title: Issue with applescript function
body: <p>I'm trying to the function replaceChars in the below script but getting the following error:</p>
  
  <pre><code>error "Finder got an error: Can’t continue replace_chars." number -1708
  </code></pre>
  
  <p>The intention is to add the script to finder as a button so that I can simply click it to copy the path to my clipboard.  I'm adding file://localhost/ so that the link can then be used when shared with users by email as a direct link to a folder on the local network.  If possible I would also like to add to clipboard the same for Windows machines.</p>
  
  <p>If you could offer any guidance as to the task above it would be much appreciated, this is my first attempt at programming with applescript so I'm not that knowledgable of how things are done.</p>
  
  <p>Heres the code:</p>
  
  <pre><code>on appIsRunning(appName)
      tell application "System Events"
          set isRunning to ((application processes whose (name is equal to appName)) count)
      end tell
  
      if isRunning is greater than 0 then
          return true
      else
          return false
      end if
  end appIsRunning
  
  on replace_chars(this_text, search_string, replacement_string)
      set AppleScript's text item delimiters to the search_string
      set the item_list to every text item of this_text
      set AppleScript's text item delimiters to the replacement_string
      set this_text to the item_list as string
      set AppleScript's text item delimiters to ""
      return this_text
  end replace_chars
  
  if appIsRunning("Finder") then
      tell application "Finder"
          set thePath to "file://localhost/" as text
          set theTarget to (target of front Finder window) as text
          set the clipboard to thePath &amp; replace_chars(theTarget, ":", "/") as text
      end tell
  end if
  </code></pre>