In many instances, the software must be able to interact with the user. This can be done in real time (in user time), or it can be done up front, ie, when the program is invoked.
This project is about the upfront passing of parameters by means of the command line. I wrote this flimsy program just to familiarize with the way the commandline options are accessed and dealt with.

The environment variables are accessed in a remotely similar way. Read all about it in the 'GetEnv' project.

Commandline parsing with Mocka.

MODULE try;

FROM  Arguments  IMPORT  GetArgs, ArgTable, GetEnv;
FROM  InOut	 IMPORT	 WriteCard, WriteLn, WriteString;


VAR   count, item	 : SHORTCARD;
      storage		 : ArgTable;   


BEGIN
   GetArgs (count, storage);
   item := 0;
   REPEAT 
      WriteCard (item, 4);
      WriteString (' :  ');
      WriteString (storage^ [item]^);
      WriteLn;
      INC (item)
   UNTIL item = count
END try.
   
The source is small. But it's also clear. I won't comment or add anything here, apart from the fact that the line with the WriteString in it (storage^ [item]^) shows that we dealt with the POINTER TO POINTER definition by means of double carets (^).

Have fun with Modula-2. If you need to mail me, look in the mainfile of this section.

Page created 2005,