On Wed, 11 Jul 2001, Prof. A Olowofoyeku (The African Chief) wrote:
On 11 Jul 2001, at 11:21, Adam Naumowicz wrote:
[...]
begin getmem(a,3*sizeof(NameStr));
This is your problem. Use 'New' instead of 'getmem' - i.e., New (a, 3 * sizeof (NameStr)); or New (a, sizeof (shortarray)); or better still, just "New (a);"
Thanks for your answers. But I want my sources to stay BP/Delphi compatible...
Both BP and Delphi understand "New (a);".
I believe that NEW with size parameter is not accepted.
I still don't know what is wrong with the getmem call. Maybe I should try this example with a newer compiler as Maurice says it works fine for him.
I have the latest snapshot of the compiler, and getmem does not work in this example.
It worked fine for me with BP, Delphi and FPC, but all those handle strings in somewhat different manner than GPC. Why is new better than getmem in this example ?
It is because of the format of GPC strings. Read: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/gpc_37.html#SEC37
Yes I read this. But the NameStr (String[8]) I use is of a fixed size and I want to getmem the array, not the strings ... Then I assign a value of a variable of that type to an element of the array that should (?) be a compact sequence of its elements. Regards, Adam Naumowicz
-------------------------------------- WWW: http://math.uwb.edu.pl/~adamn/ --------------------------------------