Hi,
I created a flow using Applescript to do a simple search and replace in an html file with TextWrangler. The search and replace works fine, but the script ends in error with the message:
'"path-to-file.html" doesn't understand the send to single message'. Same error appears with alias and POSIX paths. Below is the script I've used (replace string left out):
on jobarrived( s, j )
tell application "Switch_Service"
set search_document to path of j
set jobPath to POSIX path of search_document
tell me
replaceText(search_string, replacement_text, search_document)
end tell
send to single jobPath -- neither does "send to single search_document" work
end tell
end jobarrived
on replaceText(search_string, replacement_text, this_document)
tell application "TextWrangler"
activate
open this_document opening in new_window
tell window 1
replace search_string using replacement_text options {search mode:literal, starting at top:true}
close saving yes
end tell
end tell
end replaceText
What is wrong with my script? I found only one example of a script in Applescript and there the send to functions were all "send to data"'s.
Any help appreciated,
Patrik
applescript doesn't understand the send to single message
applescript doesn't understand the send to single message
The correct syntax for send to single is:
send to single j path search_document
But you also need to do another thing: search_string and replacement_text get no values! Add two properties to the script so you can fill them in in your script element, either as an inline value or as a single-line text with variables, depending on your needs. You can set all the possible editors you need in Switch Scripter.
To access the values in your script:
set search_string to value of switch property "SearchString" of s
set replacement_text to value of switch property "ReplaceString" of s
of course, inside the Switch part and with the tag name that you have defined as being a property of the script.
Freddy
send to single j path search_document
But you also need to do another thing: search_string and replacement_text get no values! Add two properties to the script so you can fill them in in your script element, either as an inline value or as a single-line text with variables, depending on your needs. You can set all the possible editors you need in Switch Scripter.
To access the values in your script:
set search_string to value of switch property "SearchString" of s
set replacement_text to value of switch property "ReplaceString" of s
of course, inside the Switch part and with the tag name that you have defined as being a property of the script.
Freddy
applescript doesn't understand the send to single message
Thanks! I just wanted to spare you from the long strings I have the script to search and replace, which I have inline so I replaced them with "search_string" and "replacement_text". So everything works now, thanks!
--patrik
--patrik