[fpc-pascal]Strings vs. Ansistrings

James_Wilson at i2.com James_Wilson at i2.com
Wed Sep 20 16:29:20 CEST 2000

> There are different ways of storing an ansistring, like first save the
> them the data (See previous mail) or save it as a Pchar. May I ask what
> of program needs to read an array of strings from a file? If you want to
> read a text-file you should use TStringList (FCL?) or something else, but
> you can not load it directly.

I don't use TStringList because it's unique to FPC. I try to make all my
source code 'portable' to other compilers (primarily TMT, but maybe I'll
start playing around with the new VP as well). This way, if I have a
problem I can verify it on another platform, but if I use something
proprietary to one or the other it becomes a nightmare to trace. Now, it's
impossible to not have some differences so I do use a few $ifdefs, but
that's about it.

The program I'm (re)writting is a console mode text file viewer. I've
written a number of file viewers in my life time; some proprietary and for
a specific need, some generic for virtually any type of file. One of the
challenges I decided to undertake was to completely rewrite, from the
ground up, a program that looked and acted like one of my generic file
viewers, but with expanded capabilities (multi-megabyte files, unlimited
line lengths, long file names, etc). I have always used ^string for the
data structure and just naturally assumed that this would be the best
method to do it again. Is there a better way to do it?

BTW; do you know of another way to send text to the screen (for go32
targets) then write and writeln? One of the functions of the file viewer is
to be able to read/display binary files. When you try to use write to
display data from a binary file (which was read from the file using
blockread) everything after a cr/lf pair is ignored. Would assigncrt help
at all?



More information about the fpc-pascal mailing list