How do I create a text file and dump data to it.

I’m trying to create a text file with data in. I looked in the help and found the following code:

OutFile.TEXTMODE(TRUE);
OutFile.WRITEMODE(TRUE);

OutFile.CREATE(‘c:\msr.txt’);
gbolFileCreated := TRUE;

OutFile.CREATEOUTSTREAM(OutStream);
OutStream.WRITETEXT(‘To: someone@somewhere.com’);
OutStream.WRITETEXT();
OutStream.WRITETEXT(‘From: “Navison NAS” <superawesomeperson@somewhere.com>’);
OutStream.WRITETEXT();
OutStream.WRITETEXT(‘Subject: Whatever’);
OutStream.WRITETEXT();
OutStream.WRITETEXT(‘MIME-Version: 1.0’);
OutStream.WRITETEXT();
OutStream.WRITETEXT(‘Content-Type: text/html;’);
OutStream.WRITETEXT();
OutStream.WRITETEXT(’ charset=“iso-8859-1”’);
OutStream.WRITETEXT();
OutStream.WRITETEXT('Content-Transfer-Encoding: quoted-printable ');
OutStream.WRITETEXT();
OutStream.WRITETEXT(‘BODY OF EMAIL HERE
’);
OutStream.WRITETEXT(‘Additional Lines below!!!’);
OutFile.CLOSE();

I have declared the Outfile as type File. But when I compile this code, I get an error “type of conversion is not possible because 1 of the operators contains an invalid type . Outstream. := Type”. What is the problem here? Is this the best way to create a text file with data in?

Thanks in advance.

Regards,

Merril

Hi Merril,

You must declare OutStream as a variable too but of some reason you can’t use the name OutStream. Try OutStr instead. Remember to change your code from OutStream to OutStr.

Instead a outstrem you just can use OutFile.WRITE. Remember to the line OutFile.TEXTMODE := TRUE;

Best Regards

Bjarne