Help to create and dump a text file needed

merrilmerril Member Posts: 38
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<br>'); 
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

Answers

  • krikikriki Member, Moderator Posts: 9,110
    BTW : it is possible that the error is created by the
    OutStream.WRITETEXT();
    
    maybe you should put this (didn't try it):
    OutStream.WRITETEXT('');
    

    But the outstream is not really necessary.
    Try this:
    OutFile.TEXTMODE(TRUE);
    OutFile.WRITEMODE(TRUE);
    OutFile.CREATE('c:\msr.txt');
    
    OutFile.WRITE('To: someone@somewhere.com');
    OutFile.WRITE('');
    OutFile.WRITE('From: "Navison NAS" <superawesomeperson@somewhere.com>');
    OutFile.WRITE('');
    OutFile.WRITE('Subject: Whatever');
    ...
    OutFile.CLOSE();
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • XypherXypher Member Posts: 297
    OutStream.WRITETEXT();
    
    This statement should work fine,


    How do you have your variables declared?

    The code you have supplied works fine for me, are you sure you have declared 'OutStream' as datatype OutStream? (Also you might want to use less ambiguous variable names. How about 'oStream' ?)
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I thought it isn't possible to name an OutStream variable "OutStream". :?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • XypherXypher Member Posts: 297
    I thought it isn't possible to name an OutStream variable "OutStream". :?

    Yeah I was thinking somewhat the same, until I tried it out 8-[
  • merrilmerril Member Posts: 38
    I have declared Outfile as File. If I declare Outstream as type outstream, I get an error: "The variable outstream is defined more than once"
  • krikikriki Member, Moderator Posts: 9,110
    merril wrote:
    I have declared Outfile as File. If I declare Outstream as type outstream, I get an error: "The variable outstream is defined more than once"
    Because you can't name a variable "Outstream". It is a keyword, so you can't use it as a variable (like "einsTeIn.NET" suggested).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.