2 Replies Latest reply on Aug 31, 2010 8:41 AM by philmodjunk

    Basic counter script

    zackdenzer

      Title

      Basic counter script

      Post

      I am trying to learn how to use the scripts. This one is just a basic counter loop I was trying. I wanted the script to go to the next record 10 times, then stop. I put that last set field just to see if the script went through. I am using the sample tutorial that comes with filemaker pro 11. The "field" is just a global txt field I created. Needless to say, it isnt working.

      Show all records

      Go to record/request [first]

      Set Field [Members::Field; Members::Field=0]

      Loop

      Go To Record/Request [next]

      Exit Loop if [Members::Field=10]

      Set field [Members::field +1]

      End Loop

      Set field [Members:: Home Address 2; Members Home Address 2=1]

       

        • 1. Re: Basic counter script
          sunmoonstar.13

          The script should look like this:

           

          Show all records
          Go To Record/Request [first]
          Set Field [Members::Field; 0]
          Loop
             Go To Record/Request [next]
             Exit Loop If [Members::Field=10]
             Set field [Members::field ; Members::field +1]
          End Loop
          Set field [Members::Home Address 2; 1]

           

          Note the bits in red that differ from the script given in your original post.

           

          Nick

           

          • 2. Re: Basic counter script
            philmodjunk

            While your script will work fine with a global text field, its a good habit to get into to use number type field for numbers, text fields for text and date fields for dates. FileMaker often lets you put the wrong type of data into a field and sometimes it works OK like this script. Other times such as when sorting or comparing values, it'll trip you up with unexpected results. Thus, it's a good practice to use the right field types consistently so you can avoid "head scratcher" results from your scripts.