• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

if (Myword < Word$) Then SeekFile(Filenum,((FilePosition * 18) - 18)) writestring(filenum,MyWord) MyWord = WordString End If FilePosition ++ Loop Not using actual code just psuedo coding above Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !! ### #2SiCrane Moderators Posted 11 December 2012 - 09:39 AM Did you try implementing your pseudocode? Did it work? If not, then what errors or incorrect behavior did you observe? ### #3Nypyren Members Posted 11 December 2012 - 12:08 PM I suspect the underlying problem is that when you write at a position in a random access file, you *overwrite* what is already there. In order to insert, you have to shift the entire remainder of the file forward as well. ### #4Poigahn Members Posted 12 December 2012 - 08:33 AM I am not certain if I am Overwriting, Under-Reading or what ? My fixed String$ length is 18 charactors. I know the first element starts at 0 - But is the anything additional that gets written to a file that I need to account for or will the above math work ?
I have coded the routine. Wrote 6 TextStrings to the diskdrive, but I can't properly read then.
Does Seekfile Only work with binary files ?
Will seekfile Also work on textfiles if each string is the samelength ? ( Adding spaces to shorter words to get to the length of 18 )

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!

### #5SiCrane  Moderators

Posted 12 December 2012 - 09:25 AM

How can we know how SeekFile works when you haven't mentioned what programming language, operating system or I/O library you are using? Also "I can't properly read then" isn't an adequate error description. What exactly goes wrong when you read the file? Did you try opening your file in something like a hex editor to see if it was written properly? And since you now have actual code instead of pseudo-code it would probably help if you showed what you actually wrote. This includes both writing and reading.

### #6Poigahn  Members

Posted 14 December 2012 - 05:25 AM

What went wrong was 2 things. I could write the first data string with a fixed length of 18 charactors. When I try writing the next string by using SeekFile to position the pointer it would either be to short or to long ? Not Certain. Subsequently when I would try to read then Third String out of 5 and compare it to an identical string to make certain I war reading what I was writing, I would no get a match. So I did not know if the math calculation to position the pointer was off and by how many elements.
I Have since solved it by opening the file as a sequential read, reading in each string, The identifying the string size to determine how it was written to the disk drive and then adjusting the math accordingly.

In the end , Problem Solved

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.