| 1 |
(* Copyright (C) 2005 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 testcse48 ; |
| 19 |
|
| 20 |
FROM StrIO IMPORT WriteLn ; |
| 21 |
FROM SYSTEM IMPORT ADR ; |
| 22 |
|
| 23 |
TYPE |
| 24 |
string = ARRAY [0..10] OF CHAR ; |
| 25 |
STRING = RECORD |
| 26 |
c: POINTER TO string ; |
| 27 |
h: CARDINAL ; |
| 28 |
END ; |
| 29 |
|
| 30 |
PROCEDURE StrLen (a: STRING) : CARDINAL ; |
| 31 |
VAR |
| 32 |
b: string ; |
| 33 |
BEGIN |
| 34 |
b := a.c^ ; |
| 35 |
a.c := ADR(b) ; |
| 36 |
a.c^[4] := 'a' ; |
| 37 |
RETURN 5 |
| 38 |
END StrLen ; |
| 39 |
|
| 40 |
VAR |
| 41 |
l: CARDINAL ; |
| 42 |
t: STRING ; |
| 43 |
b: string ; |
| 44 |
BEGIN |
| 45 |
b := 'hello' ; |
| 46 |
t.c := ADR(b) ; |
| 47 |
t.h := 5 ; |
| 48 |
IF StrLen(t)=5 |
| 49 |
THEN |
| 50 |
WriteLn |
| 51 |
END |
| 52 |
END testcse48. |