Re: Weird problem with a script?
Re: Weird problem with a script?
- Subject: Re: Weird problem with a script?
- From: "Stockly, Ed" <email@hidden>
- Date: Fri, 11 Mar 2016 18:36:44 +0000
- Thread-topic: Weird problem with a script?
You might try coercing myCustomValue to text. (see below)
I'm not sure what this "andPropertyName:(myCustomPropertyName)" is doing.
BTW, if you're doing a lot of appleScripting you can step through each
line of your script and monitor variables and their class as they change
using ScriptDebugger. Much simpler than using the log.
--------------
--set myCustomValue to my
getWordCustomDocumentPropertyWithDocumentID:(myDocumentID)
andPropertyName:(myCustomPropertyName)—uncomment this line
set myCustomValue to "HIGH" as text — comment out this line
--
set myCustomValue to myCustomValue as text —
--set myCustomInitialValue to myCustomValue
copy myCustomValue to myCustomInitialValue
log ">>>>> myCustomValue: " & myCustomValue & "<<<<<"
log ">>>>> myCustomInitialValue: " & myCustomInitialValue & "<<<<<"
if myCustomValue is equal to "HIGH" then
--- I’ve tried using instead of “is equal to” and both always fail?
log "Setting myCustomValue to LOW"
set myCustomValue to "LOW"
else
log "Setting myCustomValue to HIGH"
set myCustomValue to "HIGH"
end if
log ">>>>> myCustomValue: " & myCustomValue & "<<<<<"
log ">>>>> myCustomInitialValue: " & myCustomInitialValue & "<<<<<"
On 3/11/16, 8:31 AM,
"applescript-users-bounces+ed.stockly=email@hidden on
behalf of Dave"
<applescript-users-bounces+ed.stockly=email@hidden on
behalf of email@hidden> wrote:
>Hi All,
>
>Can anyone tell what’s wrong with this code snippet?
>
>If “if” statement is ALWAYS failing, see log output.
>
>I’m reading the Value in myCustomValue from a MS Word Custom Document
>Property if that makes any difference? I return it as a string, as in:
>
>return myValue as string if the
>getWordCustomDocumentPropertyWithDocumentID handler.
>
>------------------------
>
>
>set myCustomValue to my
>getWordCustomDocumentPropertyWithDocumentID:(myDocumentID)
>andPropertyName:(myCustomPropertyName)
>
>--set myCustomInitialValue to myCustomValue
>copy myCustomValue to myCustomInitialValue
>
>log ">>>>> myCustomValue: " & myCustomValue & "<<<<<"
>log ">>>>> myCustomInitialValue: " & myCustomInitialValue & "<<<<<"
>
>if myCustomValue is equal to "HIGH” then — I’ve tried using “=“ instead
>of “is equal to” and both always fail?
> log "Setting myCustomValue to LOW"
> set myCustomValue to "LOW"
>else
> log "Setting myCustomValue to HIGH"
> set myCustomValue to "HIGH"
>end if
>
>log ">>>>> myCustomValue: " & myCustomValue & "<<<<<"
>log ">>>>> myCustomInitialValue: " & myCustomInitialValue & "<<<<<“
>
>Log Output:
>
>(*>>>>> myCustomValue: HIGH<<<<<*)
>(*>>>>> myCustomInitialValue: HIGH<<<<<*)
>(*Setting myCustomValue to HIGH*)
>(*>>>>> myCustomValue: HIGH<<<<<*)
>(*>>>>> myCustomInitialValue: HIGH<<<<<*)
>tell application "Script Editor"
> display dialog "STOP"
>Result:
>error "User canceled." number -128
>
>All the Best
>Dave
>
>
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>AppleScript-Users mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>imes.com
>Archives: http://lists.apple.com/archives/applescript-users
>
>This email sent to email@hidden
_______________________________________________
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