Inspect Manual

High-Level Inspect Commands
Inspect Manual429164-006
6-103
IF
IF
The IF command provides conditional execution of an Inspect command.
expression
specifies the expression that must evaluate to TRUE (that is, a nonzero value)
before Inspect will execute the command or alias following THEN.
command
is any Inspect command except FA, FB, FC, FK, or XC.
alias-name
is the name of a previously defined alias. The replacement string for the given alias
must be a valid command list.
Usage Considerations
The IF Command and the BREAK THEN Clause
You can use the IF command within the THEN clause of the BREAK command to
execute a break action conditionally. Given the following breakpoint, Inspect will
modify A only if its value is >100 when the breakpoint is triggered:
BREAK tax-section THEN "D a;IF a>100 THEN M a=1;R"
After the break event, Inspect displays the value of A, resets it to 1 if it exceeds
100, and then resumes execution. If A is less than 100, execution will not be
resumed.
Note the use of quotes when IF is used as part of the BREAK command compared
to when it is used IN an IF.
Note that using the THEN command in the THEN clause of a BREAK serves a purpose
different from the IF clause of the BREAK command. If the condition is specified in the
IF clause, Inspect breaks only when the condition is met:
The result is that A is displayed only when its value exceeds 100.You can use the
IF command within the BREAK command in the command file.
If an expression contains a string, each element of the string must be evaluated
individually. For example:
IF expression THEN { command | alias-name }
IF J=3 THEN RESUME
IF J=3 THEN DISPLAY 'Not far enough';RESUME
BREAK tax-section IF a>100 THEN "D a;M a=1;R"