From: MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 31-MAR-1993 21:39:40.87 To: Info-VAX@KL.SRI.COM CC: Subj: Re: Getting parameters. John Selph writes: > I have seen lots of talk about telling the VAX how to send >parameters to a program. I have done that a lot. You see, I am a junior >CS major. We have looked at system service routines (there are only a few >million). What I want to know is how to get the command line parameters >from a VAX program. The language isn't that important, since I know: >VAXpascal, VAX assembly, VAX fortran, etc. I would prefer a demo in either >assembly or pascal. Note that even though I know C, we don't have a C >compiler for our VAX so that won't help me. Thanks! > in some of the previous discussions on passing parameters to a program, it was also noted a few times on how to do this. i describe it here again. there are two ways to do it. A: 1) use the lib$get_foreign routine to obtain the _entire_ command line (except for the image name). i.e. if the foreign command EXAMPLE is setup, and the command: $ EXAMPLE param1 param2 param3 is executed, calling lib$get_foreign in the program will return the string "param1 param2 param3". 2) create an command definition that describes your programs' command structure (see Command Definition Utility). i.e.: EXAMPLE.CLD: module example_parameters define verb example parameter p1 parameter p2 parameter p3 3) create an object module from the above CDU description: $ set command/object=example_cld.obj example.cld 4) call the cli$ routines to parse and obtain values from the command line. 4a) use cli$dcl_parse to parse and validate the command line. because lib$get_foreign gets the command line string without the image name (i.e. verb), you must put the verb back into the string and pass this to the cli$dcl_parse routine: "example param1 param2 param3". the table argument to cli$dcl_parse expects an longword external value, i.e.: EXTERNAL example_parameters 4b) use the cli$present to test if the parameter or qualifier is present. 4c) use the cli$get_value to get values if the CDU description allows for values. 5) link the program with the CDU object module: link example.obj,example_cld.obj B: the other way to do the above is to follow steps 1, 2 and 4, but instead of creating an object module as in step 3, just add the command definition to your process' command definitions: $ set command example then, skip the EXTERNAL definition in 4a, and remove the example_cld.obj in step 5. note, you will have to do this each time you login before you run your example program. i prefer A because i don't have to execute the "$ set command example" command each time before i want to run the program. you can put this in your login.com file, but if you're like me, i have dozens of such programs and this just slows down my login time too much. the disadvantage of A is that the image must be invoked _before_ the command line parameters are validated. in B, the command line is validated _before_ the image is invoked. ___ rod eldridge vms systems support | gvrod@isuvax.iastate.edu iowa state university | gvrod@isuvax.bitnet