[BUG] write to file

J. Landman Gay jacque at hyperactivesw.com
Mon Jan 25 15:35:33 EST 2016

On 1/24/2016 9:46 PM, Kay C Lan wrote:
> The Dictionary says that if I open a file for 'update', then 'read from
> file' to a specific position that when I 'write to file' it will occur at
> the position I've read to but that's not what I'm seeing in 6.6.5GM, 7.1.1
> rc4 and 8.0 dp13 - OS X 10.9.5. In the msg box:
> set the defaultFolder to specialFolderPath("documents")
> put "trash this file.txt" into tFileName
> put "This is a test." into URL ("file:" & specialFolderPath("documents") &
> "/" & tFileName)
> open file tFileName for update
> read from file tFileName for 2 words
> put it into tResult
> write "open/read/write/close" to file tFileName
> close file tFileName
> put URL  ("file:" & specialFolderPath("documents") & "/" & tFileName) into
> msg
> put cr & tResult after msg
> I was expecting:
> This is open/read/write/close
> What I'm getting:
> This is a test.open/read/write/close
> The 'read' portion is clearly working correctly so there is something wrong
> with 'write' but I'm surprised that this hasn't broken people's code left
> right and centre so what am I doing wrong? How do I get LC to write from
> where I've read to?

If you specify the position it seems to work:

  write "open/read/write/close" to file tFileName at 8

If you're tracking the file content, you could also use "seek" to move 
the current pointer position.

In either case, there does seem to be something wrong with "write".

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

More information about the Use-livecode mailing list