For conditional branching, the if-then-go construct is used.
The if statement is a conditional branch statement in a paragraph or PROC.
if {"|’}string1{"|’} [<|l|=|e|>|g] {"|’}string2{"|’} then go label if [constant|<<input.prompt>>] [conditional] [constant|<<input.prompt>>]then go label
The parameters include:
input.prompt | Ties in the screen input and output syntax: <<cnumber>> <<inumber,prompt.text>> <<f(file.name,item.name{,attribute{,value}}),prompt.text>> <<{options}{,@([x,y|bell|clr])},prompt.text{,mask}>> |
conditional |
|
label | An alphanumeric label that displays elsewhere in the paragraph. |
The if command compares the two string operators. If they are both numeric, then they are compared numerically. If either or both cannot be converted to a number, then they are compared alphabetically.
Between these two strings is a single-character conditional operator, which can be one of these:
< or l | Less than |
= or e | Equal to |
> or g | Greater than |
If the condition evaluates to true, then the paragraph processor starts searching from the beginning of the paragraph for a label which matches the one after the go statement, but which must be followed by a colon and a space. When this label is found, execution of the paragraph continues on the line containing the label.
One of the string parameters in an if statement is usually an input substitution.
PA if <<Input a number between 1 and 10:>> > 5 then go greater display Less than or equal to 5 Go done greater: display Greater than 5 done: * There must be a space after the colon
The example above asks the user for a number, and then prints a result based on the value of this number.
Labels are used as the target of if-then-go statements and consist of an alphanumeric label name, followed by a colon, and at least one space. Other paragraph commands can follow on the same line. The syntax for labels:
labels: {tcl.commands}
For example:
if<<inputx>><3 then go less 3 less 3: displays something