Re: Script Objects - help please!!
Re: Script Objects - help please!!
- Subject: Re: Script Objects - help please!!
- From: has <email@hidden>
- Date: Fri, 10 Jun 2005 23:00:07 +0100
Simon Forster wrote:
>script renderQueue
> property renderClient : {}
> ....
>end
>
>I load the external library file [...] and then copy the render queue script to the end of a list x times, calling the script object's init method as I go:
>
>set theList to {}
>repeat...
> copy renderQueue of myLib to end of theList
> tell last item of theList to init(someData)
>end
General point: I don't recommend using copy to duplicate nested script objects as it's far too greedy. It doesn't just duplicate the object and its contents, it also duplicates its parent as well (in this case your entire library script), consuming considerable resources and screwing up shared state (i.e. any mutable properties in the library script which your script objects rely on). (Not that duplicating some parent objects isn't desirable; just not the whole damn lot of them.) Use a constructor function instead:
on makeRenderQueue(someData)
script
...
end script
end makeRenderQueue
set theList to {}
repeat...
set end of theList to makeRenderQueue(someData)
end
>While the subsequent references do not appear to be pointers to the same object, when I call the object's getXX() method the results are identical for both objects - the someData supplied to the last object's init method.
>[...]
>Am I screwing up by having the script object in an external library file?
Nope. This is one of the saner, more reliable parts of AppleScript. So unless someone's broken it since I last used it then your problem lies elsewhere. Unfortunately, you don't provide enough code to recreate your bug which kinda makes it difficult to diagnose. The only thing I can think of that'd cause the symptoms you describe is if there's AppleScript references used somewhere in your renderQueue object, as they're the one type of mutable AppleScript object that the 'copy' statement does not duplicate. Example:
script foo
property X : "foo"
property Y : a reference to X
end script
copy foo to bar
display dialog foo's Y --> "foo"
display dialog bar's Y --> "foo"
set bar's X to "bar"
display dialog foo's Y --> "foo"
display dialog bar's Y --> "foo" (!)
return {foo's Y, bar's Y} --> {X of «script foo», X of «script foo»}
Note how the reference object in bar's Y property still points to foo's X property after the copy operation.
If it's not that, you'll need to provide additional code so folk can reproduce your bug themselves.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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