Operators

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 6.0


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.

Precedence

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.

The Assignment Operator

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:

String Operators

See the section String Operators.

Numeric Operators

See the section Numeric Operators.

Date Operators

See the section Date Operators.

Time Operators

See the section Time Operators.

Comparison Operators

See the section Comparison Operators.

Logical Operators

See the section Logical Operators.

Picture Operators

See the section Picture Operators.

Bitwise Operators

See the section Bitwise Operators.

See Also

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


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next