Re: Script objects 'as string' in an identifiable way
Re: Script objects 'as string' in an identifiable way
- Subject: Re: Script objects 'as string' in an identifiable way
- From: email@hidden
- Date: Mon, 5 Nov 2001 09:15:16 -0500
On Mon, 5 Nov 2001 01:15:32 +0100, Brennan <email@hidden> asked,
>
I'm in a position where it would be useful for me to distinguish one script
>
object from another (while debugging) in the result window.
>
>
Unfortunately they all appear as <<script CLASSNAME>>, with no further
>
identifying features.
Its not really a class name. What appears after the <<script is the name of
that particular script. A copy won't have that name.
Specifically, on my machine (AS 1.5.5 and Script Editor 1.5.5), a script defined
as
script foo
-- whatever
end script
appears as <<script foo>> in the result window. But if the script is defined
dynamically (either by copying the script above: "copy foo to bar", or by
returning the script from a constructor function after being created
anonymously,
to makefoo()
script
-- whatever
end script
end makefoo
In that case, you just get <<script>> as the result.
>
In Lingo (Director) these kinds of reference would go to string as
>
>
<offspring "classname" 2 7d65ab3>
>
>
... providing the reference count (in this case 2) and the memory location of
>
the object as well as the class. This is very useful in finding out at a
glance
>
whether one instance is different from another one of the same type.
(Basically
>
if the memory location is the same, it's the same object).
You could just assign the script object a property, like 'name', and display
'name of myScriptObject' in the result window. But that won't differentiate
between copies of the same object, unless you give each object a unique name or
serial number when you create it. That would mean you would need to create it
with a constructor function, or manually fiddle with the properties when you
make a copy, like
script foo
name: "Foo"
instance : 1
on whatever()
--whatever
end whatever
end script
copy foo to bar
tell bar to set its instance to its instance + 1
But, you may not care about different instances.
--
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