Re: help loading script objects
Re: help loading script objects
- Subject: Re: help loading script objects
- From: "Arthur J Knapp" <email@hidden>
- Date: Thu, 08 Mar 2001 15:56:08 -0500
>
From: email@hidden
>
Date: Wed, 7 Mar 2001 12:09:34 EST
>
Subject: help loading script objects
>
Is it possible to load a file containing a script object? I've tried loading
>
it as I do handler libraries, and refer to it the form:
>
tell myScriptObject to doSomeHandler()
>
but it returns an error. I've placed the script object inside a handler and
>
called that handler before trying to refer to the script object, but this
>
also results in error.
If I understand the problem correctly, you have to refer to the script
object as an element of the loaded script:
set anObject to load script alias "whatever..."
tell myScriptObject of anObject to doSomething
Alternatively, you can set your initial variable to the script
object in this way:
set anObject to myScriptObject of (load script alias "...")
Yet more alternatively, you can simple make the loaded file
a script object, ie: there is really no difference between
a script object and a script that you load into a variable.
Instead of doing this:
*** file "my script object" ***
script myScriptObject
property abc : 123
property def : 456
end script
*** file "generic script" ***
set obj to load script alias "my script object"
abc of myScriptObject of obj
-- > 123
just do this:
*** file "my script object" ***
property abc : 123
property def : 456
*** file "generic script" ***
set obj to load script alias "my script object"
abc of obj
-- > 123
Dealing with scope is discussed, (albeit in a confusing manner),
in the AppleScript Language Guide:
<
http://developer.apple.com/techpubs/macos8/InterproCom/AppleScriptScripters
/AppleScriptLangGuide/index.html>
P.S. Actually, there may be a difference between a script object
and a script loaded as an object, but it's like some sort of
big AppleScript secret that we're not supposed to know about.
;-)
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://home.earthlink.net/~eagrant/