[Oberon] FPGA - DIY Dialogs

Tomas Kral thomas.kral at email.cz
Tue Jan 15 17:02:50 CET 2019


On Mon, 14 Jan 2019 11:26:27 +0100
Jörg Straube <joerg.straube at iaeth.ch> wrote:

> So while storing the list, first store the constant object elements
> if the object is not stored already (so you have to remember whether
> you stored an object’s instance already) and then store the list
> elements.

Hi,

Thanks. I keep unique names in an array, referring to them by an
index, or if first instance by index+name. Testing it.

This sets a fixed limit on numer of object types (frames, buttons, text boxes, ...) e.g. max 16. While INTEGER number of instances. 
 
I would like to keep unique name list instead, reading from the root and adding at an end. But not sure what is better.

The file has this format { id [name] x y w h [obj properties] }

  PROCEDURE ReadObjName(VAR r: Files.Rider; VAR mod: ObjName);
    VAR id: BYTE; mods: ARRAY 16 OF ObjName;
  BEGIN Files.ReadByte(r, id);
    IF id = end THEN Files.ReadString(r, mod); mods[id] := mod; INC(end)
    ELSE mod := mods[id] END
  END ReadObjName;

  PROCEDURE WriteObjName(VAR r: Files.Rider; mod: ObjName);
    VAR id: BYTE; found: BOOLEAN; mods: ARRAY 16 OF ObjName;
  BEGIN  found := FALSE; id := 1;
    WHILE ~ found & (id < end) DO
      IF mod = mods[id] THEN found := TRUE END ; INC(id)
    END ;
    Files.WriteByte(r, id);
    IF ~ found THEN Files.WriteString(r, mod); mods[id] := mod; INC(end) END
  END WriteObjName;

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list