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

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. StampElems
  4. Alloc
  5. 10 Mar 94
  6. Syntax10b.Scn.Fnt
  7. MODULE Automatic;    (* Michael Franz, 3.11.90; << SHML 
  8.     (* A simple macro facility for executing several commands at once. Each command has to be terminated with "~".
  9.         Example:
  10.             Automatic.Do
  11.                 System.Directory D*.Mod ~
  12.                 System.DeleteFiles
  13.                     a.Bak
  14.                     b.Bak
  15.                 ~
  16.                 Browser.ShowDef TextFrames ~
  17.     IMPORT Display, Texts, Viewers, Oberon;
  18.     VAR W: Texts.Writer;
  19.     PROCEDURE NextLine(text: Texts.Text; pos: LONGINT): LONGINT;
  20.         VAR R: Texts.Reader; ch: CHAR;
  21.     BEGIN
  22.         IF pos < text.len THEN
  23.             Texts.OpenReader(R, text, pos); Texts.Read(R, ch);
  24.             WHILE ~R.eot & (ch # "~"(*<<0DX*)) DO Texts.Read(R, ch) END;
  25.             IF R.eot THEN RETURN -1 ELSE RETURN Texts.Pos(R) END
  26.         ELSE RETURN -1
  27.         END
  28.     END NextLine;
  29.     PROCEDURE Do*;
  30.         VAR
  31.             S: Texts.Scanner; text: Texts.Text; vwr: Viewers.Viewer; frame: Display.Frame;
  32.             pos: LONGINT; par: Oberon.ParList; res: INTEGER;
  33.     BEGIN
  34.         Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
  35.         NEW(par); vwr := Oberon.Par.vwr; frame := Oberon.Par.frame; text := Oberon.Par.text;
  36.         WHILE S.class = Texts.Name DO
  37.             par.vwr := vwr; par.frame := frame; par.text := text; par.pos := Texts.Pos(S)-1;
  38.             pos := NextLine(text, par.pos);
  39.             Texts.WriteString(W, "Auto> "); Texts.WriteString(W, S.s); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
  40.             Oberon.Call(S.s, par, FALSE, res);
  41.             IF pos > 0 THEN Texts.OpenScanner(S, text, pos); Texts.Scan(S) ELSE S.class := Texts.Inval END
  42.         END
  43.     END Do;
  44. BEGIN Texts.OpenWriter(W)
  45. END Automatic.
  46.