introspection questions
introspection questions
- Subject: introspection questions
- From: "Nathan Herring" <email@hidden>
- Date: Thu, 30 Jan 2003 19:37:06 -0800
I. properties/handlers of an generic script object?
How can I enumerate through the properties and/or handlers of a generic
script object at runtime? Being able to get a reference to them would be
good. Being able to get their names as well would be better.
If I can constrain these generic object to implement a particular subset =
of
common handers/properties, can I get this to work?=20
I know I could manually create a script object like:
script a
property x : 1
property y : 2
property props : {{"x", a reference to x}, {"y", a reference to y}}
end script
set aScript to a
and then be able to use props of aScript (independing of what script =
aScript
is set to) to read off names and properties (albeit unable to change =
their
values), and always make sure props was in sync with a and then god =
forbid
one of these scripts uses the parent property.
Do I have to write an osax to do this for script objects that are not of =
the
nature of the example?
II. properties/handlers of a generic non-script object?
If you exclude value-type objects (whose class is data, text, integer, =
list)
and applescript objects (whose class is script, handler), what is left =
are
osax or application defined objects. If I have a generic non-script =
object,
is there a way to enumerate through the properties and/or handlers of =
that
object at runtime? Again, being able to get a reference to them, and =
getting
names as well would be better.
Is there a way to get at an object's "dictionary" at runtime? or do I =
have
to write an osax to figure out what dictionary supports that object and =
then
what that object says that it should support (not that it necessarily =
does,
nor that the dictionary list is necessarily complete).=20
III. setting a property through a reference?
if I have a variable set to a reference to a property of an object, how =
can
I set that property? e.g.,
script a
property x : 1
end script
set aRef to a reference to x of a
set aRef to 2 -- this sets the variable aRef to 2, leaving x of a alone
set aRef to a reference to a
set x of aRef to 2 -- this sets x of a, but I had to know that it was =
named
x at compile time
IV. properties, handlers, and scripts by name=20
I want to be able to refer to handlers, scripts, and properties using a
string variable. e.g.,
property "foo"
handler "bar"
script "baz"
How can I do this?=20
Say, for example I have an object anObject, and I want to get or set the
property that was passed in to my handler as a string in propertyName. =
It
would seem I'd have to write out into a temp file something like:
"on getIt(anObject, anApp)
tell anApp to return " & propertyName & " of anObject
end
on setIt(anObject, anApp, aValue)
tell anApp to set " & propertyName & " of anObject to aValue
end"
then load that file using load script and calling the newly formed
getIt(anObject, it) and setIt(anObject, it, whateverValue), which would =
bind
to the correct item.
I could do the same thing for scripts and handlers, but it seems REALLY
awkward. Is there another way around this?
Sorry if these questions are asked and answered, but a (rather) brief =
scan
of the list archive didn't seem to give answers to these questions.
Thanks,
nh
[demime 0.98b removed an attachment of type application/ms-tnef which had a name of winmail.dat]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.