A favour from a Leopard user, please

Hi, folks.

I’m currently revising my ScriptWire article about the File Read/Write commands in order to sort out a couple of inaccuracies (and punctuation errors). The release notes for AppleScript 2.0 in Leopard mention a change to the encoding system in the read and write commands made necessary by the amalgamation of the string and Unicode text classes; but it’s not clear (to me) what sort of text now gets written to a file if it’s written, say, as string. Since I’m not yet in a position to upgrade to Leopard myself, would some kind Leopard user care to run the following test script for me and tell me what it returns? (It creates a test file on the desktop, writes some known text to it with various as settings, and notes the length of the file in each case.) Thanks. :slight_smile:

set testPath to (path to desktop as Unicode text) & "Test file.txt"
set testText to "12345"
set fileLengths to {}

set fRef to (open for access file testPath with write permission)
try
	set eof fRef to 0
	write testText to fRef
	set end of fileLengths to (get eof fRef)
	
	set eof fRef to 0
	write testText as string to fRef
	set end of fileLengths to (get eof fRef)
	
	try
		set eof fRef to 0
		write testText as text to fRef -- Writing 'as text' errors in Jaguar and Tiger.
		set end of fileLengths to (get eof fRef)
	on error
		set end of fileLengths to missing value
	end try
	
	set eof fRef to 0
	write testText as Unicode text to fRef
	set end of fileLengths to (get eof fRef)
on error msg
	display dialog msg buttons {"OK"} default button 1
end try
close access fRef

return fileLengths
--> {5.0, 5.0, missing value, 10.0} -- With Jaguar and Tiger.

Hi Nigel,

in Leopard it returns
{5, 5, 5, 10} (all integers)

That’s great! Thanks, Stefan. :slight_smile: