* Foreign commands and CLI$GET_VALUE, etc
@ 1993-06-22 8:26 John Lovell
1993-06-22 19:10 ` fairfield
0 siblings, 1 reply; 2+ messages in thread
From: John Lovell @ 1993-06-22 8:26 UTC (permalink / raw)
Hi, can an executable image tell whether or not it
has been installed in the command table with SET COMMAND ?
I would like to have the option of both being able to, say,
"run" an program by typing
$ run test
as well as having TEST.EXE defined as a verb with SET COMMAND.
In the latter case, I am using CLI routines to parse, say,
$ test/logfile=test.log
But if I try to "run" a program which has a CLI$GET_VALUE in
it then I get a fatal syntax error parsing "LOGFILE", "entity
not found in command table."
To avoid this problem I would like TEST.EXE to be able to query
the command table to see if it's in there and only then call
CLI routines. Can this be done?
Any help appreciated,
Thanks,
John Lovell (lovell@sdr.slb.com)
Schlumberger-Doll Research,
Ridgefield, CT 06877
203-431-5560
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Foreign commands and CLI$GET_VALUE, etc
1993-06-22 8:26 Foreign commands and CLI$GET_VALUE, etc John Lovell
@ 1993-06-22 19:10 ` fairfield
0 siblings, 0 replies; 2+ messages in thread
From: fairfield @ 1993-06-22 19:10 UTC (permalink / raw)
In article <C90Kso.5H7@sdr.slb.com>, lovell@sdr.slb.com (John Lovell) writes:
> Hi, can an executable image tell whether or not it
> has been installed in the command table with SET COMMAND ?
Yes and no. You can use CLI$GET_VALUE('$VERB', STR, LSTR) to retrieve
what DCL _thinks_ the VERB was. If you used "RUN TEST", the verb will be
"RUN". If TEST is in the command tables and you invoked the image via
"TEST...", the verb will be "TEST". However, _if_ you invoked the image
via a foreign command definition ( $TEST == "$dev:[dir]TEST"), the verb
will be somewhat indeterminate: if you did a DIRECTORY, and then did
TEST where TEST is a foreign command), "DIRE" will be returned as the verb.
> I would like to have the option of both being able to, say,
> "run" an program by typing
>
> $ run test
>
> as well as having TEST.EXE defined as a verb with SET COMMAND.
> In the latter case, I am using CLI routines to parse, say,
>
> $ test/logfile=test.log
>
> But if I try to "run" a program which has a CLI$GET_VALUE in
> it then I get a fatal syntax error parsing "LOGFILE", "entity
> not found in command table."
>
> To avoid this problem I would like TEST.EXE to be able to query
> the command table to see if it's in there and only then call
> CLI routines. Can this be done?
That's the hard way (if it can even be done). On the other hand, I and
other sysmgr types have pointed out before that _we_ would like the option to
run commercial software _either_ from a command installed in DCLTABLES,
_or_ as a foreign commands (or as RUN image :-). This is trivial to
accomplish:
1) Take your TEST.CLD. Replace the line:
IMAGE dev:[dir]TEST.EXE
by
MODULE TEST_CLD
To avoid confusion, save the modified file as TEST_CLD.CLD.
Retain TEST.CLD for those cases in which you _want_ the verb
installed in the DCL command tables.
2) Create an object file from TEST_CLD.CLD:
SET COMMAND/OBJECT TEST_CLD
This creates TEST_CLD.OBJ which you'll use at LINK time.
3) In your program TEST, use LIB$GET_FOREIGN to retrieve the command
line, append "TEST " to the beginning of it, and call CLI$DCL_PARSE.
In Fortran, it looks like this:
EXTERNAL TEST_CLD
.
.
ISS = LIB$GET_FOREIGN (COMMAND, , LCMD)
IF (.NOT.ISS) CALL EXIT (ISS)
IF (LCMD.GT.0) THEN
ISS = CLI$DCL_PARSE('TEST '//COMMAND(1:LCMD), TEST_CLD,,,)
IF (.NOT.ISS) CALL EXIT (ISS)
ELSE ! Avoid ACCVIO on COMMAND(1:0)...
ISS = CLI$DCL_PARSE('TEST', TEST_CLD,,,)
IF (.NOT.ISS) CALL EXIT (ISS)
ENDIF
After this section, the rest of your program (calls to CLI$GET_VALUE,
etc.) is unchanged.
4) When you LINK, include TEST_CLD.OBJ in the list (or add it to
your object library so it gets picked up in the search). In C,
you'll need to replace the EXTERNAL TEST_CLD with something
equivalent so that the compiler knows this is a reference to an
external module.
The method outlined above works in ALL cases: RUN <image>, DCL verb,
foreign command, and/or MCR <image>. There is an _insignificant_ increase
in processing because you potentially parse the command line twice, if and
only if the command has been installed in the command tables. On the other
hand, the point of the DCL command tables (or one point) is to verify the
command line syntax before the _significant_ overhead of image activation
is incurred. You'll never notice a second parse once the image _is_
activated.
-Ken
--
Dr. Kenneth H. Fairfield | Internet: Fairfield@Slac.Stanford.Edu
SLAC, P.O.Box 4349, MS 98 | DECnet: 45537::FAIRFIELD (45537=SLACVX)
Stanford, CA 94309 | FAX: (415) 926-4335
----------------------------------------------------------------------------
These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1993-06-22 19:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-06-22 8:26 Foreign commands and CLI$GET_VALUE, etc John Lovell
1993-06-22 19:10 ` fairfield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox