Oberon Community Platform Forum
October 17, 2017, 07:20:56 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Length of an open/dynamic array  (Read 3519 times)
darek
Jr. Member
**
Posts: 57


« 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 
Logged
cfbsoftware
Full Member
***
Posts: 106


WWW
« Reply #1 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.
Logged

Chris Burrows
Astrobe v6.0 (Jun 2016): Oberon for ARM Cortex-M4 and Cortex-M3 Microcontrollers
http://www.astrobe.com
darek
Jr. Member
**
Posts: 57


« Reply #2 on: March 21, 2011, 12:24:49 PM »

Hi,
I am using  WinAos version 3978  on WinXP/Win7.
Regards,
  Darek


Logged
leledumbo
Jr. Member
**
Posts: 96



WWW
« Reply #3 on: March 21, 2011, 05:17:46 PM »

Confirmed, doesn't work in WinAOS.
Logged
fnecati
Jr. Member
**
Posts: 60


« Reply #4 on: March 22, 2011, 01:15:40 PM »

what about this;

 L := LEN(A, 0);


Logged
darek
Jr. Member
**
Posts: 57


« Reply #5 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
Logged
leledumbo
Jr. Member
**
Posts: 96



WWW
« Reply #6 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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!