[Oberon] Runtime array in Oberon-07

Deadmarshal adeadmarshal at gmail.com
Tue Oct 18 16:37:03 CEST 2022


Hi,

I've read that in Oberon-07 we can't have a pointer to an array, and I was
wondering how we can set the size of an array at runtime. I want to do
something similar to the below code snippet:

MODULE Test;
(*Oberon-2 compatible*)
IMPORT In,Out;

VAR
  PA:POINTER TO ARRAY OF INTEGER;
  N,Input,I:INTEGER;

BEGIN
  Out.String("Size of array: "); Out.Ln;
  In.Int(N);
  NEW(PA,N);
  Out.String("Enter Items: "); Out.Ln;
  FOR I := 0 TO N-1 DO
    In.Int(Input);
    PA[I] := Input;
  END;
  FOR I := 0 TO N-1 DO
    Out.Int(PA[I],0);
    Out.Char(' ');
  END;
  Out.Ln;
END Test.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20221018/b019a0a0/attachment.html>


More information about the Oberon mailing list