From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,183a3a4a68c4fe9c X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-06-22 11:15:23 PST Newsgroups: comp.sys.dec Path: gmd.de!newsserver.jvnc.net!darwin.sura.net!math.ohio-state.edu!uwm.edu!linac!unixhub!slacvx.slac.stanford.edu!fairfield From: fairfield@slacvx.slac.stanford.edu Subject: Re: Foreign commands and CLI$GET_VALUE, etc Message-ID: <1993Jun22.111024.1@slacvx.slac.stanford.edu> Sender: news@unixhub.SLAC.Stanford.EDU Organization: Stanford Linear Accelerator Center References: Date: Tue, 22 Jun 1993 19:10:24 GMT In article , 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 , DCL verb, foreign command, and/or MCR . 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...