7 Replies Latest reply on Jun 22, 2010 8:21 AM by philmodjunk

    Pasting from one field to another based on a script...HELP!!

    user14830

      Title

      Pasting from one field to another based on a script...HELP!!

      Post

      Hello All!

       

      I really need some help with this one.  I'm new to the FileMaker family and I am using FM11.

       

      I'm trying to figure out a way to paste into a field only the most updated value from a few other fields, (that probably made no sense).

       

      Here's the story...I'm working on a database for logging poker hands, (I don't think you'll need to know the game to help me).  I work for a TV production company that televises poker shows and we're trying to streamline the data entry of our hands to save time and energy.

       

      Here's the basic headings for the layout....

      PLAYER NAME.....HOLE CARDS....ACTION....BET AMOUNT....POT TOTAL

       

      The action field is where a player will either fold, bet, or raise his/her opponents.  IF the player calls a bet from an opponent, (or "C" as it's entered in the value list), I would like the LAST bet made to simply be pasted in that players Bet Amount field.

       

      Here's the foil...There are six players at our final table.  If the player directly preceding the one I'm entering data for folds, then there's nothing in his/her Bet Amount field.  How do I get a script to look at other Bet Amount fields in ORDER until it finds one that has an amount and the pastes that amount into the Bet Amount field for player that calls. 

       

      I hope I explained my dilemma clearly enough for you to help.  Thanks in advance!

       

      Fred 

       

        • 1. Re: Pasting from one field to another based on a script...HELP!!
          philmodjunk

          Assuming your records are sorted in the order of play. (And not forgetting that play is circular).

           

          Freeze Window

          Set Variable [$CurrentPlayer; Value:  Get ( RecordNumber ) ]

          Set Variable [$Prev ; Value:  If ( $CurrentPlayer = 1 ; Get ( FoundCount ) ; $CurrentPlayer - 1 ]

          Go To Record [No dialog ; $Prev]

          Loop

             Exit Loop If [ ( $CurrentPlayer = $Prev ) or ( Table::Bet Amount > 0 ) ]

             Set Variable [$Prev ; Value:  If ( $Prev = 1 ; Get ( FoundCount ) ; $Prev - 1 ]

             Go To Record [No dialog ; $Prev]

          End Loop

          If [$Prev = $CurrentPlayer]

             Show Custom Dialog ["Error, no players had placed a bet..."]

          Else

             Set Variable [$Call ; Value: Table::Bet Amount ]

             Go To Record [No dialog ; $CurrentPlayer]

             Set Field [ Table::Bet Amount ; $Call ]

          End If

           

          Note: It seems to me that you might want to track all betting action in a related table so as to create a detailed history of each game. Thus, you might want to create a related betting table so that you could track all such activity.

          • 2. Re: Pasting from one field to another based on a script...HELP!!
            user14830

            Hi Phil,

             

            Thanks for your help!  I'll give this a try. 

             

            Right now each individual hand is it's own record.  The players, their actions, and bet amounts, and of course the cards, are part of the HANDS TABLE, and each record.

             

            Will your previous formula still work?

             

            Thanks again for your help.  I've read your other posts on this forum for other questions I've had and you're always the guy with the answers.  Thanks for being here for us newbies with a dream, lol.

             

            Fred

            • 3. Re: Pasting from one field to another based on a script...HELP!!
              philmodjunk

              I assumed these fields were all in one table when I posted the sample script. If there is always just one Hands record per player during the game, you'll simply need to modify identifiers to refer to the correct table and field where appropriate.

              • 4. Re: Pasting from one field to another based on a script...HELP!!
                user14830

                They are in the same table and the same record.  That's why I was wondering if the above script was still valid.

                 

                I've entered it but nothing happened.  I'm sure it's an error on the way I've entered it.  I apologize for asking such elementary questions but, what does the "$" do in a line of script?  Does it have meaning in the script or is that a reference I should be familiar with.

                 

                Because this information is in the same record, should I be replacing the identifier of GoToRecord, with GoToField??

                 

                Thanks again for your help.  I just need a little clarification on your script and I'll be on my way.

                 

                Fred

                 

                • 5. Re: Pasting from one field to another based on a script...HELP!!
                  philmodjunk

                  $ is needed at the start of a variable name so that you can use it in an expression such as Set FIeld [Table::Field ; $VariableName ]

                   

                  That's the symbol that tells filemaker that the name refers to a variable and not a field.

                   

                  What version of filemaker are you using for this? If you are using an older version that does not support variables (The script editor won't have Set Variable as a script step you can use.), you'll need to use global fields instead of these variables.

                   

                  You should not be using go to field.

                   

                  Each player has their own "Hand" record, correct? (If not, they should) That's the assumption I made when posting the script.

                   

                  If you don't have filemaker advanced (If you do select the script debugger and run the script), insert a pause/resume step as the very first step after Loop and run the script, continuing the srcript each time it pauses. This way, you should be able to watch it move from record to record and that may give you a clue as to why it isn't working.

                   

                   

                  • 6. Re: Pasting from one field to another based on a script...HELP!!
                    user14830

                    Hi Phil,

                     

                    Thanks again for your attention.  I'm using FIleMaker Pro 11.  

                     

                    Let me better explain the structure of my database.  Each hand is it's own record.  Each record consists of the hand's players, their cards, their actions, and their bet amounts.  When the hand is over, a new record for the next hand is created.

                     

                    Each hand starts with all six players that are at our final table, (or less if there's been an elimination).  As players fold, bet, call, or raise, their actions are recorded so our editor's know the dynamics of the hand.

                     

                    So if a player folds, they are done in that hand.  If a player bets, the bet amount is recorded.  If a player raises, that bet amount is recorded.  If a player calls, I would like the most recent bet amount entered to be pasted into the bet amount field of the player that called.

                     

                    I hope I explained it well enough for you, the game of poker can be confusing if you not familiar with it.

                     

                    Thanks again!

                     

                    Fred 

                     

                    • 7. Re: Pasting from one field to another based on a script...HELP!!
                      philmodjunk

                      Well I think I've played poker exactly twice and neither time for real money :smileywink:

                       

                      I think this will work provided you can keep only the current hand records in your found set sorted in order of play.