H 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 <selp001@obu.arknet.edu> writes: = >	I have seen lots of talk about telling the VAX how to send  K >parameters to a program.  I have done that a lot.  You see, I am a junior  L >CS major.  We have looked at system service routines (there are only a few J >million).  What I want to know is how to get the command line parameters H >from a VAX program.  The language isn't that important, since I know:  M >VAXpascal, VAX assembly, VAX fortran, etc.  I would prefer a demo in either  H >assembly or pascal.  Note that even though I know C, we don't have a C 5 >compiler for our VAX so that won't help me.  Thanks!  >   J in some of the previous discussions on passing parameters to a program, itG was also noted a few times on how to do this. i describe it here again.  there are two ways to do it.   A:  D    1) use the lib$get_foreign routine to obtain the _entire_ commandC       line (except for the image name). i.e. if the foreign command (       EXAMPLE is setup, and the command:  		$ EXAMPLE param1 param2 param3E       is executed, calling lib$get_foreign in the program will return (       the string "param1 param2 param3".  H    2) create an command definition that describes your programs' commandD       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: 1 	$ set command/object=example_cld.obj example.cld   H    4) call the cli$ routines to parse and obtain values from the command       line. H    4a) use cli$dcl_parse to parse and validate the command line. becauseI       lib$get_foreign gets the command line string without the image name F       (i.e. verb), you must put the verb back into the string and passH       this to the cli$dcl_parse routine: "example param1 param2 param3".F       the table argument to cli$dcl_parse expects an longword external       value, i.e.: 	EXTERNAL example_parametersC    4b) use the cli$present to test if the parameter or qualifier is        present.H    4c) use the cli$get_value to get values if the CDU description allows       for values.   2    5) link the program with the CDU object module:! 	link example.obj,example_cld.obj    B:C    the other way to do the above is to follow steps 1, 2 and 4, but B    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 F    example_cld.obj in step 5. note, you will have to do this each time2    you login before you run your example program.   F i prefer A because i don't have to execute the "$ set command example"G command each time before i want to run the program. you can put this in A 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 eldridge3 vms systems support      | gvrod@isuvax.iastate.edu . iowa state university    | gvrod@isuvax.bitnet  