Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indexed files
#15
Hi Phil
Back on the old site I had a similar discussion with Steve on a project I was trying to get off the ground. I recall the topic we were using was called "Random Access to a Sequential File". The major stumbling block was finding a particular record in a sequential file. The first thing I remember Steve pointing out is that it can't be done accurately without knowing the length of each record. It's easy to determine the size of each variable within a record (ie a Long = 4 byte and an Integer = 2 etc). The challenge is the string variables. Back then Steve pointed out that the safest was to determine what the words were in the longest string and to be sure to pad with spaces those string words which were less than the longest.

If you have another way to calculate the exact length of each string's length, then you wouldn't need any spacing. 

It is a simple matter then of opening the file once and use Seek #1 (or Seek #100 whatever the file number you have chosen to open) to position the search at the beginning of the sequential file, Record 1 would be record 1 (ie Seek #1, 1). If memory services me right, the pointer finding the records will always end on the last data item so to get to the next record you have to add one (assuming you want the next record)

The way the random access worked, and I'm struggling with my memory here - say you started with search for record 22, then it was Seek #1,(record length *21+1). and the next search was for record 14, you would reset the search back to the beginning and do the same thing (Seek #1,1 to get back to the beginning) then Seek #1,(record length *14+1)

Sorry Phil if this is not what you were thinking of, and of course if I'm way out to lunch on the structural layout of the coding.
Reply


Messages In This Thread
Indexed files - by PhilOfPerth - 11-03-2023, 11:21 PM
RE: Indexed files - by a740g - 11-03-2023, 11:40 PM
RE: Indexed files - by bplus - 11-03-2023, 11:44 PM
RE: Indexed files - by bplus - 11-03-2023, 11:50 PM
RE: Indexed files - by TerryRitchie - 11-03-2023, 11:55 PM
RE: Indexed files - by bplus - 11-03-2023, 11:55 PM
RE: Indexed files - by SMcNeill - 11-04-2023, 12:29 AM
RE: Indexed files - by bplus - 11-03-2023, 11:57 PM
RE: Indexed files - by JamesAlexander - 11-04-2023, 01:20 AM
RE: Indexed files - by PhilOfPerth - 11-04-2023, 01:39 AM
RE: Indexed files - by mnrvovrfc - 11-04-2023, 02:21 AM
RE: Indexed files - by PhilOfPerth - 11-04-2023, 07:44 AM
RE: Indexed files - by bplus - 11-04-2023, 11:54 AM
RE: Indexed files - by SMcNeill - 11-04-2023, 12:42 PM
RE: Indexed files - by Dimster - 11-04-2023, 01:57 PM
RE: Indexed files - by bplus - 11-04-2023, 04:50 PM
RE: Indexed files - by Kernelpanic - 11-04-2023, 11:13 PM
RE: Indexed files - by PhilOfPerth - 11-05-2023, 12:21 AM
RE: Indexed files - by bplus - 11-05-2023, 01:55 PM
RE: Indexed files - by PhilOfPerth - 11-05-2023, 11:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  More info about Random Access files PhilOfPerth 28 953 02-25-2026, 01:50 PM
Last Post: ahenry3068
  Embedding and Extracting MANY files ! ahenry3068 20 1,552 11-15-2025, 10:19 AM
Last Post: ahenry3068
  program that stitches together a bunch of image files into one giant poster? madscijr 15 2,369 10-24-2024, 06:08 PM
Last Post: madscijr
  Linux HTTP WEB Server Issues - Large Files Fail old_coder 0 458 03-27-2024, 08:33 PM
Last Post: old_coder
  Making the content list of files inside a Zip ? euklides 13 2,401 02-08-2024, 03:52 PM
Last Post: euklides

Forum Jump:


Users browsing this thread: 1 Guest(s)