Oberon Community Platform Forum

Development => WinAOS => Topic started by: darek on March 20, 2011, 06:42:01 PM



Title: Length of an open/dynamic array
Post by: darek on March 20, 2011, 06:42:01 PM
Hi All,
  I came across an error when I compiled this very simple program:

MODULE TestLen;
 IMPORT Log:= KernelLog;
 
 
 VAR A : ARRAY  [ * ] OF INTEGER;
        L : LONGINT;
       
       
 PROCEDURE Run*;
   BEGIN
 END Run;
 
BEGIN
  NEW(A,1000);
  L := LEN(A); (* <--- compilation error *)
  Log.String("Length of the array is="); Log.Int(L,3);Log.Ln();
END TestLen.

TestLen.Run~

SystemTools.Free TestLen ~


Compilation error: 'Incompatible assignment' in line L:= LEN(A);

My question here  is: Is this a bug ? If not, how I can compute a length of a dynamic array?

Regards,
  Darek 


Title: Re: Length of an open/dynamic array
Post by: cfbsoftware on March 21, 2011, 12:40:18 AM
Which variant of Oberon are you using? I expected to see the declaration of a dynamic array as either:

  ARRAY * OF INTEGER

or

  POINTER TO ARRAY OF INTEGER

The LEN function can be used with either and they compile and run OK on the Oberon compiler with Active & X Extensions which is used in the ETH Windows PlugIn version of Oberon.


Title: Re: Length of an open/dynamic array
Post by: darek on March 21, 2011, 12:24:49 PM
Hi,
I am using  WinAos version 3978  on WinXP/Win7.
Regards,
  Darek




Title: Re: Length of an open/dynamic array
Post by: leledumbo on March 21, 2011, 05:17:46 PM
Confirmed, doesn't work in WinAOS.


Title: Re: Length of an open/dynamic array
Post by: fnecati on March 22, 2011, 01:15:40 PM
what about this;

 L := LEN(A, 0);




Title: Re: Length of an open/dynamic array
Post by: darek on March 22, 2011, 02:11:59 PM
Thanks! It works. BTW, I will have to modify  the A2 wrapper for the FFTW (I tried to compile it using  WinAos v.3978  and I got the same compilation error). I did not have such  problems  with some  older versions of the  WinAos system.

Regards,
   Darek


Title: Re: Length of an open/dynamic array
Post by: leledumbo on March 22, 2011, 06:53:39 PM
Quote
what about this;

 L := LEN(A, 0);
Weird... what's the semantic of LEN? ARRAY  [ * ] OF INTEGER is a single-dimensional dynamic array right?