Current seek position

Keelan Lightfoot keelan at mail.grenander.com
Thu Oct 24 09:14:00 CDT 2002


I'm working on a disk based database system, to run on a machine with
limited memory. Loading the entire file into memory to count the number of
bytes is not an option.

I need to know the current seek position so that I can record it in a table
that points to the fragments of data in the database.

After posting this message last night, I came up with this bit of code to
find the file size:

function fileSize thePath
  set the itemdelimiter to "/"
  put the last item of thePath into theFile
  delete the last item of thePath
  set the itemdelimiter to ","
  set the defaultfolder to thePath
  put the detailed files into fileList
  repeat for each line compareFile in fileList
    if item 1 of compareFile is theFile then
      return item 2 of compareFile
    end if
  end repeat
end fileSize

This will work as a work-around, though it seems a bit clunky.

- Keelan Lightfoot

> From: "Ken Ray" <kray at sonsothunder.com>
> Organization: Sons of Thunder Software
> Reply-To: use-revolution at lists.runrev.com
> Date: Wed, 23 Oct 2002 22:36:21 -0500
> To: <use-revolution at lists.runrev.com>
> Subject: Re: Current seek position
> 
> Just curious... why do you need to know this? If you're looking at appending
> data to a file, you can do a "write <data> after file <fileName>", and if
> you need to know the length of the file you can read it into a variable with
> "put url ("file:" & <fileName>") into <myVar> and then get the length of
> <myVar>.
> 
> Can you shed some light on your request?
> 
> Thanks,
> 
> Ken Ray
> Sons of Thunder Software
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> 
> ----- Original Message -----
> From: "Keelan Lightfoot" <keelan at mail.grenander.com>
> To: <use-revolution at lists.runrev.com>
> Sent: Wednesday, October 23, 2002 10:17 PM
> Subject: Current seek position
> 
> 
>> How can I find the current position to which I am at in an open file? I
> need
>> to be able to go to the end of the file (which 'seek to -1 in file ...'
>> would take care of), but I need to know the position I'm at when I'm at
> the
>> end of the file.
>> 
>> Thanks,
>> 
>> Keelan Lightfoot
>> 
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list