home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / oberon / system / in.mod (.txt) < prev    next >
Oberon Text  |  1977-12-31  |  2KB  |  76 lines

  1. Syntax10.Scn.Fnt
  2. MODULE In;    
  3. (* Stream-oriented text input, MR 1992, NW 22.5.93 *)
  4. (* Procedure Next, OpenText and CONSTs from Linz added, 25.12.95 *)
  5. IMPORT Texts, Viewers, Oberon, TextFrames;
  6. CONST
  7.     inval* = Texts.Inval;
  8.     name* = Texts.Name;
  9.     string* = Texts.String;
  10.     int* = Texts.Int;
  11.     real* = Texts.Real;
  12.     longReal* = Texts.LongReal;
  13.     char* = Texts.Char;
  14.     Done-: BOOLEAN;
  15.     S: Texts.Scanner;
  16.     T: Texts.Text;
  17. PROCEDURE Open*;
  18. VAR beg, end, time: LONGINT;
  19.     V: Viewers.Viewer;
  20. BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);  Texts.Scan(S);
  21.     IF (S.class = Texts.Char) & (S.c = "^") THEN
  22.         (* start input stream at beginning of selection *)
  23.         Oberon.GetSelection(T, beg, end, time);
  24.         IF time >= 0 THEN Texts.OpenScanner(S, T, beg); Done := TRUE
  25.         ELSE Done := FALSE
  26.         END
  27.     ELSIF (S.class = Texts.Char) & (S.c = "*") THEN
  28.         (* start input stream at beginning of text in marked viewer *)
  29.         V := Oberon.MarkedViewer();
  30.         IF (V.dsc # NIL) & (V.dsc.next IS TextFrames.Frame) THEN
  31.             T := V.dsc.next(TextFrames.Frame).text; Texts.OpenScanner(S, T, 0); Done := TRUE
  32.         ELSE Done := FALSE
  33.         END
  34.     ELSE (* start input stream after command name *)
  35.         T := Oberon.Par.text; Texts.OpenScanner(S, T, Oberon.Par.pos); Done := TRUE
  36. END Open;
  37. PROCEDURE Next* (): INTEGER;
  38.     VAR s1: Texts.Scanner;
  39. BEGIN
  40.     IF Done THEN
  41.         Texts.OpenScanner(s1, T, Texts.Pos(S));
  42.         Texts.Scan(s1); Done := ~s1.eot; RETURN s1.class
  43.     ELSE RETURN inval
  44.     END;
  45. END Next;
  46. PROCEDURE Char*(VAR ch: CHAR);
  47. BEGIN
  48.     IF Done THEN ch := S.nextCh; Done := ~S.eot; Texts.Read(S, S.nextCh) END
  49. END Char;
  50. PROCEDURE Int*(VAR i: INTEGER);
  51. BEGIN
  52.     IF Done THEN Texts.Scan(S); i := SHORT(S.i); Done := (S.class = Texts.Int) END
  53. END Int;
  54. PROCEDURE LongInt*(VAR i: LONGINT);
  55. BEGIN
  56.     IF Done THEN Texts.Scan(S); i := S.i; Done := (S.class = Texts.Int) END
  57. END LongInt;
  58. PROCEDURE Real*(VAR x: REAL);
  59. BEGIN
  60.     IF Done THEN Texts.Scan(S); x := S.x; Done := (S.class = Texts.Real) END
  61. END Real;
  62. PROCEDURE LongReal*(VAR y: LONGREAL);
  63. BEGIN
  64.     IF Done THEN Texts.Scan(S); y := S.y; Done := (S.class = Texts.LongReal) END
  65. END LongReal;
  66. PROCEDURE Name*(VAR name: ARRAY OF CHAR);
  67. BEGIN
  68.     IF Done THEN Texts.Scan(S); COPY(S.s, name); Done := (S.class = Texts.Name) END
  69. END Name;
  70. PROCEDURE String*(VAR str: ARRAY OF CHAR);
  71. BEGIN
  72.     IF Done THEN Texts.Scan(S); COPY(S.s, str); Done := (S.class = Texts.String) END
  73. END String;
  74. BEGIN Done := FALSE
  75. END In.
  76.