On Feb 18, 2011, at 23:59, louie wrote:
Could you fix the below to not use shell script?
______________________________________________________________________
------------------------------------------------------------------------------------
# HANDLER :: WRITE TEXT TO A FILE AND OVERWRITE ANY CONTENT
# 2010-10-30 : 04:11
------------------------------------------------------------------------------------
on write_to_file_overwriting(someText, targetFile)
try
set resultNumber to open for access targetFile ¬
with write permission
set eof of resultNumber to 0
write someText to resultNumber
close access resultNumber
on error errMsg number errNum
try
close access resultNumber
on error errMsg number errNum
beep
display dialog "Error: " & errMsg & return & "Error Number: " & errNum
end try
end try
end write_to_file_overwriting
------------------------------------------------------------------------------------
# MAIN
------------------------------------------------------------------------------------
set theFile to alias ("" & (path to home folder) & "test_directory:recording")
set switchON to "on"
set switchOFF to "off"
set onOff to read theFile
if onOff is "on" then
write_to_file_overwriting(switchOFF, theFile)
else if onOff is "off" then
write_to_file_overwriting(switchON, theFile)
end if
say (read theFile)