[Oberon] FPGA - Oberon7 - Type Cast

Chris Burrows chris at cfbsoftware.com
Wed Oct 3 14:03:45 CEST 2018


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Tomas Kral
> Sent: Wednesday, 3 October 2018 1:48 AM
> To: Oberon at lists.inf.ethz.ch
> Subject: [Oberon] FPGA - Oberon7 - Type Cast
> 
> Hi,
> 
> I am testing `Read/Write Bytes()' procedures. I wish to read in a
> structure, that I can write back to a file again.
> 
> TYPE
>   R1 = RECORD a, b, c, d: CHAR END;
>   Buf = ARRAY max OF BYTE;
> VAR r1: R1;
> ...
>   ReadBytes(R, SYSTEM.VAL(Buf, r1), SYSTEM.SIZE(R1));
> 
> How can I typecast r1:R1 to Buf?
> 

Buf needs to be the same size as R1. Try the following:

TYPE
  Rec = RECORD a, b, c, d: CHAR END;
  RecBuf = ARRAY SYSTEM.SIZE(Rec) OF BYTE;
...
VAR rec: Rec;
    R: Files.Rider;
...
  Files.ReadBytes(r, SYSTEM.VAL(RecBuf, rec), LEN(RecBuf));

Regards,
Chris Burrows

CFB Software
http://www.astrobe.com/RISC5




More information about the Oberon mailing list