• 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: Cannot return string from handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cannot return string from handler


  • Subject: Re: Cannot return string from handler
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 5 May 2006 18:18:38 +0200


Le 5 mai 2006, à 13:53, Ruth Bygrave a écrit :

Shouldn't that be easy?

I have three or four scripts that I wanted to tidy up by making them modular, as it says in the books should be done. For example, my backup script has a bit that tells the Finder to see if any of my flash disks exist before backing up.

on init
tell application "Finder"
if disk "Disgo" exists
set myTarget to "Disgo"
end if
return myTarget
end init

which is called from the main script as
set targetRoot to (my init)



Some readers gave fine advices but I think that a detail is always missing.
If the disk "Disgo" doesn't exist, the variable Target is not defined.


My own version would be:

on init()
tell application "Finder"
if disk "Disgo" exists then
set myTarget to "Disgo"
else
set my Target to "" (* you may choose an other value *)
end if
return myTarget
end init

set targetRoot to my init()

Yvan KOENIG

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Cannot return string from handler (From: Ruth Bygrave <email@hidden>)

  • Prev by Date: Re: Powerpoint 255 character limit
  • Next by Date: Re: Cannot return string from handler
  • Previous by thread: Re: Cannot return string from handler
  • Next by thread: Re: Cannot return string from handler
  • Index(es):
    • Date
    • Thread