AppleScript string tip: How to concatenate strings

AppleScript string FAQ: How do I concatenate (merge) strings in AppleScript?

Fortunately string concatenation in AppleScript is pretty easy (if not a little different). To concatenate strings in AppleScript just use the ampersand (&) operator.

Here are a few AppleScript string concatenation examples, with a dialog thrown in so you can see the result:

set myVar to "Al " & "was " & "here."
display dialog myVar

More AppleScript string concatenation

Here's a slightly more complicated AppleScript string concatenation example, using variables for each string:

set a to "Al "
set b to "was "
set c to "here."
set myVar to a & b & c
display dialog myVar

To test these, just copy them into your ScriptEditor, and press the Run button. (The ScriptEditor is in the Applications::AppleScript folder.)

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.