Reading/Deleting Last Line Of File

Richard Gaskin ambassador at fourthworld.com
Tue Feb 9 19:05:42 EST 2010


Would the seek command help?

Presumably it would move the file pointer to the specified point without 
having to load the entire file into RAM.

If you knew your lines were shorter than a given length, say 1000 chars, 
you could so something like:

   open file tFile for append
   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

This is off the top of my head to test before using on real data. ;)

--
  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



More information about the Use-livecode mailing list