I was writing some scripts for TextEdit and came upon this which I find a problem
Trying this script (one line):
tell application "TextEdit" to tell document 1 to tell its text to return properties of attribute run of word 1
I get this:
-->{{class:text, color:{0, 0, 0}, size:14.0, font:"Verdana-Bold"}}
Notice that this is a list not a record. To get the record I have to refer to item 1 of this list.
I did not remember any other app returning properties like this, so I checked "Mail" to see what it returns for the following script(one line):
tell application "Mail" to tell message 1 of mailbox 1 of account 1 to set pt to (get its properties)
I get this:
-->{content:"If you can't see the images below", was replied to:false, message id:"xxx", reply to:"xxx" , sender:"xxx", mailbox:mailbox "INBOX" of account "deivy" of application "Mail", subject:"xxx", read status:true, was redirected:false, date received:date "Friday, May 29, 2009 9:46:54 AM", source:"Return-Path: ", date sent:date "Friday, May 29, 2009 9:19:24 AM", floating:false, all headers:"From: ", id:11477, was forwarded:false, class:message, message size:10651, deleted status:false, background color:none, junk mail status:false}
Where xxx substitutes the real thing! As I suspected properties should have returned a record not a list.
The propblem is, if I try to get the class of pt (properties) it returns "message"!!!
Even if you try the following after the one line script above:
get class of (pt as record)
--> message
This is a problem. Now pt must be used within a "Mail" tell block to make sense.
If one tries the following after the above script outside the tell block:
was replied to of pt
one gets an error. That shouldn't be!
So I tried a similar script with a non Apple application, BBEdit.
The following script:
tell application "BBEdit" to tell document 1 to tell its text to set pt to properties
class of pt
---> record
The script returns pt as record and it recognizes it as record.
I think this is a major bug. I do not remember it being discussed here.
Am I alone in my impression?
This should be corrected asap!