On 19/12/2023 12:36, James Richters via fpc-pascal wrote:
I did notice that I cannot have a file of Ansistringsā¦ Myfile : File of Ansistring; Causes a compiler error: Error: Typed files cannot contain reference-counted types.
A "file of" must have a fixed size type. "file of word", reads 2 byte (1 word) for each entry. Shortstring always occupies 256 bytes String[20] always 21 bytesEven if such a string just contains "abc" it will have the full amount of bytes used in the file.
For ansistring that is not possible. It can have millions of chars, and you can't have each entry use 2^32 bytes. If they don't have linebreaks, then you can just readln/writeln to/from a text file.
Mind: You can't replace just one string in the file by a different value, if the new string-value has a different length => then the entire rest of the file needs to be moved.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal