Re: any way to tell if a script has a 'return' statement?
Re: any way to tell if a script has a 'return' statement?
- Subject: Re: any way to tell if a script has a 'return' statement?
- From: JollyRoger <email@hidden>
- Date: Thu, 25 Oct 2001 12:22:40 -0500
On 10/25/2001 11:40 AM, "email@hidden" <email@hidden> wrote:
>
> I want to be able to save the result returned by a script to a file, but
>
> since the result will always have something in it (something I don't want to
>
> save if the script doesn't specifically return a value), how do I tell
>
> whether or not I should be saving the result variable? I won't know a priori
>
> if the script I am running has a return statement.
Just off the top of my head: One way might be to (a) assign the result of
the handler call to a variable, and then (b) wrap the call to the script
handler in a try statement. If the return value of the handler is
undefined, no return statement was used. Something like this:
try
set myVar to ScriptObject's Handler()
get myVar
on error
-- myVar is undefined
-- (you might figure out what error number this is
-- and only handle that particular error number)
end try