Alex Tweedly wrote:

Richard Gaskin wrote:
That looks similar to what I posted here on the 9th:

   open file tFile for update
   seek relative -1000 in file tFile
   repeat
      read from file tFile until cr
      if it is not empty then
         put it after tBuffer
      else
         delete last line of tBuffer
         write tBuffer to file tFile
      end if
   end repeat
   close file tFile

Does that not do what you need?

No, it doesn't. If a file is opened for 'update' then any write to the
file simply overwrites any existing characters at the appropriates
position(s), and leaves everything following that unchanged. There is no
EOF implied by a write in update mode.

Good catch. Seems my instinct to use "append" in my first version of that was closer to the mark.

But FWIW, I tried your version and it seemed to leave the file unchanged - is this a user error on my end, or does it have a limitation I overlooked?

> 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

--
 Richard Gaskin
 Fourth World
 Rev training and consulting: http://www.fourthworld.com
 Webzine for Rev developers: http://www.revjournal.com
 revJournal blog: http://revjournal.com/blog.irv
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to