[Oberon] Oberon.Text and "Registry".

Jörg joerg.straube at iaeth.ch
Wed Jan 29 06:38:10 CET 2020


Hi

If you want to configure your SW you have at least three options. The following sample code demonstrates these options with an imaginary command "setaccount" of an imaginary mail client.

a) write own parser code to parse parameters handed over to the called command.

  IMPORT Oberon, Text;
  PROCEDURE setaccount;
    VAR S: Texts.Scanner;
    BEGIN (* no code for error handling *)
      Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
      IF S.class = Texts.String THEN method := S.s; Text.Scan(S) END;
      IF S.class = Texts.String THEN account := S.s; Text.Scan(S) END;
      IF S.class = Texts.String THEN pw := S.s END
    END setaccount;

b) write a "registry" module that parses an external text file (eg. Oberon.Text). With the help of that registry module parse your entries in that external file and fill internal variables with the data you got from the registry.

  IMPORT Registry;
  PROCEDURE setaccount;
    BEGIN
      Registry.GetEntry("Mail", "method", method);
      Registry.GetEntry("Mail", "user", account);
      Registry.GetEntry("Mail", "password", pw)
    END setaccount;
  
c) fill internal variables with the configuration data you hardcoded in your code. Basically, the compiler is the parser for your data (
  PROECDURE setaccount;
    BEGIN
      method := "IMAP";
      account := "Joerg.Straube at iaeth.ch";
      pw := "CiaoBello"
    END setaccount;

As always all options have pros and cons.
Counter-intuitively, c) is sometimes the easiest and fastest method. c) can be used as the Oberon system allows separate compilation and dynamic loading/unloading of modules. c) is especially useful if the module you re-configure is not too low in the module hierarchy and you don't have to unload tons of other modules.

a) is usable in a lot of scenarios without the need for an external registry.

b) seems easy, but needs a module "Registry" to be written first. In an embedded system, where size matters and you perhaps only reconfigure very seldom or use Registry only for one parameter in your code, this Registry code overhead might be too big. BTW: I wrote a module Registry.Mod for ProjectOberon (

br
Jörg

Am 29.01.20, 01:00 schrieb "oberon-bounces at lists.inf.ethz.ch im Auftrag von peter at easthope.ca" <oberon-bounces at lists.inf.ethz.ch im Auftrag von peter at easthope.ca>:

    Hi,
    
    S3 and A2O (is A2O an acceptable name for the Oberon subsystem of 
    A2?) are configured by content of the file Oberon.Text.
    
    V5 doesn't have Oberon.Text.  
    
    Can anyone tell how V2 and V4 were configured?
    
    The sources of S3 and A2O have scattered references to the "Registry".
    That is the content of Oberon.Text beginning with LinkSchemes?
    
    I've added "Oberon.Text" and "Registry" to 
    https://en.wikibooks.org/wiki/Oberon#Glossary .  Corrections welcome.
    
    Thanks,              ... Lyall E.
    
    
    
    -- 
    https://en.wikibooks.org/wiki/Medical_Machines
    https://en.wikibooks.org/wiki/Oberon
    Tel: +1 604 670 0140            Bcc: peter at easthope. ca
    
    --
    Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
    https://lists.inf.ethz.ch/mailman/listinfo/oberon
    




More information about the Oberon mailing list