Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Case/switch statement in DCL

 
SOLVED
Go to solution
Fredrik.eriksson
Valued Contributor

Case/switch statement in DCL

A question I couldn't really find.
Is there any equivalent statement call to case/switch and is there something like linux "shift"?

Best regards
Fredrik Eriksson
4 REPLIES 4
Robert Gezelter
Honored Contributor
Solution

Re: Case/switch statement in DCL

Fredrik,

Yes. This is a question that is actually in the backlog for my OpenVMS Consultant column on OpenVMS.org (see http://www.openvms.org ).

The way that a case/switch (aka FORTRAN computed GOTO) is handled is via use of symbol substitution, to wit:

$ X = 15
$ ...
$ IF (X .LT. 0) .OR. (X. GT. 20)
$ THEN
$ .... (Error Processing) ...
$ ENDIF
$!
$ GOTO TARGET_'X'
$!
$ TARGET_0:
$ ...
$ GOTO TARGET_COMMON:
$!
$ TARGET_1:
$ ...
$ TARGET_20:
$ ...
$ TARGET_COMMON:

The usual tricks that can be done with this class of construct (e.g., coalescing different cases) are straightforward.

I hope that the above is helpful.

- Bob Gezelter, http://www.rlgsc.com
Fredrik.eriksson
Valued Contributor

Re: Case/switch statement in DCL

Thank you, that's what I thought. Was just hoping there was something like the linux case-statement, like this:
case $1 in
case-trigger)

;;
shift
esac

Best regards
Fredrik Eriksson
Robert Gezelter
Honored Contributor

Re: Case/switch statement in DCL

Fredrik,

With all due respect, there is no "linux case statement", it is a shell case statement.

There is a shell available on OpenVMS, is is available as part of the separate tools installation.

- Bob Gezelter, http://www.rlgsc.com
Hoff
Honored Contributor

Re: Case/switch statement in DCL

Or use the shell and the suite of shell tools that are available as part of the HP GNV download for OpenVMS, and write your shell scripts in bash.