Hi Again,

How do I pass an NSDictionary that is returned from an ApplesScript handler to 
another handler?

I get an error in setWordStandardDocumentDictionary running this code:

        set myDocumentID to (theStandardDocumentDictionary's 
objectForKey:"kDocumentID")
        set myStandardPropertyArray to (theStandardDocumentDictionary's 
allKeys)                        —Error Here

error "Can’t get allKeys of «class ocid» id «data 
optr0000000070A1240080630000»." number -1728 from allKeys of «class ocid» id 
«data optr0000000070A1240080630000»

statement. Yet the statement before returns what I was expecting?

Thanks for the Help.

All the Best
Dave

-------------

on getWordStandardDocumentDictionaryWithDocumentID:(theDocumentID as string)
        --say "getWordStandardDocumentDictionaryWithDocumentID:" --& 
theDocumentID
        
        set myDocument to my getWordDocumentWithDocumentID:(theDocumentID)
        
        tell application id "com.microsoft.Word"
                set myTranslationDictionary to 
pWordStandardDocumentPropertiesKeyTranslationDictionary of me
                
                set myStandardPropertiesDictionary to current application's 
NSMutableDictionary's alloc()'s init()
                set myStandardPropertyArray to (document properties of 
myDocument)
                
                repeat with myStandardProperty in myStandardPropertyArray
                        set myPropertyName to the name of myStandardProperty
                        set myPropertyValue to the value of myStandardProperty
                        if myPropertyValue = missing value then
                                set myPropertyValue to ""
                        end if
                        
                        set myTranslatedPropertyName to 
(myTranslationDictionary's objectForKey:myPropertyName) as string
                        if myTranslatedPropertyName = missing value then next
                        
                        (myStandardPropertiesDictionary's 
setObject:myPropertyValue forKey:myTranslatedPropertyName)
                end repeat
                
                set kDocumentID of myStandardPropertiesDictionary to 
theDocumentID
        end tell
        
        return myStandardPropertiesDictionary 
end getWordStandardDocumentDictionaryWithDocumentID:


on setWordStandardDocumentDictionary:(theStandardDocumentDictionary)
        --say "setWordStandardDocumentDictionary:"
        
        set myDocumentID to (theStandardDocumentDictionary's 
objectForKey:"kDocumentID")
        
        log "======" & myDocumentID
        set myStandardPropertyArray to (theStandardDocumentDictionary's allKeys)
        
        set myDocument to my getWordDocumentWithDocumentID:(myDocumentID)
        
        tell application id "com.microsoft.Word"
                set myTranslationDictionary to 
pWordStandardDocumentPropertiesKeyTranslationDictionary of me
                
                
                repeat with myPropertyName in myStandardPropertyArray
                        set myTranslatedPropertyName to 
(myTranslationDictionary's objectForKey:myPropertyName) as string
                        if myTranslatedPropertyName = missing value then next
                        
                        set myPropertyValue to (theStandardDocumentDictionary's 
objectForKey:myPropertyName)
                        if myPropertyValue = missing value then
                                set myPropertyValue to ""
                        end if
                        
                        set the value of (custom document properties of 
myDocument whose name is myTranslatedPropertyName) to thePropertyValue
                end repeat
                
                set kDocumentID of myStandardPropertiesDictionary to 
theDocumentID
        end tell
end setWordStandardDocumentDictionary:

on run
        
        tell application id "com.microsoft.Word"
                activate
        end tell
        
        get my setupKeyTranslationDictionary()
        
        set myDocumentID to my getWordActiveDocumentID()
        set myStandardPropertiesDictionary to my 
getWordStandardDocumentDictionaryWithDocumentID:(myDocumentID)
        (myStandardPropertiesDictionary's setObject:"Hello Cruel World!" 
forKey:"kDocumentKeywords")
        
        get my 
setWordStandardDocumentDictionary:(myStandardPropertiesDictionary)
        
        return myStandardPropertiesDictionary
end run


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to