Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 1047 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I have a script called "generate 100 records" in a FM 13 table called qrgen that is supposed to run another script called "new record" which creates a new record then generates a QR code using the Google API. The script is supposed to run for 100 iterations but it doesn't stop at 100.

I found this FM 12 example which I would assume should work in FM 13 (the first example): https://fmhelp.filemaker.com/help/12/fmp/en/html/create_script.13.32.html

Here's my script: 

Loop
    perform script ["new record"]
   set field [qrgen::counter; qrgen::counter+1]
   Exit loop if[qrgen::counter>100]
End loop

I cannot figure out why the loop continues past 100. Any ideas would be appreciated.

PS: I've posted a version of the file here if you'd like to see it: www.blue-iceberg.com/files/qrcode.fmp12

 

 

Edited by rcacciato
Posted

Why not attach the file here, it's much more convenient.

From what I see, the counter field is not a global field - so instead of being increased at each iteration, each record gets a value of 1.

I am also puzzled why you're not using a variable as the counter instead of a field. The example you refer to seems very ancient. Note also that you're not following it correctly: if you want to use a field as the counter, then the field (which must be a global field) needs to be reset to 0 (or empty) at the beginning or at the end. Yet another reason to use a script variable (prefixed by a single $) which expires when the script has run out.

 

Posted

Ah, right. Thanks for revealing the mystery... let's say it's been a long time. I didn't know about script variables--I learned FM a century ago. How does one use a script variable? I changed counter to a global field and it worked. Then I made another change and now it doesn't... Argh.

Attaching the file here as you suggest.

Thanks so much!

qrcode.fmp12

Posted

OK scratch that, I got the counter to work. 

But I don't know about script variables. How does one use a script variable?

Thanks.

Posted
35 minutes ago, rcacciato said:

How does one use a script variable?

Try it this way:

Go to Layout [ “qrgen” (qrgen) ]
Loop
  Set Variable [ $i; Value:$i + 1 ]
  Exit Loop If [ $i > 100 ]
  Perform Script [ “new record” ]
End Loop
Posted

Wow. Simple and elegant. Thanks for explaining this, you've been a huge help!

This topic is 1047 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.