WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Formatting UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Remove Blank Lines

 Keywords: delete remove blank line lines @CR @LF @CRLF  

; Remove last line (empty or not) from a textfile.
intBytesWritten = FilePut (strFilename, ItemRemove (-1, ItemRemove (-1, FileGet (strFilename), @LF), @CR))


; Remove leading empty lines (@CRLF's) from a textfile.
strText = FileGet (strFilename)
intPos = 1
While intPos == StrIndex (strText, @CRLF, intPos, @FWDSCAN)
   intPos = intPos + 2
EndWhile
intBytesWritten = FilePut (strFilename, StrSub (strText, intPos, -1))


; Remove trailing empty lines (@CRLF's) from a textfile.
strText = FileGet (strFilename)
intPos = StrLen (strText)
While intPos == 1 + StrIndex (strText, @CRLF, intPos, @BACKSCAN)
   intPos = intPos - 2
EndWhile
intBytesWritten = FilePut (strFilename, StrSub (strText, 1, intPos))


; Remove leading empty lines (@CRLF's) from a textfile.
intBytesWritten = FilePut (strFilename, StrReplace (ItemRemove (-1, StrTrim (StrReplace (FileGet (strFilename), @CRLF, @TAB) : @LF), @LF), @TAB, @CRLF))


; Remove trailing empty lines (@CRLF's) from a textfile.
intBytesWritten = FilePut (strFilename, StrReplace (ItemRemove (1, StrTrim (@LF : StrReplace (FileGet (strFilename), @CRLF, @TAB)), @LF), @TAB, @CRLF))


; Remove leading and trailing empty lines (@CRLF's) from a textfile.
intBytesWritten = FilePut (strFilename, StrReplace (StrTrim (StrReplace (FileGet (strFilename), @CRLF, @TAB)), @TAB, @CRLF))

Article ID:   W18370
Filename:   Remove Blank Lines.txt
File Created: 2010:12:20:09:53:12
Last Updated: 2010:12:20:09:53:12