• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: need some help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: need some help


  • Subject: Re: need some help
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 19 Feb 2011 03:21:14 -0600

On Feb 18, 2011, at 23:59, louie wrote:
Could you fix the below to not use shell script?
______________________________________________________________________

Hey Louie,

The location of my file is in a different place, but I think this replicates the functionality.

--
Best Regards,
Chris

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: need some help
      • From: Shane Stanley <email@hidden>
References: 
 >need some help (From: louie <email@hidden>)

  • Prev by Date: Re: need some help
  • Next by Date: Re: need some help
  • Previous by thread: Re: need some help
  • Next by thread: Re: need some help
  • Index(es):
    • Date
    • Thread