Re: Running from what?
Re: Running from what?
- Subject: Re: Running from what?
- From: Dave Saunders <email@hidden>
- Date: Sat, 25 Nov 2000 07:11:18 -0500
>
From: Paul Berkowitz <email@hidden>
>
To: Applescript-Users <email@hidden>
>
>
So this is what I'd suggest: DON'T just just call the script from the OC
>
buttons - embed it. Then you won't even need to test for 'path to me', since
>
you KNOW it's running from an OC button. Just write it differently:
>
>
Variable eOC
>
>
AppleScript
>
try
>
-- your script
>
set OneClick variable "eOC" to "OK"
>
on error errMsg
>
set OneClick variable "eOC" to errMsg
>
end try
>
End AppleScript
>
If eOC <> "OK"
>
Message eOC
>
End If
>
>
>
And in the script running from OSA Menu:
>
>
try
>
--your script
>
on error errMsg
>
display dialog errMsg
>
end try
>
>
>
You can do this wherever in the script you want to error-trap (i.e. it
>
doesn't have to surround the whole script as above).
>
Paul,
Thank you for your comprehensive and thoughtful reply. I need to do
something along these lines. Your solution falls foul of the problem that
OneClick doesn't always clean up behind itself if a called AppleScript
terminates with an error. So, although what you wrote is theoretically
sound, the first time you click the OneClick button after hitting an error,
you'll get an immediate error and the only way out is to quit the
application and relaunch (sometimes, a restart of the machine is necessary).
I had thought along similar lines and a solution came to me in the middle of
the night. My OneClick button reads:
Variable StartupDisk, theAppleScript, theMessage
If Button.Color = 36 AND NOT (OptionKey)
Exit
End If
Button.Color = 36
Button.Update
StartupDisk = Volume.Name
theAppleScript = StartupDisk & "System Folder:Scripts:InDesign 1.5
Scripts:Off10 Scripts:OnePara"
AppleScript theAppleScript
theMessage = ASResult
If NOT (theMessage = "OK")
Message theMessage
End If
Button.Color = 1
I surround the real part of the script with the button coloring stuff
because some of these scripts take a long time to operate. You'll see that I
expect the script I'm calling ("OnePara") to be in the OSA menu folder so it
can also be called from there.
The solution I thought of is to move this script elsewhere and put in the
OSA folder an AppleScript that does essentially what this OneClick script
does. That way, I avoid the original issue by having the scripts have to
find out from where they're being called.
Thanks again.
Dave