Deleting a blank last line of exported text file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Deleting a blank last line of exported text file

Post by magice » Tue Jan 21, 2014 2:48 am

I am working on a script that reads a text file, modifies it for purposes of making it importable to another application and saves it. That is all simple enough. My problem, however, is that there always seems to be an empty line at the end of the file. I have tried everything I can think of, and have determined that it must be part of the way that LiveCode writes to a file. Is there any way to eliminate that last empty line?

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Deleting a blank last line of exported text file

Post by Dixie » Tue Jan 21, 2014 2:59 am

It might be something as simple as a 'trailing' carriage return...
try putting the text into a variable, called say 'theText' and delete the last character of it...

Code: Select all

delete the last char of theText

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Deleting a blank last line of exported text file

Post by magice » Tue Jan 21, 2014 3:38 am

Dixie, you are a genius. That was actually the first thing i thought of, but I discounted the thought because of the possibility of the file not having the CR as the last char. I then focused on the last line and evaluating if it were empty. Your way works for me in an if statement.

Code: Select all

if the last char of tExport is cr then delete the last char of tExport
Thank you for making me rethink my over thinking.

Post Reply