Jump to content

Recommended Posts

Posted (edited)

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
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted

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,

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted

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

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
×
×
  • Create New...