| 1 |
(* Copyright (C) 2009 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of GNU Modula-2. |
| 3 |
|
| 4 |
GNU Modula-2 is free software; you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free |
| 6 |
Software Foundation; either version 2, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with gm2; see the file COPYING. If not, write to the Free Software |
| 16 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) |
| 17 |
|
| 18 |
MODULE unbounded5 ; |
| 19 |
|
| 20 |
FROM libc IMPORT exit, printf ; |
| 21 |
|
| 22 |
PROCEDURE assign (VAR a: arrayType) ; |
| 23 |
BEGIN |
| 24 |
a := arrayType{1, 2, 3, 4, 5, 6, 7, 8, 9} |
| 25 |
END assign ; |
| 26 |
|
| 27 |
TYPE |
| 28 |
arrayType = ARRAY [1..9] OF CARDINAL ; |
| 29 |
|
| 30 |
VAR |
| 31 |
a: arrayType ; |
| 32 |
BEGIN |
| 33 |
assign(a) ; |
| 34 |
IF (a[1]#1) AND (a[2]#2) AND (a[3]#3) |
| 35 |
THEN |
| 36 |
printf("assignment failed\n") ; |
| 37 |
exit(1) |
| 38 |
END ; |
| 39 |
IF (a[4]#4) AND (a[5]#5) AND (a[6]#6) |
| 40 |
THEN |
| 41 |
printf("assignment failed\n") ; |
| 42 |
exit(2) |
| 43 |
END ; |
| 44 |
IF (a[7]#7) AND (a[8]#8) AND (a[9]#9) |
| 45 |
THEN |
| 46 |
printf("assignment failed\n") ; |
| 47 |
exit(3) |
| 48 |
END |
| 49 |
END unbounded5. |