Pascal Viandier wrote:
I have a question regarding arrays of characters passed as parameters to procedures.
If I declare:
Type Str40 = Array[1..40] Of Char; Str80 = Array[1..80] Of Char;
Var S40 : Str40; S80 : Str80; S : String(50);
Procedure DoArray(SParam : STRING); ..
Procedure DoArrayVar(VAR SParam : STRING); ...
I can call DoArray with S40, S80 and S as parameter with no problem, but I cannot call DoArrayVar with S40 or S80 (It gives the error: type mismatch in argument 1 of 'DoArrayVar' at compilation time). I don't understand why it works when the parameter is not VAR and why it does not work when it is VAR.
Types of `var' parameters have to match exactly `String' is not the same as `array of char'. Value parameters only need to be assignment compatible.
To have DoArrayVar work, I had to remove the parameter type, and assign the parameter S to a local variable pointer to a Str80. It works for S40 and S80 but not anymore for S.
Untyped parameters (if that's what you mean) are a low-level beast better left alone unless strictly needed.
Is there a way to declare a VAR parameter that would accept S40, S80 and S?
No, they're distinct types. To accept S40 and S80, you could use a conformant array, but S is still different. I might help explaining what you actually want to achieve and why you think you need to break typing rules. Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8