Skip 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.

Can script parameter replace global counter?

Featured Replies

Hi all,

I'm trying to figure out all the ways a script parameter can be used instead of a global field. Is there any way to use a script parameter instead of a global field when a counter is needed (like in a loop)?

Thanks in advance for any input on the subject!

Hi

Yes, you can !

For example, this set a variable to 1 and loop until it becames 10 :

Set Variable [$counter; Value: 1]

Loop

Set Field [ field; $counter ]

Set Variable [ $counter; Value: $counter + 1 ]

Exit Loop If [ $counter > 10 ]

End Loop

At the end of the script you'll have field = 10

If you want to see field increasing from 1 to 10 add this line after the third:

Pause/Resume Script [ Duration(seconds): 0,3] :)

[color:red]$counter is a local variable, but you can make it a global variable by naming it: [color:red]$$counter

Hi Kent,

True, script variables could be used in this way for loop counters, but script parameters work a little different: they can only be set upon calling a script.

So you could use script parameters as loop control in a recursive script (since each script call gets a new parameter sent,) but they would not be suitable in an iterative loop.

faster than me ^

Edited by Guest

ah ... they were parameters and not variables !

Sorry for my miss-reading !

I'm trying to figure out all the ways a script parameter can be used instead of a global field. Is there any way to use a script parameter instead of a global field when a counter is needed (like in a loop)?

This is a straight forward recusive call:

If [ IsEmpty ( Get ( ScriptParameter ) ) ] 

     Perform Script [ “New Script”; Parameter: 1 ] 

Else 

     #Your stuff here! 

     #Your stuff here! 

     #Your stuff here! 

     #Your stuff here! 

     If [ Get ( ScriptParameter ) = 10 ] 

            Exit Script [  ] 

     Else 

            Perform Script [ “New Script”; Parameter: GetAsNumber ( Get ( ScriptParameter ) ) + 1 ] 

     End If 

End If 

....and it can't be stressed enough the importance of having a stop value, here = 10....

--sd

  • Author

Wow, thanks to all for the replies!

You've given me some good food for thought...now I just have to digest it and experiment with it.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.