Gosub
Gosub>Subroutine_Name[,value1[,value2[,...]]]
Branches to the specified subroutine (SRT). When that the subroutine returns, processing continues at the next line after the Gosub command.
Subroutines can be nested. Subroutines can be located anywhere within the script.
If values are passed on the Gosub line variables will be created to contain these values. The variables are named with the following format: SubroutineName_Var_1, Subroutine_Var_2, ... Subroutine_Var_n
Gosub Example
Gosub>EnterName
Gosub>CloseApp
//// Subroutines Below ////
SRT>FocusApp
SetFocus>Data Entry Screen
End>FocusApp
SRT>EnterName
Gosub>FocusApp
Send>Firstname
Press Tab
Send>Surname
Press Enter
End>EnterName
SRT>CloseApp
Gosub>FocusApp
Press ALT
Press F4
Release ALT
End>CloseApp
Subroutine (SRT)
SRT>Subroutine_Name
Identifies the start of a Subroutine block. Use END to end the subroutine.
Subroutines can be nested. Subroutines can be located anywhere within the script.
In almost all circumstances subroutines should be allowed to end properly and it is best practice to do so. In other words execution should always continue on to the subroutine's End statement. While it is possible to jump out of a subroutine using a Goto statement the scope of execution will remain inside the subroutine unless and until execution returns to the subroutine and the subroutine's End statement is reached. This is most noticeable when using an OnEvent event handler. If, for example, a KEY_DOWN event is set to fire a subroutine and code is allowed to jump out of the subroutine, OnEvent won't know that the subroutine has ended and therefore no subsequent KEY_DOWN events of the same type will fire. If you do need to cause execution to jump to a label after the subroutine has terminated use the SkipLabel command.
By default variables have global scope. Variables can be set to have local scope by setting LOCALVARS to 1. See topic: Variable Scope.
SRT Example
Gosub>EnterName
Gosub>CloseApp
//// Subroutines Below ////
SRT>FocusApp
SetFocus>Data Entry Screen
End>FocusApp
SRT>EnterName
Gosub>FocusApp
Send>Firstname
Press Tab
Send>Surname
Press Enter
End>EnterName
SRT>CloseApp
Gosub>FocusApp
Press ALT
Press F4
Release ALT
End>CloseApp
SkipLabel
SkipLabel>Label_Name
SkipLabel is used within a subroutine to tell the script to jump to a label after the subroutine has ended. It is bad practice to jump out of a subroutine using a Goto statement - as the subroutine may then never end, causing problems with, for example, OnEvent handlers. In some cases however it is useful to cause the script to jump to a label once the subroutine has finished. This is what SkipLabel does.
Note:
Note that SkipLabel is NOT supported by OnEvent subroutines.SkipLabel Example
Let>x=0
Repeat>x
Let>x=x+1
GoSub>ExampleSubroutine
Until>x=100
SRT>ExampleSubroutine
If>x=5
SkipLabel>EndScript
Endif
//this bit still gets executed
Let>y=x
END>ExampleSubroutine
Label>EndScript
MessageModal>y
Assigned>Variable_Name,result
Used to determine whether or not a variable has been assigned. Assigned sets result to TRUE if Variable_Name exists, FALSE if not.
Abbreviation : ASS
Assigned Example
Assigned>strName,strNameExists
If>strNameExists=TRUE,DoName,SkipName
EndWhile
EndWhile
Use in conjunction with While to create a loop. The code between While and EndWhile will repeat while condition is true.
Note:
Note that the condition is evaluated at the start of the loop and therefore at the start of each iteration.EndWhile Example
Let>x=0
While>x<10
Let>x=x+1
MessageModal>x
EndWhile
Goto
Goto>Label_Name
Causes execution to continue at the specified label, missing any commands in between. If the label does not exist an error message will be displayed.
Label_Name can be or include a variable name.
Goto in conjunction with Label, can be used to create infinite loops. Use the If.. commands to cause conditional branching. To break out of infinite loops press Stop, or choose the Break option from the taskbar pop up menu.
Goto Example
Label>Start
..
..
Goto>SecondBit
..
..
Label>SecondBit
..
If
If
If[,label_name[,false_label_name]]
statements
[ [Else
else statements]
Endif ]
Evaluates expression. If the expression is true the first statements are executed. If the expression is false the statements after Else are executed. Else is optional. IF blocks can be nested. When label names are provided execution of the script jumps to the specified labels or subroutine names. If label names are specified Else and Endif are ignored and are unnecessary.
The expression can be simple (legacy), or complex.
Complex Expressions
The expression must be contained within curly braces "{" and "}". String literals must be delimited with double quotes ("), e.g.:
"string". Variables must be delimited with % symbols, e.g.: %VarA%.
Several types of operators and functions can be used with complex expressions. For more details see Complex Expressions.
Simple Expressions
Simple expressions can contain only two parts separated by one of the following operators:
- = Equals
- > Greater than
- < Less than
- <> Not Equal
Values in the expression can be numeric or string values, or variables containing such values. Spaces must not be used as simple expressions do not require string delimiters.
If Example
Let>a=5
//simple expression only
IF>a=5
//do something
ELSE
//do something else
ENDIF
//complex expression:
IF>{(%a% = 5) AND (%VarA% = "allen")}
//do something
ELSE
//do something else
ENDIF
//using labels
Label>Start
..
..
..
If>a<b,Start
IfNot
IfNot
IfNot>expression[,true_label_name[,false_label_name]]
statements
[ [Else
else statements]
Endif ]
The reverse of If. Evaluates expression. If the expression is not true the first statements are executed. If the expression is true the statements after Else are executed. Else is optional. IF blocks can be nested. When label names are provided execution of the script jumps to the specified labels or subroutine names. If label names are specified Else and Endif are ignored and are unnecessary.
For more information on how to use this please see If.
Label
Label>Label_Name
Marks a point in the script to allow execution to be passed to that point by the Goto, and If.. commands.
Goto in conjunction with Label, can be used to create infinite loops. Use the If.. commands to cause conditional branching. To break out of infinite loops press Stop, or choose the Break option from the taskbar pop up menu.
Label Example
Label>Start
..
..
Goto>SecondBit
..
..
Label>SecondBit
..
Let
Let>variable_name=value
Let is used to assign a value to a variable.
Where parameters are passed to commands, variables can also be passed. Variables can also be embedded within a parameter by enclosing the variable name within % symbols.
Let can also be used to perform basic calculations, and to concatinate strings. NB. If you want to assign to a variable a string that already contains a + sign, add an extra + sign to avoid the two strings being concatinated.
The value can contain a complex expression:
Complex Expressions must be contained within curly braces "{" and "}". String literals must be delimited with double quotes ("), e.g.: "string". Variables must be delimited with % symbols, e.g.: %VarA%.
Several types of operators and functions can be used with complex expressions. For more details see Complex Expressions.
Let Examples
Let>name=freddy Let>a=5 Let>path=c:\Program Files\ Run Program>%path%myapp.exe Let>k=k+1 Let>A=60-4 Let>A=5*3 Let>F=75/32 Let>Forename=John Let>Surname=Smith Let>Name=%Forename% %Surname% Name would now equal John Smith Let>MyVal={Upper("WorLd")} Let>MyVal={5 * 10 + 25} Let>d={%a%+%b%*%c%-23}Remark
Remark>Some Comment
The remark statement is ignored by the interpreter. It exists simply to allow comments to be placed in the code. You can also use // E.g.:
// This is a comment
Comments must be on a line of their own.
Several lines of code can also be commented out in one go by using /* before and */ after the lines to be commented. E.g.:
/*
Let>r=5
Repeat>r
DDERequest>Excel,efile.xls,R%r%C2,Name,60
Let>r=r+1
Until>r=5 */
You can also use /* ... */ at the end of lines of real code
Repeat
Repeat>variable
Use in conjunction with Until. Iterates the code from the Repeat statement to the Until statement until the specified expression in the Until statement becomes true. Until can take one of the following simple expressions:
variable,value |
for backward compatibility. Same as variable=value |
variable=value |
Until variable equals the value specified |
variable>value |
Until variable is greater than the value specified |
variable<value |
Until variable is less than the value specified |
variable<>value |
Until variable does not equal the value specified |
Alternatively Until can take a full complex expression (specified between curly braces).
Until will loop back to the last Repeat that has the same counter variable.
Repeat Example
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
Until
Until>variable,finalvalue
Use in conjunction with Repeat. Iterates the code from the Repeat statement to the Until statement until the specified expression in the Until statement becomes true. Until can take one of the following simple expressions:
variable,value |
for backward compatibility. Same as variable=value |
variable=value |
Until variable equals the value specified |
variable>value |
Until variable is greater than the value specified |
variable<value |
Until variable is less than the value specified |
variable<>value |
Until variable does not equal the value specified |
Until will loop back to the last Repeat that has the same counter variable.
Until Example
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
WaitReady
WaitReady>paint_events
WaitReady suspends script execution until the foreground window has finished processing mouse, keyboard, show window, and optionally, paint events. Issue 1 to include paint events, and 0 to exclude paint events. This command can therefore be used to wait until the active application is ready to receive keyboard and mouse events in most situations.
Abbreviation : WRD
WaitReady Example
Run Program>"C:\Program Files\Microsoft Office\Office\WINWORD.EXE"
WaitWindowOpen>Microsoft Word*
WaitReady>0
Message>Word is now ready for input
While
While>condition
Use in conjunction with EndWhile to create a loop. The code between While and EndWhile will repeat while condition is true.
Note: Note that the condition is evaluated at the start of the loop and therefore at the start of each iteration.
While can take one of the following simple expressions:
variable,value |
for backward compatibility. Same as variable=value |
variable=value |
Until variable equals the value specified |
variable>value |
Until variable is greater than the value specified |
variable<value |
Until variable is less than the value specified |
variable<>value |
Until variable does not equal the value specified |
Alternatively While can take a full complex expression (specified between curly braces).
While Example
Let>x=0
While>x<10
Let>x=x+1
MessageModal>x
EndWhile
Comments
0 comments
Please sign in to leave a comment.