Accessing Child Elements of Property List Records or Lists
Accessing Child Elements of Property List Records or Lists
- Subject: Accessing Child Elements of Property List Records or Lists
- From: Grant Erickson <email@hidden>
- Date: Sat, 15 Aug 2009 11:07:30 -0700
- Organization: Nuovation System Designs, LLC
- Thread-topic: Accessing Child Elements of Property List Records or Lists
I am attempting to use the Property List Suite of the System Events
dictionary to customize window views using a property list of attributes for
those customizations (bounds, view style, view options, etc.).
I seem to be able to successfully access all the top-level items from the
property list using:
on GetObjectForKeyInFile(inFile, inKey)
tell application "System Events"
tell property list file inFile
tell contents
return value of property list item inKey
end tell
end tell
end tell
end GetObjectForKeyInFile
with examples such as:
set theBoolean to my GetObjectForKeyInFile(thePlist, "Tool Bar")
if theBoolean is not {} then
set toolbar visible to theBoolean
end if
However, when retrieve a dictionary (record) and then get a child of them
it:
on GetObjectForKeyInRecord(inRecord, inKey)
tell application "System Events"
tell property list item inRecord
return value of property list item inKey
end tell
end tell
end GetObjectForKeyInRecord
with an example such as:
set theBounds to my GetObjectForKeyInFile(thePlist, "Bounds")
set theHeight to my GetObjectForKeyInRecord(theBounds, "Height")
I get an error of:
System Events got an error: CanĀ¹t get property list item {|X|:10,
|Y|:10, |Width|:480, |Height|:320}. Invalid index. (-1719)
Any insights? I am certain there is some "of..." or "as..." syntax I am
missing here; however, various combinations of "as record", etc. have proved
fruitless.
Regards,
Grant
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden