November 16, 200520 yr 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!
November 16, 200520 yr 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
November 16, 200520 yr 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.
November 16, 200520 yr 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
November 16, 200520 yr 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