[Oberon] Printing an array

Martin Bishop martinbishop at bellsouth.net
Tue Oct 7 22:05:59 MEST 2008


This is probably a silly question, but how can I create a function to
print an array?

Obviously I'd use a FOR loop over the elements, but when I try to use
something like:

VAR a: ARRAY 10 OF INTEGER;

PROCEDURE PrintArray(VAR a: ARRAY OF INTEGER);
   VAR i: INTEGER;
BEGIN
   FOR i := 0 TO LEN(a) - 1 DO
      Out.Int(a[i], 0);
      Out.String(" ");
   END;
END PrintArray;

I get the error:

/home/martin/code/Oberon/Bogo.Mod:32:30: Expression not compatible with
variable type `INTEGER'

Which I assume means LEN can't get the length of a?


More information about the Oberon mailing list