in reply to Replace a position in a txt file.

Which part is giving you trouble? Break it down into steps, and let us know which step you're unable to implement.

I'm glossing over low level detail so that you can more easily point to the step that is problematic. Once we know which problem you haven't been able to solve, we will know where to provide help. And as you point to the part of the problem you haven't overcome yet, please provide a compact example of code that we can work on with you.

One thing to keep in mind: Imagine you're doing this project with a pen and paper, and that you have no eraser or white-out. This is the situation that you mostly likely find yourself in when dealing with updating variable-width fields in a flat text file. If you were doing it with pen and paper, with no eraser and no white-out, you would take two pages of paper; one with your original information, and one blank. Then you would look at the first line of your original page, and write it down (with any necessary modifications) on the second page. You would repeat this line after line, until you have finished the new page. The new page would then contain a near duplicate of the original, but with the modifications in place. Once you verified that your new page is complete, you could toss out your original page. This is the most straightforward approach, and happens to be very close to how you will accomplish the task programatically as well.


Dave