Switch from string to ansi/wide

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Switch from string to ansi/wide

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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Switch from string to ansi/wide

Luca Olivetti-2
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal