Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Question on memory set aside for Zero
#5
It all depends on how the data was written to file.   GET/PUT doesn't have any sort of CRLF usually.   Of course, if you were using GET/PUT with SINGLE values, then they wouldn't be in human readable format.  SINGLE is 4-bytes, but 57 might liook like $#@! for those 4-bytes.  It certainly isn't going to loo like "57".

IF you used WRITE to create the file, then the file would be human readable as you describe, but you won't be able to use SEEK with it effectively.  The issue is the fact that those data are written in base-10, human-language format.

Take the value 12345, for example.  A SINGLE variable type will easily hold that value, but that's going to be 5-bytes in length and not 4.

The only way you could use SEEK with that data  file would to be to convert it first so that each data entry was the same number of bytes.

0057
0000
0123
4567

Something similar to the above would work as it'd be a set 4-bytes for data + CRLF, with the leading 0s working as placeholder for your spacing.

But, from what it looks like you have, and from how you speak of creating the file (using WRITE #), then your only option is just to read that file sequentially to get to the data you want.  Luckily, it doesn't sound as if it's an extremely large file, so I'd either just read it once and store it in an array, or else I'd just SEEK #file_handle, 1 and read it from the start of the file to the point where I get the data I need each time.  Your access times on something small like this isn't going to be that great overall, in the end, I don't think.  It's not like having to sequentially read millions of records to get to that one proper one.  Wink

When you WRITE to a file, you need to INPUT from that file, and if the data is variable length (like it is here), you can't just use SEEK easily with it.
Reply


Messages In This Thread
RE: A Question on memory set aside for Zero - by SMcNeill - 11-30-2024, 04:53 PM



Users browsing this thread: 14 Guest(s)