CBFalconer wrote:
However write knows that you specified the string to be an array of 256 chars, so it outputs 256 chars (unless told to truncate by a field specification). Those chars have somehow become blanks in your system, and that part is not standard.
It is standard -- Extended Pascal, to be precise.
The assignment to test evidently has been arranged to append blanks, and it also appears as if the write operation has been arranged to elide trailing blanks, at least when the line is ended by the writeln operation.
It doesn't. Perhaps the spaces were just trimmed when copied into the mail.
BTW, the OP might want to use `--extended-pascal' or `--borland-pascal', unless your class has a strict requirement for the original standard language. (I'd recommend the former, but if you're somewhat familiar with Turbo (= Borland) Pascal as you indicated, you might prefer this. Both have a built-in string type (BP: `String[n]', EP: `String (n)').
a.d. jensen wrote:
On Mar 13, 2005, at 7:57 AM, loop lopy wrote:
How does writeln knows where to stop printing the string?
If it's a Pascal string, the first byte shows the length of the string. In other words, this assignment:
myS:= 'Test';
puts the value of 4 in the first byte.
The first byte applies only to BP's short strings. GPC's implements EP strings which store the length differently. From a user's point of view, it doesn't matter, except that they're not limited to 255 chars (unless you do dirty tricks such as accessing `s[0]').
In both cases, one can simply access `Length', and `Write' etc. obey the length automatically.
Frank