Current file position ?

Cubist at aol.com Cubist at aol.com
Wed Jul 21 13:14:26 CDT 2004


sez janschenkel at yahoo.com:
>--- Cubist at aol.com wrote:
>> sez janschenkel at yahoo.com:
>> >--- Alex Tweedly <alex at tweedly.net> wrote:
>> >> How can I find the current file position ?
>> >> 
>> >> I found
>> >>    seek  ..                      to set the
>> current
>> >> position (either abs or 
>> >> relative)
>> >>    read .... at N ...           to read, starting
>> at
>> >> a specified position
>> >>    write .... at N ...          to write,
>> starting
>> >> at a specified position
>> >> but I can't find how to find the current
>> position.
>> >
>> >I'm afraid you can't do that...
>>    More precisely, Rev doesn't keep track of such
>> things *for* you. So if you 
>> want to do it, you have to do it yourself, "by
>> hand". Use a separate 
>> variable, or custom property, or whatever...
>Of course we can track it ourselves, but I think it
>makes more sense that we can ask the engine where
>we're at in the file. Example :
>--
>on ReadTheFile pFilePath
>  open file pFilePath
>  read from file pFilePath for 1 line
>  put the currentPosition of file pFilePath
>  close file pFilePath
>end ReadTheFile
>--
>Indeed, I can just check (the length of it) and add it
>to my counter, but it's just more convenient...
   Obviously it *would* be more convenient to just let the engine handle the 
messy details; I don't dispute that in the least. In fact, I think I agree 
with you, and Alex, that such a thing would be good. All I'm sayin' is, if you 
(or anyone else) need this feature *right now* (as opposed to whenever RunRev's 
demon programmers get around to adding this feature to the engine), it should 
be possible for you to implement it yourself in one form or another.

>just like I'd love to see an addition to 'repeat for ...
>  end repeat
   Me, too. But seeing as how the currently-necessary workaround isn't *that* 
grotesquely inconvenient, I am unsure that it's worth the bother of tryna 
persuade RunRev's demon programmers to fix it...


More information about the use-livecode mailing list