mort mort - 2 months ago 19
AppleScript Question

Error in workflow when launched from calendar event

I am making a calendar alarm workflow that pulls text from a website and compares it to the text stored in a local file once a day. I store the text in the two variables "newText" and "oldText" in Automator. With the following apple-script code I try to access and compare these two variables. If they are equal, I want the break out of the workflow.



on run {input, parameters}

set newText to value of variable "newText" of front workflow
set oldText to value of variable "oldText" of front workflow

if newText is equal to oldText then
tell me to quit
end if

end run


The workflow works fine when run from automator, but when launched from the calendar-event I get the following error (second line):


Syntax Error, Expected end of line, etc. but found “"”.


All suggestions appreciated!

Answer

Outside of Automator you must wrap the related code in an application tell block

tell application "Automator"
    set newText to value of variable "newText" of front workflow
    set oldText to value of variable "oldText" of front workflow
end tell
if newText is equal to oldText then
    tell me to quit
end if