mirror of
https://github.com/vishapoberon/oberonbyexample.git
synced 2026-04-05 21:02:25 +00:00
testing, need to move the enums example with complete history.
This commit is contained in:
parent
3321c74fee
commit
576603f55d
3 changed files with 0 additions and 96 deletions
|
|
@ -1,68 +0,0 @@
|
||||||
MODULE Days;
|
|
||||||
|
|
||||||
TYPE
|
|
||||||
Day* = POINTER TO DayDesc;
|
|
||||||
DayDesc = RECORD
|
|
||||||
next, prev : Day
|
|
||||||
END;
|
|
||||||
Week = ARRAY 7 OF Day;
|
|
||||||
|
|
||||||
VAR
|
|
||||||
sun*, mon*, tue*, wed*, thu*, fri*, sat* : Day;
|
|
||||||
week: Week;
|
|
||||||
|
|
||||||
PROCEDURE Next*(d : Day): Day;
|
|
||||||
BEGIN
|
|
||||||
RETURN d.next
|
|
||||||
END Next;
|
|
||||||
|
|
||||||
PROCEDURE Prev*(d: Day): Day;
|
|
||||||
BEGIN
|
|
||||||
RETURN d.prev;
|
|
||||||
END Prev;
|
|
||||||
|
|
||||||
PROCEDURE inc(VAR j: SHORTINT);
|
|
||||||
BEGIN
|
|
||||||
IF j = 6 THEN
|
|
||||||
j := 0
|
|
||||||
ELSE
|
|
||||||
INC(j)
|
|
||||||
END
|
|
||||||
END inc;
|
|
||||||
|
|
||||||
PROCEDURE dec(VAR j: SHORTINT);
|
|
||||||
BEGIN
|
|
||||||
IF j = 0 THEN
|
|
||||||
j := 6
|
|
||||||
ELSE
|
|
||||||
DEC(j)
|
|
||||||
END
|
|
||||||
END dec;
|
|
||||||
|
|
||||||
PROCEDURE init(VAR w : Week);
|
|
||||||
VAR
|
|
||||||
i,j : SHORTINT;
|
|
||||||
BEGIN
|
|
||||||
i := 0;
|
|
||||||
REPEAT
|
|
||||||
j := i; inc(j);
|
|
||||||
w[i].next := w[j];
|
|
||||||
j := i; dec(j);
|
|
||||||
w[i].prev := w[j];
|
|
||||||
INC(i)
|
|
||||||
UNTIL i > 6;
|
|
||||||
END init;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
NEW(sun); NEW(mon); NEW(tue); NEW(wed); NEW(thu); NEW(fri); NEW(sat);
|
|
||||||
week[0] := sun;
|
|
||||||
week[1] := mon;
|
|
||||||
week[2] := tue;
|
|
||||||
week[3] := wed;
|
|
||||||
week[4] := thu;
|
|
||||||
week[5] := fri;
|
|
||||||
week[6] := sat;
|
|
||||||
|
|
||||||
init(week);
|
|
||||||
|
|
||||||
END Days.
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
Example aimed to show how to survive without enumerations in Oberon.
|
|
||||||
|
|
||||||
This way is even cooler than enumerations. (:
|
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
MODULE test;
|
|
||||||
|
|
||||||
IMPORT Days, Out;
|
|
||||||
|
|
||||||
VAR today, yesterday, tomorrow: Days.Day;
|
|
||||||
|
|
||||||
BEGIN
|
|
||||||
today := Days.mon; (*init*)
|
|
||||||
|
|
||||||
yesterday := Days.Prev(today);
|
|
||||||
IF yesterday = Days.sun
|
|
||||||
THEN
|
|
||||||
Out.String("it works!"); Out.Ln
|
|
||||||
END;
|
|
||||||
tomorrow := Days.Next(today);
|
|
||||||
|
|
||||||
IF tomorrow = Days.tue
|
|
||||||
THEN
|
|
||||||
Out.String("it works!"); Out.Ln
|
|
||||||
END;
|
|
||||||
|
|
||||||
END test.
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue