Current file position ?

Jan Schenkel janschenkel at yahoo.com
Wed Jul 21 06:14:14 EDT 2004


--- 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 ; please file an
> >enhancement request with bugzilla to get a
> >'currentPosition' property for open files.
> >Please remember to inform the mailing list of the
> >number so people can vote on it ;-)
>    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, to keep
> track of wherever you are in the 
> file you're reading, and adjust the value of that
> variable (or whatever) every 
> time you read from the file.
>    Hmmm... If you made that variable (or whatever)
> multi-line, with each line 
> consisting of two items (those being (a) a filepath,
> and (b) the numerical 
> position within the file whose path that is), you
> could write a file-reading 
> handler which keeps track of the position(s) within
> an arbitrarily large number 
> of files at once...
> 

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 ; just
like I'd love to see an addition to 'repeat for each'
that keeps track of the counter for you :
--
  repeat for each line tLine in tVar with counter i
    ...
  end repeat
--

Anyway, just my two cents.

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 


More information about the use-livecode mailing list