[comp.os.vms] Verbs and running programs

MCGUIRE@GRIN2.BITNET.UUCP (06/09/87)

> Date:         Mon,  8 Jun 87 22:27 CDT
> From:         Turing Ghost in the  Machine <PETERSC0@VUENGVAX>
> Subject:      Verbs and running programs
>
> Is there a way to check whether a word is a logical or symbol (something
> like DIR*ECTORY or MAIL) without causing errors in DCL?  What I would like
> to do is check a parameter to see if it is a verb/symbol and $symbol if it
> is and $r parameter if it is not.

What Chris apparently wants to do is write a command procedure which
accepts a parameter which is either a DCL command or a program name.  If it
is a DCL command, the command should be executed.  If it is not, it should
be treated as a program name (by putting RUN in front of it).

> Date:         Tue, 09 Jun 87 09:50:38 EDT
> From:         Mike Sieweke <MSIEWEKE@GTRI01>
> Subject:      symbols and logicals
>
> You can tell if a word is a symbol using the f$type() lexical function.
> (requires vms 4.0 or later).  If you pass an invalid symbol to f$type, it
> returns an empty string.
>
> You can tell if a word is a logical using the f$logical() lexical function.
> It also returns an empty string if the logical does not exist.

The tools that Mike provided are excellent answers to Chris' specific query
about how to check for the existence of a logical name or a symbol.

Chris, here's some additional information that may help you.

DCL looks in two places to see if it recognizes a command.  It looks in the
symbol table first, then it looks in the DCL command table.  It doesn't
look in the logical name table.

You can use F$TYPE to check for the command in the local or global symbol
table.  Unfortunately for you, there is no lexical function which will
search the DCL command table.  As far as I know, therefore, you will have
to try the command and handle the error.

One way to handle the error is to put a SET NOON statement before you try
the command.  This prevents DCL from terminating the command procedure when
it encounters an error.  A matching SET ON later, or exiting from the
command procedure, puts DCL back in control.  Immediately after you run the
command, check the value of the symbol $STATUS.  By trial, you can discover
the value that $STATUS receives if the statement was unrecognized.  Your
procedure can check for that value and branch to the RUN command.

This doesn't turn off the error message that DCL prints, however.  There
are a couple of ways of doing this.  Both methods will also turn off error
messages that are displayed by the program that is run if the command you
try really works.  I think you're doomed to be disappointed.  Unless, of
course, you change the design of the program to check for the existence of
the program before you try your parameter as a command.  There is a lexical
function F$SEARCH which can search for a program without returning an
error.

Ed <MCGUIRE@GRIN2.BITNET>