Jump to content
Sign in to follow this  
inov8iv

[SOLVED] Removing Extra Line Break

Recommended Posts

inov8iv

I have a program I wrote and am having an issue with it writing an extra Carriage Return at the end of the document. For processing I cannot have this extra CR at the end. It puts the CR after however many rows of 9's it needs. Any help is greatly appreciated.

;--------CODE SNIPPET--------

FileWriteLine($ACHFile, $FLine1)

FileWriteLine($ACHFile, $FLine2)

If StringRight($TLines4, 1) = 1 Then $FLCount = 9

If StringRight($TLines4, 1) = 2 Then $FLCount = 8

If StringRight($TLines4, 1) = 3 Then $FLCount = 7

If StringRight($TLines4, 1) = 4 Then $FLCount = 6

If StringRight($TLines4, 1) = 5 Then $FLCount = 5

If StringRight($TLines4, 1) = 6 Then $FLCount = 4

If StringRight($TLines4, 1) = 7 Then $FLCount = 3

If StringRight($TLines4, 1) = 8 Then $FLCount = 2

If StringRight($TLines4, 1) = 9 Then $FLCount = 1

$FLine3 = "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"

$FLC = 0

While $FLC <> $FLCount

FileWriteLine($ACHFile, $FLine3)

$FLC = $FLC + 1

WEnd

FileClose($ACHFile)

;------------------------------------------

Thank you,

inov8iv

Edited by inov8iv

Share this post


Link to post
Share on other sites
Melba23

Good morning,

As you are only concerned about the last line of the file, try using FileWrite rather then FileWriteLine.

From the Help file:

FileWriteLine - "If the line does NOT end in @CR or @LF then a DOS linefeed (@CRLF) will be automatically added."

FileWrite - "The line is written as is - no @CR or @LF characters are added."

That should solve your problem.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
inov8iv

Changing the FileWriteLine to FileWrite did not work. As you can see in the script, I am using the $FLine3(rows of 9's) to finish the footing for my file. they have to be in columnar format. I am going to test the file with the extra linebreak at the end and see if it works. You solution sounded good, but I think it would create to much extra coding for me to make it work. Anyone else have any ideas?

Thank you,

Share this post


Link to post
Share on other sites
Melba23

inov8iv,

Why not change the While...WEnd to a For...Next, but leave it one short:

For $FLC = 0 To $FLCount - 2
    FileWriteLine($ACHFile, $FLine3)
Next
FileWrite($ACHFile, $FLine3)

That way you get the @CRLF for everything but the last line.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
inov8iv

inov8iv,

Why not change the While...WEnd to a For...Next, but leave it one short:

For $FLC = 0 To $FLCount - 2
    FileWriteLine($ACHFile, $FLine3)
Next
FileWrite($ACHFile, $FLine3)

That way you get the @CRLF for everything but the last line.

M23

I did something similar, but may change it to your way to make it simplier.

$FLC = 1

While $FLC < $FLCount

FileWriteLine($ACHFile, $FLine3)

$FLC = $FLC + 1

WEnd

While $FLC = $FLCount

FileWrite($ACHFile, $FLine3)

$FLC = $FLC + 1

WEnd

Thanks for your help people.

inov8iv

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×