bbw842@leah.Albany.Edu (Barry B Werger) (10/11/88)
Does anyone know how to receive a command-line parameter in VAX Pascal? Thank you, -Barry
geigel@soleil.UUCP (jogle) (10/12/88)
In article <1096@leah.Albany.Edu>, bbw842@leah.Albany.Edu (Barry B Werger) writes: > > Does anyone know how to receive a command-line parameter in VAX Pascal? Actually, this is a problem in VAX Pascal. We figured out a solution but it's certainly far from clean. We use the VAX system routine lib$get_foreign. A sample piece of code using this might look like: [inherit ('sys$library:starlet.pen')] program moo; type string80 = packed array [1..80] of char; string25 = packed array [1..25] of char; w_integer = [WORD]0..32767; var command_Line: string80; prompt: string25; (* prompt if no command line is given *) status: unsigned; length: w_integer; (* Length of command line returned *) x: integer; (* Determines if prompting is to be done *) [EXTERNAL]function lib$get_foreign (%stdescr in_line : string80; %stdescr prompt_st:string25 VAR out_len : w_integer; VAR x : integer) : integer; EXTERNAL; begin (* moo *) prompt:= 'prompt here '; status := lib$get_foreign (command_Line,prompt,out_len,x); ... end (* moo *). After calling lib$get_foreign, the command line will be in command_Line. Note that you have to parse this string in order to extract each parameter. (Its not like an argv array in C, its whatever was typed after the command name). You don't have to specify a prompt. We don't use promping here, and we never tried it. You can find more specific information about this routine, as well as the status codes that the function returns, in the VAX Run-time library manual. (they may also be on line. Run help and look under topic RTL-Routines.). Once you compile and link the program, you must assign the executable name to a symbol and then to run the program, type in the symbol then the rest of the command line. For example, if my executable is disk01:[jmg]moo.exe, then at the VAX prompt, one would type: $ gorf:==$disk01:[jmg]moo to run moo (with a command line), one types: $ gorf commandline Hopes this helps. good luck. -- jogle
stodghil@svax.cs.cornell.edu (Paul Stodghill) (10/12/88)
In article <421@soleil.UUCP> geigel@soleil.UUCP (jogle) writes: >In article <1096@leah.Albany.Edu>, bbw842@leah.Albany.Edu (Barry B Werger) writes: >> >> Does anyone know how to receive a command-line parameter in VAX Pascal? > > > Actually, this is a problem in VAX Pascal. We figured out a solution > but it's certainly far from clean. We use the VAX system routine > lib$get_foreign. A sample piece of code using this might look like: > > [ Code and comments ] I can think of two better ways to do it. Unfortunately, I can't give a complete discription of each since I am no longer at a VMS site and no longer have access to the manuals. Anyway, here are some pointers: First, if the format of the command line is in more-or-less usual VMS style (ie, parameters and qualifiers), try using the CLI$ routines described in the Utility Routines Manuals (all kinds of goodies here). These routines are not that difficult to figure out and save you mucho time and effort. Second, a routine called GETARGS (I think) appeared on one of the VMS mailing lists last year. This routine provided a UNIX like semantic for getting command line arguments. This is all that I remember. Sorry that this is so vague. -- Paul Stodghill stodghil@cs.cornell.edu Paul Stodghill
rlk@telesoft.UUCP (Bob Kitzberger @sation) (10/15/88)
Barry B Werger writes: > Does anyone know how to receive a command-line parameter in VAX Pascal? Three methods have been proposed : o LIB$GET_FOREIGN (passed as a single non-parsed string) o CLI$ routines (conforming to VMS syntax) o GETARGS (or somesuch package for mimicking UNIX argv/argc) Here's another. It's been a little while, and UNIX has since wreaked havoc with my once-VMS brain, so bear with the ambiguity ;-) A quick & dirty method (that is also rather flexible) is to have a small DCL command procedure that copies the DCL parameters P1 P2 ... P9 to symbols, and then executes your Pascal program. $ FILEIN :== P1 $ FILEOUT :== P2 $ BLAT :== P3 $ RUN PASCAL_STUFF etc. Then, use LIB$GET_SYMBOL in your Pascal program to extract the string values of the parameters FILEIN, FILEOUT, and BLAT into string variables. Sorry I can't provide proper syntax. The DCL shell approach also allows you to perform checking for existence of FILEIN, mount tapes, etc. - things that are less elegant in Pascal. Good luck! .Bob. -- ------------------------------------------------------------------------------ Bob Kitzberger Internet : telesoft!rlk@ucsd TeleSoft uucp : ...!ucsd.ucsd.edu!telesoft!rlk 5959 Cornerstone Ct. West at&t : (619) 457-2700 x163 San Diego, CA 92121-9891 "Nuclear weapons can wipe out life on earth, if used properly" -- Talking Heads ------------------------------------------------------------------------------