Parameter retrieval 
Author Message
 Parameter retrieval

Hi there,
  I was translating a Turbo Pascal 5.5 program to Modula-2 and cam across
  on the following problem :

                How can I find out what the first parameter on the
                command line was ?????

I know there is a command called : GetArg (Var Argument : ARRAY OF CHAR;
                                           Var Length : CARDINAL)

This command isn't good enough because it returns the second parameter
first. (Even better yet, it returns the next parameter)

So , GetArg on the next command line will return Parm2.

COMMAND Parm1 Parm2 Parm3 etc etc....

Please, who can help me on this one????

Thankx in advance,

--
++ Erwin van Egmond UUCP: ...!mcsun!cs.vu.nl!erwvegm            ++
++                                                              ++
++  With a {*filter*} duck, one's never alone                       ++
++      -- "The Hitchhiker's Guide to the Galaxy"             ++



Fri, 29 Apr 1994 20:28:54 GMT  
 Parameter retrieval

Quote:
> Hi there,
>   I was translating a Turbo Pascal 5.5 program to Modula-2 and cam across
>   on the following problem :

>            How can I find out what the first parameter on the
>            command line was ?????

You don't.  Modula-2 has no knowledge of command lines or other strange
thingummies.

Quote:
> I know there is a command called : GetArg (Var Argument : ARRAY OF CHAR;
>                                       Var Length : CARDINAL)

Command?  This looks like a procedure call to me.
Quick question: what M2 are you using?
Another: what library are you using?

Quote:
> This command isn't good enough because it returns the second parameter
> first. (Even better yet, it returns the next parameter)

> So , GetArg on the next command line will return Parm2.

> COMMAND Parm1 Parm2 Parm3 etc etc....

Aha, this (and the bit re TP5) tell me you are using DOS.  There is a very good
reason why a lot of DOS M2 libs don't provide argv[0] - neither does DOS, at
least not with the rest of the arguments at the end of the program segment
prefix.  As of DOS 3.0 (I think) the environment block is followed by a 2-byte
count of null-terminated strings, which follow in turn.  The fully resolved
program name (drive and all) is the first of these strings.

As to how best for you to get it....well it depends on the library you're using.
The draft std says: read a series of chars from the channel whose identity is
returned by a call to ProgramArgs.ArgChan().

Other libs do it differently, of course.  The only PC implementation I've spent
a lot of time with is the JPI v1.17.  Their library dosn't appear to offer this
facility - Lib.ParamStr() never returns argv[0].

+-Brent Summers, U of Waikato, NZ----------------------------------------+
|    "Laugh and the world ignores you.  Crying doesn't help either."     |
|      All opinions expressed are, of course, solely my own errors.      |



Sat, 30 Apr 1994 09:35:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing a parameter Rexx to JCL and return a parameter to JCL

2. VHDL to Verilog - parameter which is log2 of another parameter

3. Ada 0y wish list: parameters of package parameters

4. Parameter MyVar = ## Vs Parameter ( MyVar = ## )

5. parameter syntax for array parameter

6. language rules question: using a (passed in) parameter to define a parameter

7. help. date stamped filename retrievals

8. Record Retrieval Error

9. Retrieval of IP address

10. The Report Archiving and Retrieval System has been uploaded to Icetips

11. Record Retrieval Error (C5EEB)

12. Help New User with Record Retrieval Error!!!

 

 
Powered by phpBB® Forum Software