Re: Weird problem with a script?
Re: Weird problem with a script?
- Subject: Re: Weird problem with a script?
- From: Nigel Garvey <email@hidden>
- Date: Tue, 15 Mar 2016 14:37:49 +0000
Dave wrote on Tue, 15 Mar 2016 12:04:42 +0000:
>> It would be more convincing as a fix if you understood why that fixed
it.
>
>I agree! I was at a customer site and just needed a quick fix which the
>“starts with” helped with, but you’re right, I need to understand the
>underlying cause. I *think* it’s because a new line character is being
>added to the value. Here are the missing methods:
[snip]
>on getWordCustomDocumentPropertyWithDocumentID:(theDocumentID as string)
>andPropertyName:(thePropertyName as string)
> --say "getWordCustomDocumentPropertyWithDocumentID:"
>
> set myDocument to my getWordDocumentWithDocumentID:theDocumentID
>
> tell application id "com.microsoft.Word"
> set myValue to the value of (custom document properties of myDocument
>whose name is thePropertyName)
> end tell
>
> if myValue is not equal to missing value then
> return myValue
> end if
>
> get my makeNewWordCustomDocumentPropertyWithDocumentID:(theDocumentID)
>andPropertyName:(thePropertyName) andPropertyValue:("*DEFAULT*")
>
> tell application id "com.microsoft.Word"
> set myValue to the value of (custom document properties of myDocument
>whose name is thePropertyName)
> end tell
>
> return myValue as string
>end getWordCustomDocumentPropertyWithDocumentID:andPropertyName:
Hmm. Well my theory about the value being a reference from a repeat
appears not to be true. Yvan's theory about it being a list could be
true if 'myValue' is returned at the 'missing value' check, but not if
it's returned at the end of the handler, where it's explicitly coerced
to text.
As Yvan said, you should put in a check to test the class of the result
the handler returns. If it is in fact text, you could also test the 'id'
of the text to see the Unicode numbers of the characters it contains.
I'm not familiar with Microsoft Word syntax, so I can't guess what's
returned by the Word code. If it's correct as written, I'd expect 'value
of (custom document properties of myDocument whose name is
thePropertyName)' to mean the same as 'value of (every custom document
property of myDocument whose name is thePropertyName)', in which case
I'd also expect the result to be a list. If the code's incorrect, the
correct version may be something like:
value of (first custom document property of myDocument whose name is thePropertyName)
… or …
value of (custom document property thePropertyName of myDocument)
Both of these are just guesses though.
NG
_______________________________________________
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