Le 31 mai 2009 à 16:50, Deivy Marck Petrescu a écrit :
On May 31, 2009, at 10:34, Yvan KOENIG wrote:
tell application "AppleWorks 6" set props to (get properties of document 1) log class of props end tell
Yvan, the only problem is your insistence in using Apple Apps. AppleWorks is a subsidiary. TextEdit and Mail are Apple's. If you use another application it really returns what g is, a record:
tell application "BBEdit" set props to (get properties of document 1) log class of props end tell
Log: tell application "BBEdit" get properties of document 1 {id:1358154, container:current application, modified:true, modifiable:true, modification date:date "Sunday, May 31, 2009 10:42:17 AM", name:"untitled text", on disk:false, file:missing value, creator type:"R*ch", window:text window 1, container web site:missing value, text encoding:"Unicode™ (UTF-8, no BOM)", FTP Info:missing value, is FTP:false, line breaks:Unix, source language:"(none)", state modified:false, URL:missing value, contents:"" (*record*) <------ see! end tell
I'm not insisting on Apple apps behavior.
In your example with BBEdit, the returned record doesn't contain a class property so when you ask for the clas of the record, you get the class of the item {id:1358154, container:current application, modified:true, modifiable:true, modification date:date "Sunday, May 31, 2009 10:42:17 AM", name:"untitled text", on disk:false, creator type:"R*ch", window:text window 1, container web site:missing value, text encoding:"Unicode™ (UTF-8, no BOM)", FTP Info:missing value, line breaks:Unix, source language:"(none)", state modified:false, URL:missing value, contents:""}
BUT
when a class property is embedded in the record, it's this one which is logically returned.
AppleWorks returns this record:
{class:text document, (means that the record contains the properties of a Text Document item ) name:"sans titre", index:1, modified:true, title:"", margins:{72, 72, 72, 72}, author:"", version:"", keywords:"", category:"", description:"", autohyphenate:false, date format:numeric date, fractional character widths:false, smart quotes:true, side handles:true, polygon autoclose:false, show invisibles:false, smooth fonts:true, word wrap:true, autosmooth:true, shift constraint:45}
TextEdit returns this one:
{size:10.0, color:{0, 0, 0}, font:"Monaco", class:text} (means that the record contains the properties of a Text item )
I don't know if non-Apple apps returns a class property in their records. I know that Apple ones are doing and that the behavior is perfectly logical.
Priority is given to the properties embedded in the records.
So, when we ask for the class of aRecord,
when aRecord contains a class, we get this one : text for TextEdit, text document for AppleWorks. when aRecord doesn't contain a class, we get the class of the object aRecord itself: record for BBEdit.
Yvan KOENIG (from FRANCE dimanche 31 mai 2009 17:24:08) |