Besides knowing the command line parameters, it is often required to get a notion of the unix environment
variables that can be listed from a terminal with the 'set' command. But for accessing these vars from within
an executable, another mechanism is required.
This project is about the reading of environment parameters from within a running executable. I wrote this flimsy program just to familiarize with the way the Unix environment variables can be accessed and dealt with.
Accessing unix environment variables with Mocka.
MODULE trye; FROM Arguments IMPORT ArgTable, GetEnv; FROM InOut IMPORT WriteCard, WriteLn, WriteString, WriteBf; FROM Strings IMPORT Assign, Length; VAR item : CARDINAL; storage : ArgTable; Value : ARRAY [0..511] OF CHAR; BEGIN GetEnv (storage); item := 0; LOOP IF storage^ [item] = NIL THEN EXIT END; Assign (Value, storage^ [item]^); WriteCard (item, 4); WriteString (' : ['); WriteCard (Length (Value), 4); WriteString ('] '); WriteString (Value); WriteLn; INC (item) END; WriteBf END trye.This source code is fairly similar to the program to get hold of the commandline parameters, only in this instance we don't know upfront when the table is over....
Have fun with Modula-2. If you need to mail me, look in the navigator of this section.
Page created 19 August 2004,