More Modula-2 Questions
24-Oct-86 20:21:32
Sb: #36994-More Modula-2 Questions
Fm: Richard Bielak 75716,352
To: Lon Leader 72355,1754
This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.
Hi! I'm familiar with the book "Seafearers guide to M2". There
are few mistakes in it. As there is no formal standard for M2
usually Wirth's book "Programming in M2" is used as the final
word.
In Modula-2 arrays have to be declared of exactly the same type
to be assigment compatible. So for example this code is incorrect:
VAR a : ARRAY [1..10] OF CHAR; b : ARRAY [1..10] OF CHAR;
…
a := b; (* This will not compile *)
….
What you should do is make up another type. So you can do this:
TYPE
string = ARRAY [1..10] OF CHAR;
VAR a,b : string;
….
a := b; (* This is OK *)
….
Also, string literals are considered of type "ARRAY [0..size] OF
CHAR", so if you want to say "a := 'abcdef';', declare "a" as an
array of characters whose range starts at "0". You should be
able to perform the assigment, even if the length of "a" is larger
than the leangth of the literal.
BTW, in "Ami Project" I have an AMiga/M2 column. You may find it
helpful (just a little plug)…..take care….Richie