[Oberon] System.Directory options

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Nov 1 15:40:36 CET 2017


> On Sun Oct 22 18:16:10 CEST 2017 Paul Reed wrote:
>    ...
>    WHILE ch > "!" DO pat[i] := ch; INC(i); Texts.Read(R, ch) END;
>    pat[i] := 0X; pat[i+1] := ch; (*directory option*)
>>

A more general solution that also allows for multiple single-character options is:

  i := 0;
  WHILE ch > " " DO
    IF ch = "!" THEN pat[i] := 0X; pat[i+1] := "!"; INC(i, 2) (*directory option*)
    ELSE pat[i] := ch; INC(i)
    END ;
    Texts.Read(R, ch)
  END ;
  pat[i] := 0X;

The difference is that this solution reads the *entire* argument string, i.e. it does
not stop at the first “!” character. This leads to at least two desirable properties:

1) First, it makes it easy to accept *multiple* single-character directory options, so
long as the first one is “!” (one could of course remove that limitation). For example,

  System.Directory *.Mod!$? ~

could be interpreted as having three single-character options “!”, “$”, “?”. Procedure
System.List can be easily adapted to simply read the remaining characters after the “!”

Second, it naturally lends itself to be ported to situations, where the *entire*
argument string MUST be read anyway, for example, when receiving it over an RS232
line - this is the case, for example, in Oberon0.Mod (Oberon-0 command interpreter
which is the top module of the build-up boot file used for booting over a serial line).

With the above modifications, it is easy o make it work in that environment: one
only has to replace the line

  Texts.Read(W, ch)

with the following line

 RS232.Rec(x); ch := 0X

Neither original Oberon solution nor the change proposed by Paul would work in
Oberon0, since the partner program on the host computer always sends the *entire*
argument string, no matter what (see module ORC.Mod). If the client does not read
it all, it will simply hang (or time out). The above code works in all situations.

Just my two Maria Theresien Taler..

-AP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171101/d5d02bae/attachment.html>


More information about the Oberon mailing list