2

I would like to make a Google search with an AppleScript. The code looks like this:

set search to text returned of (display dialog "Google Search" buttons {"OK"} default answer {""})
open location ("https://www.google.de/#q=" & search)

The problem is, how can I change the spaces to a +?

3

Here's a subroutine for replacing characters:

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

Source: http://www.macosxautomation.com/applescript/sbrt/sbrt-06.html

Between those two lines of AppleScript, insert the following:

set search to replace_chars(search," ","+")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .