3.3.2.30 IfIf-cmd
Syntax:
if (testCondition) sentencel; [else sentence2;]
if (testCondition) (script1) [else (script2)]
Evaluate testCondition and if true, execute script1. Expressions without conditional operators are considered true if the result of the expression is non-zero.
If the optional else is present and testCondition is false (zero), then execute script2. There should be a space after the else. Strings should be quoted and string comparisons are not case sensitive.
Single statement script arguments should end with a semicolon. Multiple statement script arguments must be surrounded by braces {}. Each statement within the braces should end with a semicolon. It is not necessary to follow the final brace of a script with a semicolon.
Examples:
The following script opens a message box displaying "Yes!".
%M = test;
if (%M == "TEST") type -b "Yes!";
If a graph window is active, this script opens a message box displaying, "A graph is active"; if a worksheet is active, a message box opens with "A worksheet is active".
if(exist(%H)==3)
type -b "A graph is active";
else
if(exist(%H)==2)
type -b "A worksheet is active";
The next script finds the first point in data1_a that is greater than 100.
ii = 1;
{
if (data1_a[ii] > 100) break;
else ii++; // this semicolon ends the if-else statement
};
if (ii != $(numPoints + 1))
{
type -b "The index number of first value >100 is $(ii)";
type "first value > 100 is $(data1_a[ii])" ;
}
See Also:
Break (command),
Switch (command)
Continue (command),
Document (command),
Exit (command),
For (command),
Loop (command),
Repeat (command)
|