Hello ,
It gives us 264 as size and capacity is 0. we have gpc-20010924.Is it corrected in a newer version?
Thanks and Regards, Anuradha.
Prof Abimbola Olowofoyeku wrote:
On 18 Mar 2002 at 13:05, Anuradha wrote:
Hello ,
The following program works in BP but prints blank in GPC. Can you tell us why.
program sts; type mytype = (a,b,c,d); myrec =record st:string; end; var arr : array[mytype] of myrec; begin arr[d].st :='anu'; writeln(arr[d].st); end.
It doesn't print blank here. It prints 'anu'.
FWIW, there may be a problem with your record. What is the size/capacity of the string 'st' ?
Best regards, The Chief
Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~African_Chief email: African_Chief@bigfoot.com
On 18 Mar 2002 at 13:42, Anuradha wrote:
Hello ,
It gives us 264 as size and capacity is 0.
Hmmm ... the capacity (AFAIK) should not be 0. I thought GPC defaults to a capacity of 255 when no capacity is supplied?
we have gpc-20010924.Is it corrected in a newer version?
Apparently. But I think you need to correct it in your code. It is not a good idea to declare a string field in a record without specifying the size/capacity of the string. Basically, it means that you are leaving it to someone else (e.g., the compiler) to determine the size of your record - and it may decide on a size that is different from the one you would like (as seems to have beem done here).
Something like this would be a better solution, should work with all compilers, and should solve your specific problem;
type myrec = record st : string [128]; end;
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~African_Chief email: African_Chief@bigfoot.com
Prof Abimbola Olowofoyeku wrote:
On 18 Mar 2002 at 13:42, Anuradha wrote:
Hello ,
It gives us 264 as size and capacity is 0.
Hmmm ... the capacity (AFAIK) should not be 0. I thought GPC defaults to a capacity of 255 when no capacity is supplied?
It does. The 264 is the result of `SizeOf' because the Capacity and Length fields and the space for a #0 terminator occupy additional space (4, 4 and 1 bytes on a 32 bit machine).
Frank
Anuradha wrote:
It gives us 264 as size and capacity is 0. we have gpc-20010924.Is it corrected in a newer version?
Indeed, that's one of the bugs I fixed recently:
20011014: files and discriminants of schemata inside arrays whose index is an enumeration type are not initialized correctly (theo1[ab].pas)
Frank