[fpc-pascal] Re: ReadStr/WriteStr vs Val/Str
Paul Nicholls
paulfnicholls at gmail.com
Tue Oct 19 02:39:58 CEST 2010
"Richard Ward" <roward at mac.com> wrote in message
news:6707D87E-2EA6-4469-97A5-CF55D1A04AA7 at mac.com...
As a user of the old Macintosh Pascal (later THINK Pascal), both ReadStr
and WriteStr functions were included and I used them quite a bit. The
names were different but the FPC implementation is basically the same as far
as I can tell.
Besides backward compatibility, portability issues and personal preference,
is there any functionality Val and Str may have that ReadStr and WriteStr
don't? I can't see any, but wanted to make sure there there were no subtle
technical issue(s) I might need to consider.
Thank you for implementing these functions.
_______________________________________________
fpc-pascal maillist -
fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Hi Richard,
I don't know about the Macintosh Pascal ReadStr and WriteStr routines
(never used them), but a 'possible' gotcha is that I think the Str()
function will append a space at the beginning of a value to leave room for
the sign if negative...
if you don't want that then you can use the Format routine instead:
Integer to string:
s := Format('%d',[<some integer number>]);
float to string:
s := Format('%.4f',[<some floating point number>]); //formats a floating
point number to 4 decimal places (just change, or remove if you want
scientific notation I think)
I hope this helps :)
cheers,
Paul
More information about the fpc-pascal
mailing list