&, + (concatenation operator)

Usage

-- Lingo syntax 
expression1 & expression2 
 
// JavaScript syntax 
expression1 + expression2

Description

String operator; performs a string concatenation of two expressions. If either expression1 or expression2 is a number, it is first converted to a string. The resulting expression is a string.

This is a string operator with a precedence level of 2.

Lingo allows you to use some commands and functions that take only one argument without parentheses surrounding the argument. When an argument phrase includes an operator, Lingo interprets only the first argument as part of the function, which may confuse Lingo.

Avoid this problem by placing parentheses around the entire phrase that includes an operator. The parentheses clear up Lingo’s confusion by changing the precedence by which Lingo deals with the operator, causing Lingo to treat the two parts of the argument as one complete argument.

Example

This statement concatenates the strings “abra” and “cadabra” and displays the resulting string in the Message window:

-- Lingo syntax 
put("abra" & "cadabra") 
 
// JavaScript syntax 
put("abra" + "cadabra");

The result is the string “abracadabra”.

This statement concatenates the strings “$” and the content of the price variable and then assigns the concatenated string to the Price field cast member:

-- Lingo syntax 
member("Price").text = "$" & price 
 
// JavaScript syntax 
member("Price").text = "$" + price;