I'm starting to get into Macro Scheduler programming, so I'm not quite sure what's possible and not.
I'm finding that I need to check if a variable is defined, and set it to default value if undefined. For example, test the TIMEOUT variable as such:
Code: Select all
Assigned>TIMEOUT,result
If>{%result%="FALSE"}
Let>TIMEOUT=0
EndIf
// From here on, I can use TIMEOUT variable safely
Code: Select all
GoSub>SetIfNotDefined,{"TIMEOUT"},0
Code: Select all
SRT>SetIfNotDefined
// Save LOCALVARS to restore at exit to minimize side effect
Let>TMP_LOCALVARS=%LOCALVARS%
Let>LOCALVARS=0
// SOWriteLn>%SetIfNotDefined_var_1% %SetIfNotDefine_var_2%
// I can't get this statement to work correctly
Assigned>%SetIfNotDefined_var_1%,result
If>{%result%="FALSE"}
SOWriteLn>%SetIfNotDefined_var_1% not defined, setting to %SetIfNotDefined_var_2%
// This statement works as expected because LOCALVARS=0
Let>%SetIfNotDefined_var_1%=%SetIfNotDefined_var_2%
EndIf
// Restore LOCALVARS
Let>LOCALVARS=%TMP_LOCALVARS%
END>SetIfNotDefined
There is an existing enhancement request to allow Assigned to work for complex expressions: http://www.mjtnet.com/usergroup/viewtopic.php?p=25410
Until the above enhancement request is (hopefully) implemented, is it possible to implement the SRT above in a different way?
Thanks