Reading/Deleting Last Line Of File

J. Landman Gay jacque at hyperactivesw.com
Fri Feb 12 23:11:01 EST 2010


Kay C Lan wrote:
> On Sat, Feb 13, 2010 at 8:25 AM, Alex Tweedly <alex at tweedly.net> wrote:
> 
>> Could you try this in your multi-line msg box and let me know what it does
>> on Mac ?
>>> put "abcdefg" & CR into URL "file:b.txt"
>>> put URL "file:b.txt"
>>> open file "b.txt" for append
>>> write "x" to file "b.txt"  at 2
>>> close file "b.txt"
>>> put URL "file:b.txt" after msg
>> on Win, it produces
>>> abcdefg
>>> abx
> Alex,
> 
> on OS X.6.2, MBP, Rev 4.0
> 
> abcdefg
> abcdefg
> x

I did some quick tests and it looks like the write command is broken on 
OS X. Endian issue with Intel Macs maybe. Don't open a file "for write" 
until they fix it, you can lose data. I'll file a bug report.

The reason I just noticed this is because I was testing some of these 
suggestions. The version of "open file" we should be using, the one 
which truncates contents, is the "open for write" command. However, no 
matter at what position I write to the file, the entire contents were 
replaced. Don't go there if you're on a new Mac.

You won't lose data with other types of open file, but the write 
position may be off. It sounds like it works okay on Windows, and I 
suspect Linux is okay too. I remember using "open file for write" on my 
PPC machine and had no trouble, which is why I suspect an Intel issue.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list