Re: Settings properties from a loaded script
Re: Settings properties from a loaded script
- Subject: Re: Settings properties from a loaded script
- From: email@hidden
- Date: Mon, 8 Jan 2001 18:26:37 -0500
On Mon, 8 Jan 2001 14:11:32 -0500, "Bourque, Jason" <email@hidden> asked,
>
I am trying to set a multitude of properties via a load script command that
>
has a bunch of dialogs for the user.
Properties of what? The script object you load is, I presume, setting its own
properties as a result of the dialogs with the user. Are you trying to then put
those properties into properties of the containing script, or are you trying to
set properties of an application object (like Finder windows, for example)?
>
My problem is that the handlers called are unable to set properties in the
>
running script.
And rightfully so. This is fundamental to the concept of modular design. In
the philosophy behind the design of computer languages, we have the idea of
modular components. These modular components, of which script object are
AppleScript's implementation, have well-defined interfaces (their handlers and
properties). They don't interact with other things in the environment like
properties and handlers of the rest of the script, unless you pass one of those
things in as a parameter. This allows the programmer or scripter to define what
a script object does, and then use it with full visibility of all its interface.
No sneaking around inside the script and changing other variables.
If I write the command
set v1 to foo(a,b,c)
I can see that v1, a, b, and c are involved. I don't want d, e, f, and v2 to be
involved also.
>
Is there another way to set the properties without using the result command?
>
>
>
set loadedScript to load script filePath
>
>
mySetting() of loadedScript
>
set theProperty to the result
You can make the statement simply
set theProperty to mySetting() of loadedScript
or
tell loadedScript to set theProperty to mySetting()
But I think it would be better design to simply say that "loadedScript" is in
charge of these properties. Don't pass them out to set to some other variables.
Just keep them in loadedScript and get them from there. That's the true use of
AppleScript's object-oriented features: the script object is an abstraction of
data and function. It combines properties and handlers into an object that
abstracts away all the grubby details of the implementation of the abstract
object.
You may be saying "color of userPreference" instead of just "preferedColor", but
if you name your object properties and the object itself right, you get a much
more readable name for the thing, and all the benefits of object abstraction and
modularity.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden