Library /sys$common/syshlp/helplib.hlb  —  IF  Examples
    1.$ COUNT = 0
      $ LOOP:
      $ COUNT = COUNT + 1
         .
         .
         .
      $ IF COUNT .LE. 10 THEN GOTO LOOP
      $ EXIT

      This example shows how to establish a loop in a command
      procedure, using a symbol named COUNT and an IF statement.
      The IF statement checks the value of COUNT and performs an EXIT
      command when the value of COUNT is greater than 10.

    2.$ IF P1 .EQS. "" THEN GOTO DEFAULT
      $ IF (P1 .EQS. "A") .OR. (P1 .EQS. "B") THEN GOTO 'P1'
      $ WRITE SYS$OUTPUT "Unrecognized parameter option ''P1' "
      $ EXIT
      $ A:       !  Process option a
       .
       .
       .
      $ EXIT
      $ B:       !  Process option b
       .
       .
       .
      $ EXIT
      $ DEFAULT: !  Default processing
       .
       .
       .
      $ EXIT

      This example shows a command procedure that tests whether a
      parameter was passed. The GOTO command passes control to the
      label specified as the parameter.

      If the procedure is executed with a parameter, the procedure
      uses that parameter to determine the label to branch to. For
      example:

        @TESTCOM A

      When the procedure executes, it determines that P1 is not null,
      and branches to the label A. Note that the EXIT command causes
      an exit from the procedure before the label B.

    3.$  SET NOON
       .
       .
       .
      $  LINK CYGNUS,DRACO,SERVICE/LIBRARY
      $ IF $STATUS
      $ THEN
      $  RUN CYGNUS
      $ ELSE
      $   WRITE SYS$OUTPUT "LINK FAILED"
      $ ENDIF
      $ EXIT

      This command procedure uses the SET NOON command to disable
      error checking by the command procedure. After the LINK
      command, the IF command tests the value of the reserved global
      symbol $STATUS. If the value of $STATUS indicates that the LINK
      command succeeded, then the program CYGNUS is run. If the LINK
      command returns an error status value, the command procedure
      issues a message and exits.

    4.$ if 1 .eq. 1
      $ then
      $   if 2 .eq. 2
      $   then
      $     write sys$output  "Hello!"
      $   endif
      $ endif

      This example shows how to use a nested IF structure.
Close Help