[fpc-pascal] Switch from string to ansi/wide
Eduardo Morras
nec556 at retena.com
Mon May 5 16:46:37 CEST 2008
Hello:
I writing an app that works with text. I use strings and define the
output file as file of string. All works fine but it's limited to 255
characters. Now i changed to ansistring (every from "string" to
"ansistring") and compiles without any problem, but when i open the
text file i get garbage. I tried widestring too but i get the same.
I have read the documentation and did't find anything about it.
Can you point me on how to get a text (ascii, not utf8, utf16 or similar) file?
TIA
Here is source code similar to mine:
const
max = 3;
maxN = max*2;
var
P,Q : array [1..max] of string;
W : array [1..maxN,1..maxN] of string;
V : array [1..maxN] of string;
i,j,k,l,m : integer;
auxstr : string;
fout : file of string;
auxansi : string;
BEGIN
for i := 1 to max do begin
str(i,auxstr);
P[i] := 'P' + auxstr;
Q[i] := 'Q' + auxstr;
end;
for i := 1 to max do
for j := 1 to max do
W[i,j+i] := '( ' + P[i] + ' IMPLIES (' + Q[j] + ' AND ' + P[i] + '))';
for i := 1 to max do
for j := 1 to max do
V[i+j] := W[i,j];
assign(fout,'fout.txt');
rewrite(fout);
auxansi := chr(10)+chr(13);
for i := 1 to max do begin
write(fout,V[i]);
write(fout,auxansi);
end;
close(fout);
END.
More information about the fpc-pascal
mailing list