Skip to main content
Inspiring
February 23, 2012
Answered

How to read in a text file with linefeeds

  • February 23, 2012
  • 1 reply
  • 878 views

Hi

I'm trying to read a text file into a textFrame.  It reads in but is not including linefeeds so it's just one big long line of text.  I'm using the following code to read the file.  I attempted to insert a \n character after each readln() but that didn't help.  I also tried creating a variable that the readln() was stuffed into before setting the textFrame.contents to the variable, but that didn't work either. I'm stumped. Any help would be appreciated, thanks.

while (! notesDoc.eof) {

    noteTextRef.contents += notesDoc.readln();
}

Doug

This topic has been closed for replies.
Correct answer Muppet Mark

Just use fileObect.read() instead of fileObect.readln() // read line Also try using \r instead of \n

1 reply

Muppet MarkCorrect answer
Inspiring
February 23, 2012

Just use fileObect.read() instead of fileObect.readln() // read line Also try using \r instead of \n

Inspiring
February 24, 2012

Thanks Muppet Mark

I forgot to mention that I had also tried just fileObject.read() as well and it didn't work either.  It was the same run on sentence result I got with the script I showed above.  Seems odd.  However, the \r instead of \n did the trick.  I had some recollection of another line feed character but couldn't remember what it was, so thanks for that.

Doug