• Post Reply Bookmark Topic Watch Topic
  • New Topic

writing to random access file

 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found a way to write a string to a random access file at a certain point in the file, but it overwrites the text that was there before. Is there a way to 'insert' new text in the middle of a file and move all the stuff that was there before to a position after the newly written string?
Thanks a lot.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no single command for this. Basically you've got to grab all the bytes from the insert to the end of the file, and copy them to new positions later in the file. Then write whatever you want to insert, on top of the old byte values that you just copied to new locations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!