From: Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> Date: Wed, 14 Mar 2018 19:10:54 +0100 IF v.state > 1 THEN (*v is a displayed viewer*) ELSIF v.state = 1 THEN (*v is a filler viewer*) ELSIF v.state = 0 THEN (*v is a closed viewer*) ELSIF v.state < 0 THEN (*v is a suspended viewer*) END OK, thanks. My exercise including "Oberon.MarkedViewer().state > 1" follows. For * marked viewers, distinguishing an original style Text viewer from a Document viewer is by the order of the two Marked evaluations. I have yet to learn how to make the distinction for selected Text. Is a selection in a plain viewer or in a Document viewer? Necessary if I want to open a new viewer of the same style as the original. Any comments about the exercise are welcome of course. Likely I've missed at least one detail. Thanks, ... Lyall E. MODULE ParameterHandling IN Oberon; IMPORT Documents, Oberon, Texts; VAR S: Texts.Scanner; W: Texts.Writer; sel: Texts.Text; beg, end, time: LONGINT; source: CHAR; (* "t" for all Text in a Text viewer, "d" for all Text in a Document viewer, "n" for * parameter following command and no marker displayed, "s" for for Text selected in a Text viewer, "u" for for Text selected in a Document viewer, "o" for ^ parameter following command but no selection, "f" for a named file and "z" for command with no parameter; ParameterHandling.Test ~ . *) (* ParameterHandling.Test * (Marked viewer), ParameterHandling.Test ^ (Text selection), ParameterHandling.Test { <filename> } ~ Named files containing Texts. *) PROCEDURE Test*; BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S); IF S.class=Texts.Char THEN IF S.c="*" THEN (* Viewer marked? *) IF (Documents.MarkedDoc() # NIL) & (Oberon.MarkedViewer().state > 1) THEN source := "d" ELSIF (Oberon.MarkedViewer() # NIL) & (Oberon.MarkedViewer().state > 1) THEN source := "t" ELSE source := "n" END ELSIF S.c="^" THEN (* Text selected? *) Oberon.GetSelection(sel, beg, end, time); (* Is the Text in an original style Text viewer or in a Document viewer? *) IF sel # NIL THEN source := "s" ELSIF FALSE THEN source := "u" ELSE source := "o" END END ELSIF S.class=Texts.Name THEN (* Existing or new file named. *) source := "f" ELSE source := "z" END; Texts.WriteString(W, "source = "); Texts.Write(W, source); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf); IF source = "f" THEN Texts.WriteString(W, "Filename parameter = "); Texts.WriteString(W, S.s); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf); END END Test; BEGIN Texts.OpenWriter(W) END ParameterHandling. Compiler.Compile * ~ ParameterHandling.Test * ParameterHandling.Test ^ ParameterHandling.Test Oberon.ParameterHandling.Mod ~ -- This message was transmitted by software carefully written to avoid the overhead and vulnerability of antivirus software. 123456789 123456789 123456789 123456789 123456789 123456789 123456789 Tel: +1 360 639 0202 Pender Is.: +1 250 629 3757 http://easthope.ca/Peter.html Bcc: peter at easthope. ca
participants (1)
-
peter@easthope.ca