Tuesday, September 19, 2017

#1 2005-10-21 06:03:21 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How do I concatenate text in AppleScript?

You use the & operator. Eg:

Applescript:

set x to "a" & "b" --> "ab"

You can also concatenate compatible things (that is, stuff which can be coerced to text). Eg:

Applescript:

set x to "a" & {"b", 5} --> "ab5"

You concatenated here (or "joined") a text, and a list containing a text item and an integer.

Note that the "&" operator will take as "chief" the left member in the operation. If it is text, it will try to coerce the rest of the members involved to text. So, this example will have a different behaviour, as the left-most member is not text:

Applescript:

set x to 5 & "a" --> {5, "a"}

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)