Current file position ?

Alex Tweedly alex at tweedly.net
Tue Jul 20 19:40:03 EDT 2004


At 17:49 20/07/2004 -0400, Cubist at aol.com wrote:
> >> at a specified position
> >> but I can't find how to find the current position.

>[snip]

>    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...

It can be done - at some inconvenience and with some risk that it will be 
wrong. And if you forget, in just one place, and use a file function 
directly instead of using the handler (or forget to adjust the variable), 
you have a very tricky bug to find. So that's a fragile or "brittle" solution.

It's true that "every other computer language known to man provides a 
built-in function to do this" isn't necessarily a reason why it MUST be 
built-in to Transcript - but I think it's a good reason why it SHOULD be.

(btw - I'm sure you, or I, can find another language that doesn't have it - 
but it's there in 99% of all known household languages)

As always,  you use the best tool for the job in hand. So I implemented my 
little "csv file indexer" application in another language instead of 
Transcript - it had the necessary function there at no cost and no effort. 
I'd have preferred to use Transcript, because I'm trying to learn it; but 
my aim is to get the functionality the user needs in the best time / effort 
/ risk trade-off, not be a language evangelist.

-- Alex.
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004


More information about the use-livecode mailing list