Code: Select all
MODULE M;
TYPE
Pid = ARRAY 4 OF CHAR;
VAR
id: Pid;
id2: ARRAY 4 OF CHAR;
PROCEDURE P(pid: Pid);
END P;
BEGIN
P("id"); (* error *)
id := "id";
P(id); (* ok *)
id2 := "id";
P(id2) (* ok *)
END M.
Code: Select all
MODULE M;
TYPE
Pid = ARRAY 4 OF CHAR;
VAR
id: Pid;
id2: ARRAY 4 OF CHAR;
PROCEDURE P(pid: Pid);
END P;
BEGIN
P("id"); (* error *)
id := "id";
P(id); (* ok *)
id2 := "id";
P(id2) (* ok *)
END M.
Code: Select all
i := LEN("id");
Code: Select all
PROCEDURE P(pid: ARRAY OF CHAR);
END P;
9.1. Assignments
2. Strings can be assigned to any array of characters, provided the number of characters in the
string is less than that of the array. (A null character is appended).
Code: Select all
TYPE
ProcessID* = ARRAY 4 OF CHAR;
PROCEDURE Init*(p: Process; proc: Coroutines.PROC; stack: ARRAY OF BYTE; startAfter: INTEGER; period: INTEGER; pid: ProcessID);
Code: Select all
PROCEDURE Init*(p: Process; proc: Coroutines.PROC; stack: ARRAY OF BYTE; startAfter: INTEGER; period: INTEGER; pid: ARRAY OF CHAR);
Code: Select all
TYPE
ProcessID* = ARRAY 4 OF CHAR;
Ticks* = INTEGER;
Process* = POINTER TO ProcessDesc;
ProcessDesc* = RECORD
cor: Coroutines.Coroutine;
schedulerState: INTEGER;
next, nextR: Process;
period, ticker, delay: Ticks;
ptype: INTEGER;
resetCount: INTEGER;
id: ProcessID
END;
ProcessConfig* = RECORD
startAfter*, period*: Ticks;
ptype*: INTEGER;
id*: ProcessID
END;
PROCEDURE Init*(p: Process; proc: Coroutines.PROC; stack: ARRAY OF BYTE; startAfter, period: Ticks; pid: ARRAY OF CHAR);
BEGIN
ASSERT(LEN(pid) <= 4, Error.PreCond);
NEW(p.cor); Coroutines.Init(p.cor, proc, stack, pid);
p.period := period;
p.ticker := startAfter;
p.id := pid;
p.ptype := Essential;
p.schedulerState := Off;
p.resetCount := 0
END Init;
PROCEDURE Init2*(p: Process; proc: Coroutines.PROC; stack: ARRAY OF BYTE; cfg: ProcessConfig);
BEGIN
NEW(p.cor); Coroutines.Init(p.cor, proc, stack, cfg.id);
p.period := cfg.period;
p.ticker := cfg.startAfter;
p.ptype := cfg.ptype;
p.id := cfg.id;
p.schedulerState := Off;
p.resetCount := 0
END Init2;