ð«Syntax10.Scn.Fnt¹üÿÿ€8ÀÔFoldElemsNewð#Syntax10.Scn.Fnt##(* This is a short demo that shows the use of fold elements. a) Middle-click at a filled triangle (e.g. behind the procedure Insert). The procedure body is shown. Middle-click at the non-filled triangle. The procedure body is collapsed again. b) Expand procedure Insert and then its local procedure Ins. You find two pseudocode actions that can also be expanded. c) Make a new fold element by selecting some text and executing FoldElems.Insert d) Compile this file with FoldComp.Compile */s A (deliberate) error is reported. Set the caret at the beginning of the text and execute FoldComp.ShowError . The error location is revealed and marked with a small rectangle. middle-click at it to get the error message. e) FoldElems.Expand expands all elements. FoldElems.Collapse collapses them all. *)Syntax10i.Scn.Fntÿÿÿÿ€8ÀÔå-ÿÿÿ€8ÀÔð#Syntax10.Scn.Fnt¯¯ VAR s: Texts.Scanner; BEGIN Texts.OpenScanner(s, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(s); IF s.class = Texts.Name THEN COPY(s.s, n) ELSE n := "" END END GetName; ÿÿÿÿ€8ÀÔåúÿÿ€8ÀÔð¶Syntax10.Scn.Fnt,£ûÿÿ€8ÀÔFoldElemsNewðÐSyntax10.Scn.FntFqýÿÿ€8ÀÔFoldElemsNewðÓSyntax10.Scn.Fnt®˜þÿÿ€8ÀÔFoldElemsNewð^Syntax10.Scn.Fntïþÿÿ½€ÀGraphicElemsAllocRectanglesNew€àÿ`Àÿ ÀÿhØÿ@hÐÿ¨ÐÿˆØÿh¸ÿˆ°ÿH°ÿH¸ÿ@€ ÿ@ ÿ,¨ÿSyntax10.Scn.Fnt £ÿ father,ˆÿ"‚ÿ pxÿЈÿ  Syntax10i.Scn.Fnt ÿÿÿÿ€8ÀÔ»p := tree; father := NIL; WHILE p # NIL DO IF elem.name = p.name THEN RETURN END; father := p; IF elem.name < p.name THEN p := p.left ELSE p := p.right END END; see pictureSyntax10i.Scn.Fntÿÿÿÿ€8ÀÔ`ÿÿÿ€8ÀÔð#Syntax10.Scn.Fnt||IF father = NIL THEN tree := elem ELSIF elem.name < father.name THEN father.left := elem ELSE father.right := elem ENDÿÿÿÿ€8ÀÔ Œ VAR p, father: Node; BEGIN elem.left := NIL; elem.right := NIL; find insertion place (father) insert elem under father END Ins;ÿÿÿÿ€8ÀÔ6d VAR x: Node; PROCEDURE Ins(elem: Node);  BEGIN NEW(x); GetName(x.name); Ins(x) END Insert; ÿÿÿÿ€8ÀÔ¼þÿÿ€8ÀÔðêSyntax10.Scn.Fntoÿÿÿ€8ÀÔFoldElemsNewð#Syntax10.Scn.Fntmm BEGIN IF x # NIL THEN P(x.left); Texts.WriteString(x.name); Texts.WriteLn(w); P(x.right) END END P;ÿÿÿÿ€8ÀÔ>Y PROCEDURE P(x: Node);  BEGIN P(tree); Texts.Append(Oberon.Log, w.buf) END Print; ÿÿÿÿ€8ÀÔÙüÿÿ€8ÀÔðÅSyntax10.Scn.Fnt/”ýÿÿ€8ÀÔFoldElemsNewð#Syntax10.Scn.FntHH VAR p, x, y, father: Node; BEGIN p := tree; father := NIL; WHILE (p # NIL) & (name # p.name) DO father := p; IF name < p.name THEN p := p.left ELSE p := p.right END END; IF p # NIL THEN IF p.right = NIL THEN x := p.left ELSIF p.right.left = NIL THEN x := p.right; x.left := p.left ELSE x := p.right; WHILE x.left # NIL DO y := x; x := x.left END; y.left := x.right; x.left := p.left; x.right := p.right END; IF father = NIL THEN tree := x ELSIF name < father.name THEN father.left := x ELSE father.right := x END END END Del;ÿÿÿÿ€8ÀÔ0a VAR name: Name; PROCEDURE Del(name: Name);  BEGIN GetName(name); Del(name); END Delete; ÿÿÿÿ€8ÀÔ7hread me MODULE FoldDemo; IMPORT Oberon, Texts; TYPE Name = ARRAY 32 OF CHAR; Node = POINTER TO NodeDesc; NodeDesc = RECORD name: Name; left, right: Node END; VAR tree: Node; w: Texts.Writer; PROCEDURE GetName(VAR n: Name);  PROCEDURE Insert*;  PROCEDURE Print*;  PROCEDURE Delete*;  BEGIN tree := NIL; Texts.OpenWriter(w) END FoldDemo.