Reading a (BIG) text file one line at a time - in reality...

J. Landman Gay jacque at hyperactivesw.com
Sat Nov 27 12:47:16 EST 2004


On 11/24/04 12:00 PM, Raymond E. Griffith wrote:

> I haven't followed the thread closely, so if I am off base please forgive
> me.
> 
>>From examining the script, the word count is probably off by just about as
> many times as you repeat through the file. You are getting a word count with
> each repeat, but in your reading blocks you are not only chopping lines, but
> words in two as well.

That may be it. But the chopped-off line isn't being counted until it is 
complete (in the next pass), so I'm not sure that's the cause. But if I 
get a chance after my house guests leave this weekend, I'll take a look.

> Another question. I see you are summing the number of words in each line. Is
> this really necessary? Perhaps you might just ask for the number of words in
> the completed block after you have finished reading it and putting it
> together? 

The word count isn't important to the script, it is just something to do 
in order to test the buffering routine. It could have been anything 
inside the repeat loop; add 1 to a variable, for example, or any other 
busy work. We were testing different ways of reading a file from disk; 
it doesn't matter what we did with the data after it was read --  which 
is why I didn't bother to debug the word count problem. ;)

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list