Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying Text file

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I am trying to open two text files and write from one to the other changing the format as I do it. The file I open to pull from has one long string of data of indeterminate length. It can vary with each file. I want to open the first file, pull the first 80 characters and put them on the first line of the second file. Then grab the next 80 characters of the first file and put them on the second line of second file. And so on until I am at the end of the record of the first file. Or, maybe just adding a carrage return every 80 characters.

Opening the files I've done before but can I get som guidence on parsing out 80 characters putting them in the other file then grabbing the next 80 characters? I don't know where to begin.
Thanks
 
inString = Input(80,#1)?

_________________
Bob Rashkin
 
It doesn't appear that you are doing anything with the data at this point, just parsing it into 80 character strings with a CR at the end. If you are just trying to make it easier to read in NotePad then start NotePad, open the file, and check <Format || Word Wrap>.

If you really need the second file, then open the read-from file as a textstream object. Create the write-to file as a textstream object.

WriteToFile.WriteLine(ReadFromFile.Read(80))
The .Read method will read the specified number of characters. I don't know if it will index to 81 on the 2nd loop through. You might have to jump to a point in the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top