Reading/Deleting Last Line Of File

Brian Yennie briany at qldlearning.com
Thu Feb 11 00:55:35 EST 2010


It's more a product of the syntax than anything. url "file:myfile.txt" is a container, and the length operates on it as such. URL containers are pretty darn handy in general, but this is one potential gotcha.
You can use the detailed files to get information about a file, including its size in bytes. So actually your suggestion should work fine, just needs a little tweaking. It would just be more like:

put filelength("myfile.txt") into tEnd
open file "myfile.txt" for text update
seek to tEnd in file "myfile.txt"

function filelength tFile
	// use the detailed files to get the file size
end filelength

No need to get all flustered =)

- Brian

> 
> 
> On Feb 10, 2010, at 11:26 PM, Brian Yennie wrote:
> 
>> Jeff,
>> 
>> This line:
>> 
>>> put the length of url "file:myfile.txt" into tEnd
>> 
>> Loads the entire file into memory in order to get its length.
> 
> 
> 
> That's a joke, right? :-(
> 
> A freakin' OS call could get that just by touching an I-Node. Please, God, tell me Rev was smart enough to do it the right way?
> 
> Jeff M._______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolutio



More information about the use-livecode mailing list