Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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!

Posted

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

Posted

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.

Posted

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

Posted

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.

This topic is 6949 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.