Q From:	CSBVAX::MRGATE!SCHUMANN%GRIN1.Bitnet@CUNYVM.CUNY.EDU@SMTP  2-MAR-1988 15:56  To:	ARISIA::EVERHART Subj:	Thanks for all the fish!    Q Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Mon 29 Feb 88 11:57:49-PST L Received: from GRIN1.Bitnet by CUNYVM.CUNY.EDU ; Mon, 29 Feb 88 14:53:45 EST! Date: Mon, 29 Feb 88 12:54:55 cst = From: "Schumann,Mark" <SCHUMANN%GRIN1.BITNET@CUNYVM.CUNY.EDU>  To:   INFO-VAX@KL.SRI.COM ! Subject: Thanks for all the fish!     B Thanks to all those who responded to my query a few weeks ago.  As* promised, here is the digest of responses.     Regards,   Mark W. Schumann <SCHUMANN@GRIN1.BITNET>   I =========================================================================   , DIGEST OF RESPONSES TO MY INFO-VAX QUESTION:  :         HOW DO I PASS SWITCHES FROM A FOREIGN COMMAND VERB%         INTO A DCL COMMAND PROCEDURE?   J ==========================================================================   From: A. Mahendra Rajah        University of Regina       Regina, Saskatchewan       Canada       <RAJAH@UREGINA1.BITNET>   D The most elegant way is to  use a program and the command definitionJ language. You can then specify switches in any order and the CLI$ routinesJ will find them. Compilation, linking, etc can then be done using LIB$SPAWN from the program.    From: Patrick Martin"       University of North Carolina       <MARTIN@UNCVAX1.BITNET>   C Define a .CLD file for valid command syntax/verbage/qualifiers, add H routines to handle the different qualifiers, and define the routine as a! foreign command with SET COMMAND.    From: Jeff E Nelson 9       Virginia Polytechnic Institute and State University        <NELSONJE@VTVAX5.BITNET>  % Define your CCLGO command as follows:    $ CCLGO == "@disk:[dir]cclgo *"   M This passes "*" to the command procedure as P1.  You should start looking for 3 user qualifiers and parameters at P2.  For example,    $ CCLGO/PRINTER=YMLN03 OUTLINE  9 Passes the following parameters to the command procedure:    P1 = "*" P2 = "/PRINTER=YMLN03" P3 = "OUTLINE"   From: Tom Vaughan        Computer Center        Canisius College       <VAUGHAN@CANISIUS.BITNET>    [sent two examples:]  A First is mac.com, a real simple command stream that will pull off J qualifiers and use them inside to modify the behavior of what is going on.  H The next is a pascal program that has several qualifiers defined for it,H the same as anyother dcl command.  It has a command verb defined for it,A and then those values are retrieved using a call to cli$getinput.    From: Bill Costa       University Computing!       University of New Hampshire        <W_COSTA@UNHH.BITNET>   @ I have written command procedures that do this, but only throughG brute-force methods.  There are some tricks to the trade.  For example:   0         $ MYPROG == "@somewhere:MYPROG.COM """""  J defines the command procedure MYPROG as a DCL command.  The trick with allF those quote marks is simply to pass a null string as the value for theI first parameter. Now this means you only have 7 possible parameters left, 0 but it also means that DCL will now let you say:           $ MYPROG/QUAL MYFILE  I where before it wouldn't.  Of course "/QUAL" is the value of P2, "MYFILE"  is the value of P3, etc.  K Now for 'real' programs (i.e. written in your favorite hi-level programming K language, Pascal, BASIC, FORTRAN, C, etc.) DEC makes it easy.  You create a K 'CLD' file which describes the qualifiers and parameters you want, and then B at run-time, your program simply asks DCL to hand the values over.E [Inconvenient to call system utilites like compiler and linker . . .]   E There are only two things I can think of doing to solve this problem:   A 1.  Write a 'real' program that uses a CLD definition for all the G parameters and qualifiers that you want your procedure to accept.  This I program, when executed, simply takes the hard-won information supplied by D DCL and turns around and executes a DCL command procedure, using theD information wanted as parameter values (in some well defined order).  B 2.  Write a general purpose program which is called by the command procedure that needs it.   From: Jonathan Borden (       Yale University School of Medicine       <BORDEN@YALEMED.BITNET>   J yes there is a fairly easy way to do this using the CLI$ routines (Command> Line Interface) look this up in the programming support manual   From: Bertrand Buclin        Computer Support Group!       Computer Science Department +       Swiss Federal Institute of Technology        CH-1015 Lausanne       <BUCLIN@CLSEPF51.BITNET>  J First in DCL : write a command procedure doing the parsing of your commandJ line, i.e. the parsing of parameters P2 to P8, and define your symbol CLGOK as CLGO :== @proc foo where foo is a dummy P1 parameter allowing you to add # qualifiers to the pseudo verb CLGO.   G Second, in a language : you will use the mechanism DEC uses for all its ? applications. This is documented in the following two manuals :   " - Vol 7B, command definition (CDU), - Vol 8A, Utilities routines (CLI interface)  I I think the manuals give enough examples, so I don't send you an example.      From: Steve Roseman        Lehigh University         <LUSGR@VAX1.CC.LEHIGH.EDU>       <LUSGR@LEHICDC1.BITNET>          PROGRAM TEKFILE          integer status>       character file*40, scale*20, xbias*20, ybias*20, param*5%       character verb*4, verbs(-1:9)*4   @       data verbs/'TEKF', 'TEKD', 'DTDR', 'HDSD', 'DEDR', 'SEID',8      +           'TK1D', 'PCDR', 'PCED', 'HPDR', 'PCMD'/  +       status = cli$get_value('P1', file, i)  !     print *, status, file, i3       if(status.ne.0 .or. i.le.0) file = 'PLOT.PLT'   /       status = cli$get_value('SCALE', scale, i)  !     print *, status, scale, i /       if(status.ne.0 .or. i.le.0) scale = '1.0'        param = 'SCALE' /       read (scale, '(bn,f20.0)', err=90) ascale   /       status = cli$get_value('XBIAS', xbias, i)  !     print *, status, xbias, i /       if(status.ne.0 .or. i.le.0) xbias = '0.0'        param = 'XBIAS' /       read (XBIAS, '(bn,f20.0)', err=90) axbias   /       status = cli$get_value('YBIAS', ybias, i)  !     print *, status, ybias, i /       if(status.ne.0 .or. i.le.0) ybias = '0.0'        param = 'YBIAS' /       read (YBIAS, '(bn,f20.0)', err=90) aybias   .       status = cli$get_value('$VERB', verb, i)3       if(status.ne.0 .or. i.le.0) file = 'PLOT.PLT'        iprog = -1       do 10 i=-1, 9 )          if(verb .eq. verbs(i)) iprog = i   10      continue   5       CALL DOTEK(iprog, file, ascale, axbias, aybias) 
       STOP    90   continue2       print *, param, ' parameter is not numeric.'
       stop	       END   
 -------------    ! TEKFILE definitions  ! Revised: SGR 01/05/88    define verb TEKFILE !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb TEKDRAW !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb DTDRAW!   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb HDSDRAW !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb DEDRAW!   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb SEIDRAW !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb TK1DRAW !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb PCDRAW!   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb PCEDRAW !   image "LU$LIB:[EXE]TEKFILE.EXE"    qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE2   define verb HPDRAW!   image "LU$LIB:[EXE]TEKFILE.EXE"a   qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUE    define verb PCMDRAWt!   image "LU$LIB:[EXE]TEKFILE.EXE"b   qualifier SCALE, VALUE   qualifier XBIAS, VALUE   qualifier YBIAS, VALUE   parameter P1, VALUEN       From: Mike Sieweke%       Georgia Tech Research Institutel       Atlanta, Georgia       <MSIEWEKE@GTRI01.BITNET>"       <MSIEWEKE@GTRI01.GATECH.EDU>  J I have come up with a way to do exactly what you want.  You have to define? your with the first parameter, and then it works.  For example:=   $ test :== @com_dir:test + $ test/bogus  K In this case, "+" is passed as p1, and "/BOGUS" is passed as p2.  There mayEJ be other ways to get this to work, but I just found this out a minute ago.I I always wanted to do this myself, but couldn't figure out how until now.n    - From: Carlo Mekenkamp <BOTMAN@HLERUL5.BITNET>a  I For command procedures switches example look at jan_gmail:gmail.com.  Fora: languages you can use CLI$-routines.  [Also sent samples.]     From: Kees DeGroot(       Wageningen Agricultural University&       Computer-centre, the Netherlands       <DEGROOT@HWALHW50.BITNET>B  E It can be done. Define a procedure, say test.com to be the following:o  $ $! TEST.COM to demonstrate the trick8 $ WRITE SYS$OUTPUT "P IS: ''P1' ''P2' ''P3' ''P4' ''P5'" $ EXIT  B And now for the interesting part! Define a symbol test as follows:   $ TEST :== @TEST %  / After that call your test with arguments as in:   % $ TEST/SWITCH MONKEYS/DONKEYS BLA BLAd  G You will see that you get all arguments passed to P1, P2 etc.  The onlymH thing to do in DCL is to remove the %. That will be an exercise for you!   From: SUTTON@BRANDEIS.BITNET  K For switches immediately following the symbol you need to define the symboleG with a dummy argument.  I've done this with my generic COMPILE command,oD which takes a file and compiles it according to it's file-type.  For instance, I can say:           $ COMPILE/LIST THIS   B It will do a search on file, THIS.*, and compile it with the /LIST
 qualifier.  B Since a sequence of qualifiers are always followed by a space whenE immediately following the verb, you can get such a list in the SECONDo) parameter if you define your symbol thus:   &         $ COMPILE == "@COM$:COMPILE X"  G You throw away the first parameter (it'll just be the X).  You can thennE check the first character of P2 to see if it's a slash.  If the firstlA parameter is a sequence of qualifiers, I keep it around as globalr& qualifiers to be applied to each file.  H For those qualifiers coming later in the command line such as the secondJ example, I use F$ELEMENT with a comma as the separator to get a value fromJ the list and parse the qualifiers out with string manipulation.  One thingJ to keep in mind is that if one of the qualifiers takes a list of values orI a quoted string containing a comma, F$ELEMENT will pare off the parameterh at the wrong comma.t  G [Another thing that COMPILE will do is process TeX and LaTeX files fromY compiling to printing.]     & From: Lewis,Pat J <LEWIS@GRIN1.BITNET> To:   Schumann,MarkE  E [Pat is a Grinnell student--obviously others on BITNET can't read hisyB files, but I didn't think it fair to leave this contribution out.]  K For an example of command line parsing, see the files [LEWIS.CLD]LOGOUT.CLDa. and [LEWIS.PROGRAMMING.C.LOGOUT]FILE_LOGOUT.C.  I You can get further examples of CLDs by typing @DISK$SYS3:[VERB]VERBSETUP ? and then typing $ VERB your-favorite-DCL-command.  For example,                    $ VERB LOGOUTf  E would print the LOGOUT.CLD to the screen.  To dump it to a file, typeC  /                 $ VERB/OUTPUT=LOGOUT.CLD LOGOUTr  H For further documentation on the CLI$ routines, see manuals 7B and 8A in the resource room.  F P.S. There are also other examples of my own CLDs that can be found inN      [LEWIS.CLD], and furthermore many of the files in my account are publicly>      readable, most notably the .COM files in [LEWIS.COMMAND].  , From: McMahon,Brian D <MCMAHON@GRIN1.BITNET>  H If you're working entirely in DCL, the only option I know of is to use a< command format like CCLNG FOO.C/<switch>, in which case P1 =J "FOO.C/<switch>", which the DCL routine has to parse.  (Using some variant of F$LOCATE("/",P1) perhaps.)r  K Disadvantage: In this case, the switch MUST come after the file, to preventrC VMS from gagging on it.  This is how the PGO command goes about itsaF business.  If you want "real" switches that can go anywhere, then thatG implies using CLI$ routines, which implies a compiled program.  I don'taF know of any other way to do it.  If you get any good ideas that aren't+ posted to the list, I'd love to see them...t    ' From: Joe Meadows <JOE@FHCRCVAX.BITNET>   E You can write a command to do just what you want (either 'foreign' or I normal). If it's a general case of having lots of command procedures that H you want to run this way, you could write one program that used the CLI$G routines, gets the command line, rewrites it in some such way, and havep  that call the command procedure.  J This mess just gives you a general way of getting strange things into DCL,J which might really be what you want to do. However, the CLI$ routines (andK SET COMMAND) allow you to do fairly complex command parsing, and you shouldb6 really check it out sometime for its intentioned uses.       From: John Hascall.       Iowa State University Computation Center       Ames, Iowa 50011 USA       <GGUUU@ISUMVS.BITNET>     6 The solution is to define the foreign command as such:  .       $ CCLGO :== @disk:[dir]filename DUMMYARG  * this will get the slash past DCL's parser.  L ============================================================================  = As you can see, the solution boils down to one of two things:   C         1. Trick DCL into thinking that the verb switch is actuallys0            a parameter by feeding it a dummy P1.           2. Or write a CLD.  
 Thanks again.,    