Page 1 of 1
open file for text read
Posted: Tue Aug 26, 2014 8:54 pm
by zaxos
hello ppl, i have a text file that gets data from a shell every second, in livecode i use open file for text read and then read from file until eof, the problem is that eventualy the file gets too large and livecode takes too much time to read it, the questing: is there a way to keep track of the last position read from was at ? or there any way at all to speed up the procesing time of the text if it gets too large?
Re: open file for text read
Posted: Tue Aug 26, 2014 10:58 pm
by Simon
"read from file" in the dictionary suggests there is a start character and an end character.
So you'd just track those.
Simon
Re: open file for text read
Posted: Tue Aug 26, 2014 11:10 pm
by zaxos
Hey there simon, thank you for your time helping.
I'm assuming that you mean i should use a buffer with the characters every time i read from the file, well i'v tryied this and its just as slow as reading the whole file, basicly the code takes some numbers from the txt and adds them then it puts them in a var, what i want is to add the numbers then put them in the var and the next time it reads from the txt it should only add the lines added to the txt, not all of it...
if i misunderstood your suggestion let me know

Re: open file for text read
Posted: Tue Aug 26, 2014 11:58 pm
by Simon
this seems to do it:
Code: Select all
global tCount
on mouseUp
set the defaultFolder to specialFolderPath("desktop")
open file "temp.txt" for read
read from file "temp.txt" at tCount until EOF
put it
put the (number of chars of it + 1) into tCount
if tCount = 1 then put 0 into tCount
close file "temp.txt"
end mouseUp
but it's sloppy. Not sure if there is any more speed.
Simon