OpenVMS - Trying to create an action for invalid selection

41 Views Asked by At

I'm trying to write a simple .com file that will give the user a choice to open files from a pick list. It opens the files fine when you select the number, but if you select an invalid choice, it should loop you back to the pick list. That is not working.

I've been looking at the OpenVMS User's Manual but have been unable to resolve this.

$! CHOICE.COM
$! Test file to offer choice to open one of two files
$!
$ ON WARING THEN EXIT
$ HOME:
$ WRITE SYS$OUTPUT “”
$ WRITE SYS$OUTPUT “1 – FILEA”
$ WRITE SYS$OUTPUT “2 – FILEZ”
$ WRITE SYS$OUTPUT “”
$ WRITE SYS$OUTPUT “”
$ INQUIRE P1 “Enter the number of the file to open or type X to exit:”
$ IF P1.EQS.”1”
$              THEN
$                   @FILEA.COM
$                    ENDIF
$ IF P1.EQS.”2”
$              THEN
$                   @FILEZ.COM
$                    ENDIF
$ IF P1.EQS.”X”
$              THEN
$                   EXIT
$ IF P1.EQS.””
$              THEN
$                   WRITE SYS$OUTPUT “Invalid Choice – try again!”
$                   WAIT 0:0:5
$                   GOTO HOME
$   ENDIF
$ !

I expect an invalid choice to return the user to HOME:

1

There are 1 best solutions below

1
DCL Newb On

OK, with a little help from a programmer, I have the answer.

$! CHOICE.COM
$! Test file to offer choice to open one of two files
$!
$ ON WARING THEN EXIT
$ HOME:
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "1 - FILEA"
$ WRITE SYS$OUTPUT "2 - FILEZ"
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT ""
$ INQUIRE P1 "Enter the number of the file to open or type X to exit:"
$ IF P1.EQS."1"
$ THEN
$   @FILEA
$   EXIT
$ ENDIF
$ IF P1.EQS."2"
$ THEN
$   @FILEZ
$   EXIT
$ ENDIF
$ IF P1.EQS."X" THEN EXIT
$ WRITE SYS$OUTPUT "Invalid Choice - try again!"
$ WAIT 0:0:5
$ GOTO HOME