Re: Remove Blank Line and/or Additional CRLF From End of File
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/14/04
- Next message: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Previous message: Leslie Houk: "Re: Password Input Box Revisited"
- In reply to: O. Johnson: "Remove Blank Line and/or Additional CRLF From End of File"
- Next in thread: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Reply: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 14 Oct 2004 17:03:13 +0200
O. Johnson wrote:
> Wrote a VBscript to extract the first 5698 characters of a 30,000+ character
> per line Lawson extract file, so it can be imported into our check writing
> software. The issue is I get a blank line and/or additional CRLF at the end
> of the file which the check writing software views as a blank record and
> errors on the import. What can I add to my script(entire script below) to
> remove this additional blank line and/or CRLF so it doesn't have to manually
> be removed as they are doing today?
Hi
This should do it:
'--------------------8<----------------------
Option Explicit
Const OpenAsASCII = 0
Const OverwriteIfExist = -1
Const FailIfNotExist = 0
Const ForReading = 1
Dim fso, strFiles, strSourceFile, strOutputFile, strOutputLine
Dim tsout, tsin, strLine
strSourceFile = "C:\pmtout\pmtout.txt"
strOutputFile = "C:\pmtout\pmtout.pmt"
set fso = CreateObject("Scripting.FileSystemObject")
' 'Create new file (will delete any old file)
set tsout = fso.createTextFile(strOutputFile, OverwriteIfExist, OpenAsASCII)
' open input file
set tsin = fso.openTextFile(strSourceFile, ForReading, _
FailIfNotExist, OpenAsASCII)
Do Until tsin.atEndOfStream
strLine = tsin.ReadLine 'Read line into memory
'Reset to first 5698 COLUMNS from left and write to output file
tsout.Write Left(strLine,5698)
' To avoid blank line at end
If not tsin.atEndOfStream Then
tsout.WriteLine
End If
Loop
tsout.close
tsin.close
msgbox "DONE!"
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Previous message: Leslie Houk: "Re: Password Input Box Revisited"
- In reply to: O. Johnson: "Remove Blank Line and/or Additional CRLF From End of File"
- Next in thread: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Reply: O. Johnson: "Re: Remove Blank Line and/or Additional CRLF From End of File"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|