OpenVMS DCL Computed GOTO/CASE Statement
This sample code was the subject of “DCL Computed GOTO”, the June 9, 2009 installment of The OpenVMS Consultant, a column on OpenVMS computing hosted by OpenVMS.org.
This sample code illustrates how a Computed GOTO (FORTRAN) or switch (C/C++) statement is constructed in OpenVMS DCL. This sample code includes support both for a string index, and for a verification that the string index contains one of the expected values.
$ VALID_INDICES = "\ONE\TWO\THREE\FOUR\" $ IF F$LOCATE("\"+F$EDIT(INDEX, "UPCASE")+"\", VALID_INDICES) - .EQ. F$LENGTH(VALID_INDICES) $ THEN $ INDEX = "DEFAULT_PROCESSING" $ ENDIF $ ! $ GOTO TARGET_'INDEX' $ ! $ TARGET_ONE: $ ... $ GOTO EXIT_TARGET $ ! $ TARGET_TWO: $ ... $ GOTO EXIT_TARGET $ ! $ TARGET_THREE: $ ... $ GOTO EXIT_TARGET $ ! $ TARGET_FOUR: $ ... $ GOTO EXIT_TARGET $ ! $ TARGET_DEFAULT_PROCESSING: $ ... $ ! $ EXIT_TARGET: |