Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SEEK with INPUT for variable length strings
#3
If you edit the text file, you just add the edited data to the end of the data.text and change the index to point to it.

For example, my data.txt file is: "onetwothreefour"

So my index file would be: 1,4,7,12

Now I want to change my second element from "two" to "apple juice".  Obviously, I can't put the 11 characters of "apple juice" in the three character spot of "two", so I just write them to the end of my data and change the index.

data.txt is now:  "onetwothreefourapple juice"

my index file is now: 1,16,7,12

There's 3 characters in the data.txt that are "lost" and not referenced anywhere, (that's the "two" that's still in there), but that may not be a big deal for me.  If it is, I'd probably want to write a routine to clean up and reindex the datafile while all my workers were at home and my company was shut down for the night.  (Say 2:00 AM Sunday morning for most folks.)  <-- That's called "Repacking" a database, and is generally just routine business which no one ever has to worry about except the data base programmer.  Wink

(And note, normally I'd either store my data with a terminator such as CRLF or CHR$(0), or else I'd have to store it with the length in my index as well.  I didn't do that here, as this is just talking about the concept and there's no actual code in this post to run or see the concept at work.  Wink )
Reply


Messages In This Thread
RE: SEEK with INPUT for variable length strings - by SMcNeill - 02-07-2023, 09:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extended Input SMcNeill 1 660 05-09-2025, 10:06 AM
Last Post: bplus
  Variable length string database, using an index file SMcNeill 0 698 04-23-2022, 05:16 PM
Last Post: SMcNeill
  Multi-Input Popup Box SMcNeill 0 613 04-23-2022, 05:12 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)