Reading/Deleting Last Line Of File

Alex Tweedly alex at tweedly.net
Fri Feb 12 09:43:34 EST 2010


Jim Bufalini wrote:
>
> Just one thing Alex, you need to:
>
> put URLDecode(the detailed files) into t
>
> in case the file name has, for example, a space in it.
>   
Thanks Jum, I didn't spot that.

But then, if the file name had a comma in it, I'd be caught out. I think 
what I needed was to URLEncode(pFile) to use in the filter :

> on deletelastline pFile
>    constant K = 1000
>    put the detailed files into t
>    filter t with URLEncode(pFile) & ",*"
>    put item 2 of t into tFileLength
>    
>    open file pFile for read
>    seek to tFileLength-K in  file pFile
>    read from file pFile until end
>    close file pFile
>    
>    put the number of chars in the last line of it into tNum
>    
>    open file pFile for append
>    write empty to file pFile at (tFileLength-tNum-3)
>    close file pFile
>    
>    end deletelastline
-- Alex.



More information about the use-livecode mailing list