Overview
 
Parse-O-Matic's flow control commands (such as If,Begin,End,Again,Stop)let you control the order in which the lines of your script are executed.You can,for example,execute a block of commands only under certain circumstances,or cause a group of commands to be executed repeatedly (“looping ”).You can also define generalized procedures to save you having to duplicate code.
 
Again
 
Format Again [v1 k2 v3 ]
Examples See the Begin command
Purpose Causes a Begin block to repeat if the comparison is true (or if
no comparison is specified)
Parameters v1 -Value to be compared
k2 -Comparator
v3 -Value to compare to v1
Restrictions You cannot combine an Again command with an If command.
 
Begin
 
Format Begin [v1 k2 v3 ]
Examples Begin MyVar ='XYZ';Execute block if MyVar equals 'XYZ'
Purpose Marks the start of a conditional block of script code
Parameters v1 -Value to be compared
k2 -Comparator
v3 -Value to compare to v1
Defaults If no comparison is specified,the block always begins.In such
case,it makes no sense to have an Else command,and it almost
invariably means that the block will end with an Again command.
Restrictions You cannot combine a Begin command with an If command.
Similar Cmds If
Notes Comparisons are not case-sensitive,so 'CAT'='Cat'(unless
you have altered the CompareCtrl setting).
The Begin command does not set the $Success variable!
Begin blocks can be nested up to 25 levels deep.
Here is an example of the Begin command,used with Else and End:
Begin MyVar ='Cat'  
OutEnd 'The animal is feline'
OutEnd 'In fact,it is a cat'
;Executed if MyVar ='Cat'
;Executed if MyVar ='Cat'
Else  
OutEnd 'The animal is not feline' ;Executed if MyVar is not 'Cat'
End  
Note the use of indentation.Indentation of the conditional code blocks is not mandatory,but it does make a complicated script much easier to understand.This is particularly important if a Begin block contains other Begin blocks:
Begin CustCode [ 1 3 ] ='USA'
OutEnd 'The customer is in the USA'
Begin CustCode [ 4 5 ] ='NY'
OutEnd 'The customer is in New York'
End
Begin CustCode [ 4 5 ] ='TX'
OutEnd 'The customer is in Texas'
End
End
Without the indentation,the logic of the code above would be hard to follow.
Here is an example of the Begin command used in a loop:
Counter =0
Begin
Counter =Counter+
OutEnd 'The counter equals 'Counter
Again Counter #<10
This would output the numbers from 1 to 10.You could also do it this way:
Counter =0
Begin Counter #<10
Counter =Counter+
OutEnd 'The counter equals 'Counter
Again
This would output the numbers from 1 to 10.
If you wish,you can put comparisons on both the Begin and Again.Both tests are repeated on every iteration of the loop.
 
Break
 
Format Break
Examples If CustNum =MaxCustNum Break
Purpose Breaks out of the current Begin/Again block,carrying on
execution at the line following the next Again command
Similar Cmds Continue
 
Call
 
Format Call v1 [v2 v3 v4...]
Examples Call MyProcedure 'Hello!';Pass 'Hello!'to MyProcedure
Purpose Invoke a generalized section of script code
Parameters v1 -The name of the Procedure;doubles as a variable for
    passing information to and receiving results back from
    the Procedure
v2 -Value (any number of values can be appended)
Defaults If v2 is not specified,the procedure variable v1 is assigned
a null value.
Restrictions Calls from procedures into other procedures,which in turn call
other procedures (and so on),can nest up to 50 levels deep.
When you Call a procedure,execution of the script jumps to the first line of the procedure and continues until the corresponding End statement.The name of the procedure is also the variable name containing any parameters passed in v2,v3 and so on (the values are concatenated).Here is a sample script:
Call OutWithExclaim 'Hello,''world' ;Call the procedure
OutEnd 'Glad you could join us!' ;This line is run after the Call
Stop ;Stop running script lines
Procedure OutWithExclaim ;Start of the procedure
OutWithExclaim =OutWithExclaim '!' ;Add an exclamation point
OutEnd OutWithExclaim ;Output
End ;Return to the line after the Call
This would output the string 'Hello,world!'then return to the line following the Call command.
 
Continue
 
Format Continue
Examples If Status ='Ignore'Continue
Purpose Jumps ahead to the Again of the current Begin/Again block
Similar Cmds Break
 
Done
 
Format Done
Examples Skips the rest of the script (for the current record)
Purpose Stop,NextFile,NextStep
Similar Cmds The Done command is usually used with the If command,
or at the end of a Begin/End block.
Here is an example of the Done command:
If EmployeeNum <>1234 Done
In this case,we are checking to see if the variable EmployeeNum is equal to 1234.If it is not,we skip the remainder of the current processing step.
 
Else
 
Format Else
Examples See the Begin command
Purpose Defines the start of the conditional code block that is
executed if the Begin comparison is false.
Restrictions You cannot combine an Else command with an If command.
 
End
 
Format End
Examples See the Begin command
Purpose Marks the end of a Begin block
Restrictions You cannot combine an End command with an If command.
 
Exit
 
Format Exit
Purpose Immediately returns from a Procedure
Restrictions You cannot combine an End command with an If command.
The Exit command is typically used in conjunction with a comparison.You do not need to include an Exit command in every Procedure;it is used to skip the rest of the procedure if some condition is met.For example:
Procedure AdjustPhoneNumber
TrimChar PhoneNumber 'A '
Change PhoneNumber '/''-'
Change PhoneNumber '.''-'
AreaCode =PhoneNumber [1 3 ]
If AreaCode ='416'Exit
If AreaCode ='905'Exit
PhoneNumber ='1-'PhoneNumber
;Remove spaces
;Tidy up format
;Tidy up format
End
In this example,the procedure puts '1-'in front of a phone number unless it starts with 416 or 905.
 
If
 
Format If v1 k2 v3 c4
Examples If CustCode ='AB12'OutEnd 'Mary Smith'
If CustCode ='CD34'CustAddr ='1234 Happy Lane'
Purpose Conditionally performs a command
Parameters v1 -Value to be compared
k2 -Comparator
v3 -Value to compare to v1
c4 -Command
Restrictions The If command may not be combined with a command that defines
the start of a code block,such as Begin or FileInit.
Similar Cmds Begin,Again
Notes 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 Otherwise c1
Examples If Animal ='Cat'Type ='Feline';The initial If command
Otherwise Type ='Non-feline';Action taken if false
Purpose Executes an alternative command when the If comparison is false
Parameters c1 -Command
Restrictions 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.
Similar Cmds Else
 
Procedure
 
Format Procedure v1
Examples Procedure MyCode
Purpose Defines the start of a generalized section of script code,which
is terminated with the End command
Parameters v1 -The name of the Procedure (must be a simple variable)
Restrictions Recursive procedures (i.e.procedures that call themselves)are
not formally supported and their use is not recommended.
Notes See the Call command for additional details about procedures.
As the script is being run,any Procedure sections are ignored when encountered;they are only executed
when explicitly invoked by Call.Procedures can go anywhere except within conditional blocks such as
Begin/End,FileInit/End and so on.Procedures are usually placed together at the end of the script.
 
Stop
 
Format Stop [v1 ]
Examples If CustNum [1 ] ='X'Stop 'Invalid customer number'
Purpose Terminates further processing
Parameters v1 -Optional pop-up message
Similar Cmds Done,NextStep
Notes If v1 is included,a pop-up message is displayed.In such case,
the Stop is considered an “abnormal ” end of processing and the
script-enabled application should proceed accordingly.
 

(This page is part of the online user manual for Parse-O-Matic.  Parse-O-Matic is a programmable parsing tool that can extract, manipulate, convert or mine existing data sources and turn them into importable data.  For more information on Parse-O-Matic products and conversion services, please visit www.ParseOMatic.com)