0

I am getting the following syntax error while creating new Service on Mac while using below script, I have attached screenshot as well:

"Can’t get every text item."

on searchReplace(theText, SearchString, ReplaceString)
        set OldDelims to AppleScript's text item delimiters
        set AppleScript's text item delimiters to SearchString
        set newText to text items of theText
        set AppleScript's text item delimiters to ReplaceString
        set newText to newText as text
        set AppleScript's text item delimiters to OldDelims
        return newText
end searchReplace


 on run {input, parameters}
        set myClip to the input
        set mytext to searchReplace(myClip, "<", "")
        set mytext to searchReplace(mytext, ">.", "")
        set mytext to searchReplace(mytext, ">", "")
        set mytext to searchReplace(mytext, "smb://", "\\\\")
        set findIt to "/"
        set replaceIt to "\\"
        set mylocation to searchReplace(mytext, findIt, replaceIt)
        return mylocation
end run


enter image description here

  • Where/how is the Automator service receiving its input? You need to include a screenshot of your Automator service workflow, otherwise how do you expect us to debug the error? How many items can be in input? If more then one, then your code as written will fail. If input is just one item, then use set myClip to the input as text, not what you currently have set myClip to the input. – user3439894 Jul 17 at 17:38
  • What does the input (selected text) look like? Please add an example of the selected text and its expected return. Also, the service workflow as show, even if it works without error will actually do nothing because what's returned is not returned to any additional actions or processed in any manner besides the searchReplace handler. – user3439894 Jul 18 at 11:18

You must log in to answer this question.

Browse other questions tagged .