7.2.7.1 The IF statement

The IF statement conditionally executes a single statement if the comparison following the IF keyword is true.

if-clause.gif

The keyword IF is followed by a comparison of a variable to another variable or constant. With the = operator the command is executed if the compared values match, with != if they don't match respectively. Please note, that a constant value must be enclosed in double quotes, even if it is a numeric value. IF compares the string representation of the variables after formatting them as defined in the VAR statement. Hence, floating point variables always are compared after being rounded to the number of digits defined for the user interface display.

Example

    IF info.version = "2.0" PRINT "TFR " FMT "f1.3" tx.frequency
    IF info.version != "2.0" PRINT "TFR " FMT "d08" SCALE 1000.0 tx.frequency

Depending on the value of the info.version variable, the example above uses different commands to set the tx.frequency at the device. PRINT is considered as a single command, with all it's parameters in this case. If more than one command in sequence shall be executed conditionally, a GOTO statement must be used to jump over the this command sequence.