Just starting to apple script here and looking for some help.. I'm trying to create an IF statement using apple script but just cant seem to get it to work.
The plan is to send a imessage and attach a file if the script is executed with the file specified, if not, just send the text.
For Example:
Text only Example: imessage 5555555555 "hi" "NoAttachment"
Text + File Example: imessage 5555555555 "hi" "/location/test.jpg"
This is the script I'm using: https://gist.github.com/aktau/8958054
But with the following changed at the bottom:
on run {targetBuddyPhone, targetMessage, targetFile}
tell application "Messages"
-- if Messages.app was not running, launch it
set wasRunning to true
if it is not running then
set wasRunning to false
launch
close window 1
my waitUntilRunning("Messages", 1)
close window 1
end if
-- send the message
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
set targetFileSend to targetFile
if targetFileSend = "NoAttachment" then
send targetMessage to targetBuddy
else
send POSIX targetFileSend to targetBuddy
send targetMessage to targetBuddy
end if
-- if the app was not running, close the window
if not wasRunning
close window 1
end if
end tell
end run
When I execute the script I get: 1635:1649: syntax error: Expected end of line but found identifier. (-2741)
What am I doing wrong here? Instead of using the trigger "NoAttachment" would a nullvalue be better to use?
Any help is much appreciated!
send POSIX file targetFileSend to targetBuddy- wch1zpink