| Flow Control Functions and variables |
| Flow Control Functions |
| else |
| end |
| if |
| if_failed |
| if_succeeded |
| repeat |
| repeat_now |
| repeat_stop |
| Flow Control Variables |
| last_result |
| error_message |
This function has no parameters.
Call this function to mark the beginning of a second execution block. If the first execution block is skipped, this one will be executed.
Example:
StopOnFailure(0)
ActivateWindowWithTitle("*notepad*")
if_succeeded()Prompt("Notepad successfully activated") else() Prompt("Notepad not activated (probably was not there)") end()
This function has no parameters.
Call this function to mark the end of an execution block.
Example:
// Show the message two times
repeat(2)Prompt("This repeats twice") end()
if(text VariableName, text ComparisonSymbol, text/number/real Value)
Or (new)
if(text Evaluation)
This function has three required parameters:
text VariableName: The name of the variable to check the value of
text ComparisonSymbol: How the values should be compared
text/number/real Value: The value to compare the value of the variable withOr (new)
text Evaluation: Total evaluation string. With this version one can use AND, OR, and parens.
Comparison Symbol Description < smaller than > greater than = equal to <= smaller than or equal to >= greater than or equal to <> not equal to Call this function mark the beginning of an execution block and to compare the value of a variable with another value. If the expression is true, the execution block is entered, otherwise it is skipped.
Example:
SetVariable("my age", 24)
SetVariable("my girlfriends age", 21)
if ("my girlfriends age", "<", "%my age%")Prompt("My girlfriend is younger than I am") else() if ("my girlfriends age", ">", 24) Prompt("I am younger than my girlfriend") else() Prompt("I am just as old as my girlfriend")
end()
end() Or (new)
Example:
SetVariable("a", 2)
SetVariable("b", 5)
SetVariable("c", 7)
if ("%a% + 4 > %b% AND ( %a%+1 > %c% OR (%a% = %b%-3)) AND test01 < test02")Prompt("true") else() Prompt("false") end()
if_failed(text VariableName = "last_result")
This function has one optional parameter:
text VariableName: The name of the variable to check the value ofCall this function mark the beginning of an execution block and to compare the value of a variable with the value 0. If the value of the variable is equal to 0, the execution block is entered, otherwise it is skipped.
Example:
StopOnFailure(0)
ActivateWindowWithTitle("*notepad*")
if_succeeded()Prompt("Notepad successfully activated") end()
if_failed()Prompt("Notepad not activated (probably was not there)") end()
if_succeeded(text VariableName = "last_result")
This function has one optional parameter:
text VariableName: The name of the variable to check the value ofCall this function mark the beginning of an execution block and to compare the value of a variable with the value 1. If the value of the variable is equal to 1, the execution block is entered, otherwise it is skipped.
For an example, see the 'if_failed' function.
repeat(text/number RepeatCount)
This function has one required parameter:
text/number RepeatCount: The number of times to repeat the execution block (-1 = repeat forever)Call this function to mark the beginning of an execution block that has to be executed multiple times.
Example 1:
// Show the message two times
repeat(2)Prompt("This repeats twice") end()
Example 2:
// Repeat forever
repeat(-1)Prompt("This repeats forever") end()
Example 3:
// Repeat 5 times
SetVariable("counter", 5)
repeat("%counter%")Prompt("This repeats 5 times") end()
This function has no parameters.
Call this function to begin the repeating loop immediately again. It will make sure the rest of the execution block will not be executed.
Example:
StopOnFailure(0)
repeat(-1)ActivateWindowWithTitle("*notepad*")
if_failed()Wait(1000)
repeat_now()end()
Prompt("Program only gets here if notepad is running")end()
This function has no parameters.
Call this function to leave the repeating loop immediately. It will make sure the rest of the execution block will not be executed and it will not repeat.
Example:
StopOnFailure(0)
repeat(-1)ActivateWindowWithTitle("*notepad*")
if_succeeded()
repeat_stop() end()
Wait(1000)end()
Prompt("Program only gets here if notepad is running")
This variable contains the result of the last function call. One can use this variable after each function call to test if the function succeeded, or failed.
Example:
StopOnFailure(0)
repeat(-1)ActivateWindowWithTitle("*notepad*")
if_succeeded("last_result")
repeat_stop() end()
Wait(1000)end()
Prompt("Program only gets here if notepad is running")
This variable contains the error message of the last failed function call. One can use this variable after a failed function call to see/display what went wrong.
Example:
StopOnFailure(0)CallScript("undefined_script")
if_failed()Prompt("It didn't work: %error_message%") end()