Syntax10.Scn.Fnt MODULE In; (* Stream-oriented text input, MR 1992, NW 22.5.93 *) (* Procedure Next, OpenText and CONSTs from Linz added, 25.12.95 *) IMPORT Texts, Viewers, Oberon, TextFrames; CONST inval* = Texts.Inval; name* = Texts.Name; string* = Texts.String; int* = Texts.Int; real* = Texts.Real; longReal* = Texts.LongReal; char* = Texts.Char; Done-: BOOLEAN; S: Texts.Scanner; T: Texts.Text; PROCEDURE Open*; VAR beg, end, time: LONGINT; V: Viewers.Viewer; BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S); IF (S.class = Texts.Char) & (S.c = "^") THEN (* start input stream at beginning of selection *) Oberon.GetSelection(T, beg, end, time); IF time >= 0 THEN Texts.OpenScanner(S, T, beg); Done := TRUE ELSE Done := FALSE END ELSIF (S.class = Texts.Char) & (S.c = "*") THEN (* start input stream at beginning of text in marked viewer *) V := Oberon.MarkedViewer(); IF (V.dsc # NIL) & (V.dsc.next IS TextFrames.Frame) THEN T := V.dsc.next(TextFrames.Frame).text; Texts.OpenScanner(S, T, 0); Done := TRUE ELSE Done := FALSE END ELSE (* start input stream after command name *) T := Oberon.Par.text; Texts.OpenScanner(S, T, Oberon.Par.pos); Done := TRUE END Open; PROCEDURE Next* (): INTEGER; VAR s1: Texts.Scanner; BEGIN IF Done THEN Texts.OpenScanner(s1, T, Texts.Pos(S)); Texts.Scan(s1); Done := ~s1.eot; RETURN s1.class ELSE RETURN inval END; END Next; PROCEDURE Char*(VAR ch: CHAR); BEGIN IF Done THEN ch := S.nextCh; Done := ~S.eot; Texts.Read(S, S.nextCh) END END Char; PROCEDURE Int*(VAR i: INTEGER); BEGIN IF Done THEN Texts.Scan(S); i := SHORT(S.i); Done := (S.class = Texts.Int) END END Int; PROCEDURE LongInt*(VAR i: LONGINT); BEGIN IF Done THEN Texts.Scan(S); i := S.i; Done := (S.class = Texts.Int) END END LongInt; PROCEDURE Real*(VAR x: REAL); BEGIN IF Done THEN Texts.Scan(S); x := S.x; Done := (S.class = Texts.Real) END END Real; PROCEDURE LongReal*(VAR y: LONGREAL); BEGIN IF Done THEN Texts.Scan(S); y := S.y; Done := (S.class = Texts.LongReal) END END LongReal; PROCEDURE Name*(VAR name: ARRAY OF CHAR); BEGIN IF Done THEN Texts.Scan(S); COPY(S.s, name); Done := (S.class = Texts.Name) END END Name; PROCEDURE String*(VAR str: ARRAY OF CHAR); BEGIN IF Done THEN Texts.Scan(S); COPY(S.s, str); Done := (S.class = Texts.String) END END String; BEGIN Done := FALSE END In.