4203_5021@uwovax.uwo.ca (03/11/90)
I am writing some modula-2 code for a VAX-6330 and I need some assistance
using VAX Command Language (CLI) routines with my program.
Here's what I would like to do:
Run a program and grab the first parameter on the command-line
into an ARRAY of CHAR in my program.
Here's what I'm using:
A modula-2 compiler that I KNOW is NOT mocka.
The module's it uses always have the following, if it is any help:
Fachbereich Informatik
Universitaet Hamburg
D-2000 Hamburg 13
Here's what I've done:
I have located the following module:
COMMANDLA.DEF (where .IMP is, I don't know)
It EXPORTS the following:
PROCEDURE CLI$PRESENT
PROCEDURE CLI$GETVALUE
PROCEDURE CLI$DISPATCH
PROCEDURE CLI$DCL_PARSE
I know I have to set the following alias:
$name :== "(drive&directory)name.exe"
I want to run the program as:
$name parameter
I have tried to call CLI$PRESENT and CLI$GETVALUE in my
program after importing them from CommandLanguageInterface.
It compiled. It linked. It crashed.
I have alse heard i have to set up a "subcommand.cld" file.
I have tried this, but couldn't get this to work.
(I tried to write one, then use
$SET COMMAND SUBCOMMANDS/OBJECT=SUBCOMMANDS )
ANY help would be greatly appreciated.
I have next to no documentation on how to do this.
Thanks.
Patrick Bradd The University of Western Ontario
Computer Science
===============================================================================
Patrick Bradd "Before you kill somebody,
4203_5021@uwovax.uwo.ca make absolutely sure he
isn't well connected....
So it goes." <K.V.>
===============================================================================GRANT@LAUCOSC.LAURENTIAN.CA ("Grant R. Guenther") (03/12/90)
How to get command lines from DCL with the Hamburg M2 Compiler.
The first thing to realise is that you should avoid the CLI routines.
They are messy and require that you compile a .CLD file to specify the
syntax. Use the GetForeign interface instead. If a program is
invoked through a symbol, its entire command line can be easily obtained.
The following command (put it in LOGIN.COM or SYSLOGIN.COM) declares
the foreign command
$mycom :== $mydisk:[mydir]myprog
After this, a command like
$mycom anything at all
will invoke mydisk:[mydir]myprog with "anything at all" as its command
line.
To obtain the command line in an M2 program you must do two things.
First, create the following .DEF file and compile it. Leave the .SYM
file in MOD$SYSTEM (then it is reusable). There is no implementation,
the %FOREIGN takes care of that - the linker will find the standard
LIB$GET_FOREIGN in the RTL.
%FOREIGN DEFINITION MODULE Foreign;
EXPORT QUALIFIED LIB$GET_FOREIGN;
PROCEDURE LIB$GET_FOREIGN( VAR %STDESCR line: ARRAY OF CHAR ): CARDINAL;
END Foreign.
Second, in your application you should
FROM Foreign IMPORT LIB$GET_FOREIGN;
Then declare
VAR com : ARRAY [0..79] OF CHAR;
And in your initialisation code, execute
IF NOT ODD(LIB$GET_FOREIGN(com)) THEN com[0] := 0C END;
Now, com contains the command line, parse it as you wish.
Good luck, send me mail if you have any problems
Grant Guenther
Maths and Computer Science, Laurentian University, Sudbury, Ontario, Canada.
grant@laucosc.laurentian.camarkus@log-hb.se (Markus Nikolopoulos) (03/14/90)
In article <5277.25f92d46@uwovax.uwo.ca> 4203_5021@uwovax.uwo.ca writes: >I am writing some modula-2 code for a VAX-6330 and I need some assistance >using VAX Command Language (CLI) routines with my program. > Your SUBCOMMAND.CLD file should look something like: DEFINE VERB YourProgram IMAGE "Complete_file_spec_for_the_executable_of_your_program" PARAMETER P1, LABEL=MyParameter To install "YourProgram" do: $ set command subcommand.cld From your Modula-2 program you can get the parameter value by calling: ..... VAR value:ARRAY[0..30] OF CHAR; length:CARDINAL; CommandLanguageInterface.CLI$GET_VALUE('MyParameter',value,length); ..... The language used for writing CLD files allows you to define very complex combinations of parameters, options and startup values for a program. Using them saves a lot of parameter checking that you have to do within your program. The disadvantages are that you have to learn a new language and your programs become difficult to port outside VMS. I hope this helps.