Jump to content

FileWriteLine() or FileWrite()


Recommended Posts

Is is possible to write to a certain line number in a text file? I've read over FileWriteLine() and FileWrite() and both just seem to append. For example, I create a text file, but then I want to go back to the 6th line in the text file and insert a 'Total Record Count.' Could I do this, if so, how?

As always, thanks for your time.

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to post
Share on other sites

Thanks Plato,

I follow your code, but I'm not sure I understand. If I have the file open for Readin, and I read down to the 6th line, and then I do a FileWriteLine() will it automatically put the text on the 6th line? And if so, will it replace the 6th line or will it move down whatever was on the 6th line to the 7th line?

Thanks again,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to post
Share on other sites

file1 = the file that you want to add a line to - on line 6

file2 = temp file

first time thru loop

line 1 from file1 is put into file2

next time thru loop

line 2 from file1 is put into file2

next time thru loop

line 3 from file1 is put into file2

next time thru loop

line 4 from file1 is put into file2

next time thru loop

line 5 from file1 is put into file2

next time thru loop

extra line is added to file2 at position 6

line 6 from file1 is put into file2 as line 7

you check the EOF and exitloop

after loop copy file2 over file1

boy, I'm glad you did not want to add at line 1200....

Edit: opps

Edit2: opps2

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...