Link to home
Start Free TrialLog in
Avatar of AccordJ35
AccordJ35

asked on

Remove extra line in Text file using Autoit

I using the Autoit program to create my own program. I have been trying to figure out how how to remove a blank line in a text file. We have a program that outputs a text file. The problem is that it adds a blank line at the end of the file.

when I use the command _FileCountLines
it comes back and says there is 10 lines but when you open the text file you can click on the 11th line. The problem with that is that the company we are uploading this file to says we have to remove that blank line.
Avatar of dustock
dustock
Flag of United States of America image

What command are you using the write the lines?
Avatar of AccordJ35
AccordJ35

ASKER

The program uses a sql store procedure to create the .txt file. It just has a blank line at the end. Trying to figure out how to get rid of it.
It's been awhile since I last used AutoIT, but I think you should try StringReplace to remove the last line.

Something like:

yourstring = StringReplace(yourstring, @CRLF, '', -1)

If I remember correctly the -1 will remove the last occurrence of what ver you are trying to replace.  You may also want to search for just @CR or @LF if @CRLF doesn't work.  Also you may have to mix functions like StringReplace(StringRight(yourstring, 1), @CRLF, '') but I can't be sure since I am not near a PC to try.
ASKER CERTIFIED SOLUTION
Avatar of matrixnz
matrixnz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Function 2 worked for me. :-)