AnsweredAssumed Answered

Set Field to increment record count challenge

Question asked by HerbLoner on May 10, 2011
Latest reply on May 12, 2011 by HerbLoner


Set Field to increment record count challenge


I want to take a file of (let's say) 28 records, perform a script on the first record, count it as "1", advance to the second record, perform the same script, count as "2", and continue doing this until I reach "7". Then I want to continue with record number eight, perform a different script, count it as "1", and continue till I reach "7" again, and do this with every 7 records.  In FoxPro this has been very easy: "counter = counter + 1". It would appear that the Set Field command would work similarly in FM.

Here is my script:

Go to [First] Record

Set Field [ filename:fieldname;  filename:fieldname = -1]

(Note: if I use a 0, it inserts a "1" in the first record)


   Exit Loop If [ filename:fieldname = 7]

   Perform some script

   Set Field [ filename:fieldname; filename:fieldname + 1]

   Go to [Next] Record

End Loop

Exit Script


This script puts a “1” in the first 27 records until the last record where it loops 7 times, puts a “7” in the field and then exits.  What am I going astray?  Thnx for your  help.