if command (C and C++)

The if command lets you conditionally perform a command. You can optionally specify an else clause on the if command. If the test expression evaluates to false and an else clause exists, the command associated with the else clause is performed. The if and else keywords must be lowercase and cannot be abbreviated.

Read syntax diagramSkip visual syntax diagram if ( expression ) command elsecommand ;
expression
A valid z/OS® Debugger C and C++ expression.
command
A valid z/OS Debugger command.

When if commands are nested and else clauses are present, a given else is associated with the closest preceding if clause within the same block.

Usage notes

  • An else clause should always be included if the if clause causes z/OS Debugger to get more input (for example, an if containing USE or other commands that cause z/OS Debugger to be restarted because an AT-condition occurs).
  • The if command cannot be used while you replay recorded statements by using the PLAYBACK commands by using the PLAYBACK command.

Examples

  • The following example causes grade to receive the value "A" if the value of score is greater than or equal to 90.
    if (score >= 90)
       grade = "A";
  • The following example shows a nested if command.
    if (paygrade == 7) {
       if (level >= 0 && level <= 8)
          salary *= 1.05;
       else
          salary *= 1.04;
    }
    else
       salary *= 1.06;