5.2. Review of Concatenation
You may recall that using the operator & between two strings has the effect of joining (or concatenating) the two strings together. So if you write
set message to "Hello, " & "Greg!"
you end up with the string "Hello, " followed by the string "Greg!" being assigned to message, just as if you had written
set message to "Hello, Greg!"
If a user's name is stored inside a variable called firstName, you could write the statement
set message to "Hello, " & firstName
to join the string "Hello, " with the string stored in firstName, and then assign the result to message.
You can perform multiple concatenation operations in a single statement. If the variable firstName contains the string "Allan", and the string lastName contains the string "Fiber", writing the following statement
set message to "Hello, " & firstName & " " & lastName & "!"
has the effect of concatenating the five indicated strings in succession and storing the result of "Hello, Allan Fiber!" in the variable message.
If you concatenate a string with something that's not a string...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access