Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-05

Switch from string to ansi/wide

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Eduardo Morras

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.

Reply by email

Luca Olivetti
to Eduardo Morras

En/na Eduardo Morras ha escrit:

Can you point me on how to get a text (ascii, not utf8, utf16 or similar) file?

Use "text" or "textfile" instead of "file of string". BTW, you can use "writeln" if you want to add a line terminator.

Bye

Luca

Reply by email