4D v16.3

Operators

Home

 
4D v16.3
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 String Operators section.

See the Numeric Operators section.

See the Date Operators section.

See the Time Operators section.

See the Comparison Operators section.

See the Logical Operators section.

See the Picture Operators section.

See the Bitwise Operators section.



See also 

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

 
PROPERTIES 

Product: 4D
Theme: Operators

 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)