4D v13.4

Operators

Home

 
4D v13.4
Operators

Operators  


 

 

Operators are symbols used to specify operations performed between expressions. They:

  • Perform calculations on numbers, dates, and times.
  • Perform string operations, Boolean operations on logical expressions, and specialized operations on pictures.
  • Combine simple expressions to generate new expressions.

The order in which an expression is evaluated is called precedence. 4D has a strict left-to-right precedence, in which algebraic order is not observed. For example:

 3+4*5

returns 35, because the expression is evaluated as 3 + 4, yielding 7, which is then multiplied by 5, with the final result of 35.

To override the left-to-right precedence, you MUST use parentheses. For example:

 3+(4*5)

returns 23 because the expression (4 * 5) is evaluated first, because of the parentheses. The result is 20, which is then added to 3 for the final result of 23.

Parentheses can be nested inside other sets of parentheses. Be sure that each left parenthesis has a matching right parenthesis to ensure proper evaluation of expressions. Lack of, or incorrect use of parentheses can cause unexpected results or invalid expressions. Furthermore, if you intend to compile your applications, you must have matching parentheses—the compiler detects a missing parenthesis as a syntax error.

You MUST distinguish the assignment operator := from the other operators. Rather than combining expressions into a new one, the assignment operator copies the value of the expression to the right of the assignment operator into the variable or field to the left of the operator. For example, the following line places the value 4 (the number of characters in the word Acme) into the variable named MyVar. MyVar is then typed as a numeric value.
MyVar := Length ("Acme")

Important: Do NOT confuse the assignment operator := with the equality comparison operator =.

The other operators provided by the 4D language are described in the following sections:

See the section String Operators.

See the section Numeric Operators.

See the section Date Operators.

See the section Time Operators.

See the section Comparison Operators.

See the section Logical Operators.

See the section Picture Operators.

See the section Bitwise Operators.

 
PROPERTIES 

Product: 4D
Theme: Operators

 
SEE ALSO 

Constants
Data Types
Identifiers
QUERY
QUERY BY FORMULA
QUERY SELECTION BY FORMULA