ack/lang/m2/test/getenv.mod

30 lines
601 B
Modula-2
Raw Normal View History

1988-04-20 10:43:48 +00:00
MODULE PrEnv;
FROM InOut IMPORT WriteString, WriteLn, ReadString, Done;
FROM Arguments IMPORT GetEnv, Argv, Argc;
VAR Buf: ARRAY[1..256] OF CHAR;
i: INTEGER;
BEGIN
FOR i := 0 TO INTEGER(Argc) - 1 DO
IF Argv(i, Buf) > SIZE(Buf) THEN
WriteString("Argument too long");
WriteLn;
HALT;
END;
WriteString(Buf);
WriteString(" ");
END;
WriteLn;
LOOP
WriteString("Environment name: ");
ReadString(Buf);
IF NOT Done THEN EXIT; END;
IF GetEnv(Buf, Buf) = 0 THEN
WriteString("No environment variable");
ELSE
WriteString(Buf);
END;
WriteLn;
END;
WriteLn;
END PrEnv.