home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / modula2 / tutorial / programs / arrays.mod < prev    next >
Text File  |  1993-03-14  |  792b  |  26 lines

  1.                                          (* Chapter 6 - Program 1 *)
  2. MODULE Arrays;
  3.  
  4. FROM InOut IMPORT WriteString, WriteCard, WriteLn;
  5.  
  6. VAR Index       : CARDINAL;
  7.     Automobiles : ARRAY [1..12] OF CARDINAL;
  8.  
  9. BEGIN   (* main program *)
  10.    FOR Index := 1 TO 12 DO
  11.       Automobiles[Index] := Index + 10;
  12.    END;
  13.    Automobiles[7] := 54;  (* example, change one value of array *)
  14.    WriteString("This is the first program with an array.");
  15.    WriteLn;
  16.    WriteLn;                       (* end of data initialization *)
  17.  
  18.    FOR Index := 1 TO 12 DO              (* display the data now *)
  19.       WriteString("Automobile number");
  20.       WriteCard(Index,3);
  21.       WriteString(" has the value of");
  22.       WriteCard(Automobiles[Index],3);
  23.       WriteLn;
  24.    END;
  25. END Arrays.
  26.