Re: Cannot return string from handler
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