×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using the Put Statement!!

Using the Put Statement!!

Using the Put Statement!!

(OP)
When you use the Put Statement and the text file already contains data (text) it overwrites the data at the position you state. Can I go to a position in a text file and overwrite a certain number but leave the data in front of this number there. The number that I want to write to the file might be longer than the number already in the position.

Thanks for any help :)

RE: Using the Put Statement!!

It sounds like you want to insert into the middle of a text file, depending on whether there's enough room for the stuff you want to Put there.

Not an easy question, I'm afraid.

Once you've determined that your data won't fit, you have to go through the following steps:
1) Copy all data from your original file (file 'A') up to the start of the position you want to insert to, to file 'B'.
2) Append your data to file 'B'
3) Back in file 'A', skip over the data that you would've overwritten, then append the rest of file 'A' to file 'B'
4) Delete file 'A', and rename file 'B' to 'A'.

Ugly, really ugly, but I don't know any other way to handle it. Maybe someone else here has a better suggestion. Of course, the "correct" answer would be to redesign the file layout so this doesn't happen, but that may not be an available option for you.

Chip H.

RE: Using the Put Statement!!

Hmmm...

I would suggest that if you get to this point - it's time to use a little database.

Don't waste your time shuffling data about - it's already been done and far better than most of us could do it. Easy enough to read and write to a database file in VB - even I managed it...

Mike

Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close