Download user manual - Parse-O

Transcript
P A R S E - O - M A T I C
C O M M A N D S
U S E R
M A N U A L
—
F L O W
C O N T R O L
If
Format
Examples
Purpose
Parameters
Restrictions
Similar Cmds
Notes
If v1 k2 v3 c4
If CustCode = 'AB12' OutEnd 'Mary Smith'
If CustCode = 'CD34' CustAddr = '1234 Happy Lane'
Conditionally performs a command
v1 - Value to be compared
k2 - Comparator
v3 - Value to compare to v1
c4 - Command
The If command may not be combined with a command that
defines the start of a code block, such as Begin or
FileInit.
Begin, Again
The comparison is case-insensitive, so 'CAT' = 'cat'
unless you have altered the CompareCtrl setting.
The If command does not set the $Success variable!
In deference to the ingrained training of seasoned programmers, you may use the word
―then‖ after the comparison. Thus, the following command will be accepted:
If x > y then z = 'Hello'
This usage is non-standard, however, and is not recommended. The scripting engine
treats the ―then‖ as a variable, but ignores it in this context. Thus, you should never use
a variable named ―Then‖.
The If command does not have an ―Else‖ option as in most programming languages.
To execute a command when the If condition is false, use the Otherwise command.
Alternatively, you can use the Begin command with an Else section.
Otherwise
Format
Example
Purpose
Parameters
Restrictions
Similar Cmds
Otherwise c1
If Animal = 'Cat' Type = 'Feline' ; The initial If
command
Otherwise Type = 'Non-feline'
; Action taken if
false
Executes an alternative command when the If comparison
is false
c1 - Command
The Otherwise command must follow immediately after an
If.
The Otherwise command may not be combined with a
command that defines the start of a code block, such as
Begin or FileInit.
Else
Procedure
Format
Example
Purpose
Parameters
Restrictions
Procedure v1
Procedure MyCode
Defines the start of a generalized section of script
code, which is terminated with the End command
v1 - The name of the Procedure (must be a simple
variable)
Recursive procedures (i.e. procedures that call
106