🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #5020

Re: Using CLI routines & Modula-2

#5020
From: "Grant R. Guenther"
Date: Mon, 12 Mar 1990 15:32
55 lines
2077 bytes
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.ca
Technical Details
Message-ID: <C6F3893C35BF0022BB@LAUVAX01.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!LAUCOSC.LAURENTIAN.CA!GRANT

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!LAUCOSC.LAURENTIAN.CA!GRANT
From: GRANT@LAUCOSC.LAURENTIAN.CA ("Grant R. Guenther")
Newsgroups: comp.lang.modula2
Subject: Re: Using CLI routines & Modula-2
Message-ID: <C6F3893C35BF0022BB@LAUVAX01.BITNET>
Date: 12 Mar 90 15:32:00 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@PSUVM.PSU.EDU>
Organization: The Internet
Lines: 55