Skip to content

Instantly share code, notes, and snippets.

@kpmy kpmy/ypkDetails
Created May 26, 2016

Embed
What would you like to do?
TYPE
ObjList* = LIMITED RECORD
list: ListsLinear.List;
END;
VAR
objList-: ObjList;
PROCEDURE (VAR l: ObjList) ForEach* (s: Service; VAR action: Action), NEW;
VAR i: INTEGER; x: ANYPTR;
BEGIN
i:=0; action.stop:=FALSE;
WHILE (i<l.list.len) & ~action.stop DO
x:=l.list.GetItem(i);
ASSERT(x#NIL, 40);
WITH x: Obj DO
action.Do(s, x);
ELSE HALT(100) END;
INC(i);
END;
END ForEach;
PROCEDURE (VAR l: ObjList) This* (idx: INTEGER): Obj, NEW;
VAR x: ANYPTR; res: Obj;
BEGIN
ASSERT(idx<l.list.len, 20); ASSERT(idx>=0, 21);
x:=l.list.GetItem(idx);
IF x#NIL THEN res:=x(Obj) END;
RETURN res
END This;
PROCEDURE (VAR l: ObjList) Length* (): INTEGER, NEW;
BEGIN
RETURN l.list.len
END Length;
PROCEDURE (VAR l: ObjList) Add(obj: Obj), NEW;
BEGIN
l.list.SetLength(l.list.len+1);
l.list.SetItem(l.list.len-1, obj);
END Add;
IMPORT ypkDetails
BEGIN
IF (h.next < ypkDetails.objList.Length()) THEN
o:=ypkDetails.objList.This(h.next);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.