Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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.

 

  • Author

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

  • Author

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.

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
  • Author

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.