[Oberon] open array usage
bob at web-options.com
Sat Jul 10 18:25:48 MEST 2010
You have to declare a variable whose type is an array, and populate the elements individually. This is for Blackbox:
Denis = ARRAY 3 OF REAL;
PROCEDURE Sum(reals:ARRAY OF REAL) : REAL ;
VAR i : INTEGER;
x := 0.0;
FOR i := 0 TO LEN( reals )-1 DO
x := x + reals[i];
d := 1.1;
d := 2.2;
d := 4.4;
Out.Real( Sum( d ),7 );
Pascal's WRITE is a method of writing text to the screen. Oberon has a more interesting and general solution, but you can use procedures in the Out module to write text to the log.
> -----Original Message-----
> From: oberon-bounces at lists.inf.ethz.ch [mailto:oberon-
> bounces at lists.inf.ethz.ch] On Behalf Of spir
> Sent: 10 July 2010 16:40
> To: Oberon
> Subject: [Oberon] open array usage
> Sorry for coming back to the topic, but I still cannot figure out how
> open arrays are supposed to be used in Oberon, without any form of
> literal notation.
> PROCEDURE Sum(reals:ARRAY OF REAL) : REAL ;
> PROCEDURE Max(reals:ARRAY OF REAL) : REAL ;
> How can one pass [1,2,3] or [a,b,c] to one of those procedures?
> TYPE STRING = POINTER TO ARRAY OF CHAR ;
> PROCEDURE concat(ARRAY OF STRING) : STRING ;
> PROCEDURE write(ARRAY OF STRING) ;
> How can one concat or write ["Hello, ", name, ", how do you do?"]?
> Is there an answer?
> If not, how to achieve that, or anyhow work around the issue?
> Side-question: how to define an Oberon equivalent to Pascal's write?
> vit esse estrany ☣
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
More information about the Oberon