mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 08:42:24 +00:00
added Oberon.Mod which can be used to read command line arguments by
reading Oberon.Par.text like in Oberon system.
This commit is contained in:
parent
40a58e1771
commit
461148de7e
2 changed files with 61 additions and 0 deletions
61
src/lib/v4/Oberon.Mod
Normal file
61
src/lib/v4/Oberon.Mod
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
MODULE Oberon;
|
||||||
|
|
||||||
|
(* this version should not have dependency on graphics -- noch *)
|
||||||
|
|
||||||
|
IMPORT Kernel, Texts, Args;
|
||||||
|
|
||||||
|
TYPE
|
||||||
|
|
||||||
|
ParList* = POINTER TO ParRec;
|
||||||
|
|
||||||
|
ParRec* = RECORD
|
||||||
|
(* vwr*: Viewers.Viewer;
|
||||||
|
frame*: Display.Frame;*)
|
||||||
|
text*: Texts.Text;
|
||||||
|
pos*: LONGINT
|
||||||
|
END;
|
||||||
|
|
||||||
|
VAR
|
||||||
|
|
||||||
|
Log*: Texts.Text;
|
||||||
|
Par*: ParList; (*actual parameters*)
|
||||||
|
W : Texts.Writer;
|
||||||
|
(*clocks*)
|
||||||
|
|
||||||
|
PROCEDURE GetClock* (VAR t, d: LONGINT);
|
||||||
|
BEGIN Kernel.GetClock(t, d)
|
||||||
|
END GetClock;
|
||||||
|
|
||||||
|
PROCEDURE Time* (): LONGINT;
|
||||||
|
BEGIN
|
||||||
|
RETURN Kernel.Time()
|
||||||
|
END Time;
|
||||||
|
|
||||||
|
PROCEDURE PopulateParams;
|
||||||
|
VAR W : Texts.Writer;
|
||||||
|
i : INTEGER;
|
||||||
|
str : ARRAY 32 OF CHAR;
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
i := 1; (* skip program name *)
|
||||||
|
Texts.OpenWriter(W);
|
||||||
|
|
||||||
|
REPEAT
|
||||||
|
IF i < Args.argc THEN
|
||||||
|
Args.Get(i, str);
|
||||||
|
Texts.WriteString(W, str);
|
||||||
|
Texts.WriteString(W, " ");
|
||||||
|
END;
|
||||||
|
INC(i)
|
||||||
|
UNTIL i >= Args.argc;
|
||||||
|
|
||||||
|
Texts.Append (Par^.text, W.buf);
|
||||||
|
|
||||||
|
END PopulateParams;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
NEW(Par);
|
||||||
|
NEW(Par.text);
|
||||||
|
Texts.Open(Par.text, "");
|
||||||
|
PopulateParams;
|
||||||
|
END Oberon.
|
||||||
BIN
voc
BIN
voc
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue