Reading Files and Carriage Returns

I have an action which reads through a text file and puts the contents into a variable, which I then place in the body of an email and send.

My problem is that if I have a text file which looks like this:


Hello, this is a line

this is a new line

this is the last line


It arrives in the email as:


Hello, this is a linethis is a new linethis is the last line


which obviously isn’t what I want.

I am using the following code to get the text:

Open fileName For Input As #1

While Not Eof(1)

	Line Input #1,a$

	BodyText = BodyText +a$

Wend 

I got the above code from this site when someone had a similar problem.

How can I get it to return the text as I see it in the file?

I have tried Input instead of Line Input as suggested in the help file, but this has made no difference

Thanks

Subject: Reading Files and Carriage Returns

Hello David,

Please try the following code…

While Not Eof(1)

Line Input #1,a$

BodyText = BodyText +a$

BodyText = BodyText+Chr(13)

Wend

Hope this helps…

Best Regards,

Munish Kaushik

Subject: Reading Files and Carriage Returns

To achieve this task for web, I put the following formula in the view:

@ReplaceSubstring(COLUMN_NAME; @Char(13); “
”)

(replace COLUMN_NAME with appropriate value)

I assume something similar should be done in lscript as well.

Subject: RE: Reading Files and Carriage Returns

Thanks Vahe,

I have tried replacing Chr(13) for Chr(10) and vice versa with no effect.

Subject: Reading Files and Carriage Returns

Line Input only returns the data on the line, it doesn’t return the line feed or carriage return characters. All you have to do is add it again along with the data line. So update the string collector to:

BodyText = BodyText + a$ + chr(10)

that’s using a line feed… you may also be able to use a carriage return, and windows usually uses a carriage return + line feed pair, but I think Notes is pretty lenient.

Subject: RE: Reading Files and Carriage Returns

Bruce, genius!

Thanks

EDIT Minush, you replied before I refreshed. Genius to you to :slight_smile: