An expression is a string that defines a formula or criteria, evaluated at runtime. It can be a combination of variables, constants, strings, dates, and operators/functions. For instance "1000 format ``" gets 1,000.00 for US format, while 1.000,00 is displayed for German format.
![]() |
Expressions allow you to dynamically assign or modify the content displayed in a cell based on specific conditions or criteria. They enable you to evaluate the data in a cell and determine the appropriate value or caption to be shown, applying predefined logic or transformations. These expressions are useful for defining new captions, performing calculations, or adjusting content according to different conditions. Exontrol's eXPression component provides a syntax editor that helps you define, view, edit, and evaluate expressions. It allows you to easily check the correctness of your expressions and test their results with different values, making it an ideal tool for configuring applications and ensuring the proper execution of expressions.
Usage examples:
The general-expression supports:
The following is a detailed explanation of all the predefined constants, operators, and functions supported by the general expression.
The constants can be represented as:
The predefined constants are:
The supported binary arithmetic operators are:
The supported unary boolean operators are:
The supported binary boolean operators are:
The supported binary boolean operators, all these with the same priority 0, are :
The supported binary range operators, all these with the same priority 5, are :
The supported binary operators, all these with the same priority 0, are :
:= (Store operator), stores the result of expression to variable. The syntax for := operator is
variable := expression
where variable is a integer between 0 and 9. You can use the =: operator to restore any stored variable ( please make the difference between := and =: ). For instance, (0:=dbl(value)) = 0 ? "zero" : =:0, stores the value converted to double, and prints zero if it is 0, else the converted number. Please pay attention that the := and =: are two distinct operators, the first for storing the result into a variable, while the second for restoring the variable
=: (Restore operator), restores the giving variable ( previously saved using the store operator ). The syntax for =: operator is
=: variable
where variable is a integer between 0 and 9. You can use the := operator to store the value of any expression ( please make the difference between := and =: ). For instance, (0:=dbl(value)) = 0 ? "zero" : =:0, stores the value converted to double, and prints zero if it is 0, else the converted number. Please pay attention that the := and =: are two distinct operators, the first for storing the result into a variable, while the second for restoring the variable
The supported conversion operators are:
The bitwise operators for numbers are:
The operators for numbers are:
A) The 'flags' parameter for the format operator can accept a list of values separated by the | character (e.g., 'NumDigits|DecimalSep|Grouping|ThousandSep|NegativeOrder|LeadingZero'). These flags allow customization of numeric formatting (e.g. 1,230.00), with each representing a specific setting:
- NumDigits - specifies the number of fractional digits, If the flag is missing, the field "No. of digits after decimal" from "Regional and Language Options" is using.
- DecimalSep - specifies the decimal separator. If the flag is missing, the field "Decimal symbol" from "Regional and Language Options" is using.
- Grouping - indicates the number of digits in each group of numbers to the left of the decimal separator. Values in the range 0 through 9 and 32 are valid. The most significant grouping digit indicates the number of digits in the least significant group immediately to the left of the decimal separator. Each subsequent grouping digit indicates the next significant group of digits to the left of the previous group. If the last value supplied is not 0, the remaining groups repeat the last group. Typical examples of settings for this member are: 0 to group digits as in 123456789.00; 3 to group digits as in 123,456,789.00; and 32 to group digits as in 12,34,56,789.00. If the flag is missing, the field "Digit grouping" from "Regional and Language Options" indicates the grouping flag.
- ThousandSep - specifies the thousand separator. If the flag is missing, the field "Digit grouping symbol" from "Regional and Language Options" is using.
- NegativeOrder - indicates the negative number mode. If the flag is missing, the field "Negative number format" from "Regional and Language Options" is using. The valid values are 0, 1, 2, 3 and 4 with the following meanings:
- 0 - Left parenthesis, number, right parenthesis; for example, (1.1)
- 1 - Negative sign, number; for example, -1.1
- 2 - Negative sign, space, number; for example, - 1.1
- 3 - Number, negative sign; for example, 1.1-
- 4 - Number, space, negative sign; for example, 1.1 -
- LeadingZero - indicates if leading zeros should be used in decimal fields. If the flag is missing, the field "Display leading zeros" from "Regional and Language Options" is using. The valid values are 0, 1
For instance:
- "1000 format ''", displays 1,000.00 for English format, while 1.000,00 is displayed for German format
- "1000 format '2|.|3|,'" always renders as 1,000.00, ignoring control panel settings
- "dbl(value) format `0`", converts the value to a number and displays with no decimals as 1,000 for English format, while 1.000 is displayed for German format
If formatting the number fails for some invalid parameter, the value is displayed with no formatting.
B) The 'flags' property for the format operator can follow the format '%'<flags>?<width>?<precision>?<length>?<specifier>, allowing numeric values to be formatted in either scientific notation (e.g., 1.23e+03) or fixed-point notation (e.g., 1230.00), as detailed below:
<format> ::= '%' <flags>? <width>? <precision>? <length>? <specifier>
<flags> ::= <flag>+
<flag> ::= '-' | '+' | ' ' | '#' | '0'
<width> ::= <number>
<precision> ::= '.' <number>
<length> ::= 'l' | 'L' | 'll' | 'z' | 'j' | 't'
<specifier> ::= 'e' | 'E' | 'f' | 'F'
<number> ::= <digit>+
<digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'where:
Flags
Flag Meaning - Left-justify the result within the field + Always show the sign (+ or -) Leave a space before positive numbers # Force decimal point (%f) or keep trailing zeros (%e) 0 Pad with leading zeros instead of spaces Width
Minimum number of characters for the output (e.g.,%8.2f
uses width 8).Precision
Specifies digits after the decimal point:
%f
: Number of digits after the decimal.
%e
: Digits after the decimal in scientific notation.Length
Optional and mainly affects how the argument is interpreted:
l
: double (default for %f, %e)
L
: long double (e.g., %Lf)
ll
,z
,j
,t
: primarily for integers (ll: Use for large integers (64-bit), , z: Use for sizes or array indices, j: Use for the largest integer type available, t: Use for pointer differences)Specifier
Specifier Meaning %f Fixed-point decimal notation %F Same as %f, but with uppercase INF and NAN %e Scientific notation (e.g., 1.23e+05) %E Same as %e, but with uppercase E For instance:
- "1000 format `%+.2E`", force sign, 2 decimals, uppercase scientific, such as "+1.00E+003"
- "dbl(value) format `%-14.4e`", left-aligned, width 14, 4 decimals in scientific, such as "1.0000e+003 "
- "value format `%.1E` replace `+00` with `+`", displays the number in scientific notation with 1 digit after the decimal and uppercase 'E' for the exponent, such as "1.0E+3"
- "value format `%f`", default fixed-point (6 decimal digits), such as "1000.000000"
- "value format `%8.2f`", Width 8, 2 decimal places, such as " 1000.00"
If number formatting fails due to an invalid parameter, the value is displayed according to the current regional settings.
The operators for strings are:
The following table defines the format types used to represent days:
- d, day of the month as digits without leading zeros for single-digit days (8)
- dd, day of the month as digits with leading zeros for single-digit days (08)
- ddd, abbreviated day of the week as specified by the current locale ("Mon" in English)
- dddd, day of the week as specified by the current locale ("Monday" in English)
The following table defines the format types used to represent months:
- M, month as digits without leading zeros for single-digit months (4)
- MM, month as digits with leading zeros for single-digit months (04)
- MMM, abbreviated month as specified by the current locale ("Nov" in English)
- MMMM, month as specified by the current locale ("November" for English)
The following table defines the format types used to represent years:
- y, year represented only by the last digit (3)
- yy, year represented only by the last two digits. A leading zero is added for single-digit years (03)
- yyy, year represented by a full four or five digits, depending on the calendar used. Thai Buddhist and Korean calendars have five-digit years. The "yyyy" pattern shows five digits for these two calendars, and four digits for all other supported calendars. Calendars that have single-digit or two-digit years, such as for the Japanese Emperor era, are represented differently. A single-digit year is represented with a leading zero, for example, "03". A two-digit year is represented with two digits, for example, "13". No additional leading zeros are displayed.
- yyyy, behaves identically to "yyyy"
The following table defines the format types used to represent era:
- g, period/era string formatted as specified by the CAL_SERASTRING value (ignored if there is no associated era or period string)
- gg, period/era string formatted as specified by the CAL_SERASTRING value (ignored if there is no associated era or period string)
The following table defines the format types used to represent hours:
- h, hours with no leading zero for single-digit hours; 12-hour clock
- hh, hours with leading zero for single-digit hours; 12-hour clock
- H, hours with no leading zero for single-digit hours; 24-hour clock
- HH, hours with leading zero for single-digit hours; 24-hour clock
The following table defines the format types used to represent minutes:
- m, minutes with no leading zero for single-digit minutes
- mm, minutes with leading zero for single-digit minutes
The following table defines the format types used to represent seconds:
- s, seconds with no leading zero for single-digit seconds
- ss, seconds with leading zero for single-digit seconds
The following table defines the format types used to represent time markers:
- t, one character time marker string, such as A or P
- tt, multi-character time marker string, such as AM or PM
The supported ternary operators, all these with the same priority 0, are :
expression ? true_part : false_part
It evaluates the expression and returns the true_part if the expression is true; otherwise, it returns the false_part. For example, %0 = 1 ? 'One' : (%0 = 2 ? 'Two' : 'not found') returns 'One' if the value is 1, 'Two' if the value is 2, and 'not found' for any other value. The case statement is an n-ary equivalent.
The supported n-ary operators are (with priority 5):
expression array (c1,c2,c3,...cn)
where c1, c2, ..., are constant elements, which could be numeric, date, or string expressions. For instance, the expression month(value)-1 array ('J','F','M','A','M','Jun','J','A','S','O','N','D') is equivalent to the following case expression: month(value)-1 case (default:''; 0:'J';1:'F';2:'M';3:'A';4:'M';5:'Jun';6:'J';7:'A';8:'S';9:'O';10:'N';11:'D')
expression in (c1,c2,c3,...cn)
where c1, c2, ..., are constant elements, which could be numeric, date, or string expressions. For instance, the expression value in (11,22,33,44,13) is equivalent with (expression = 11) or (expression = 22) or (expression = 33) or (expression = 44) or (expression = 13). The in operator is more efficient than the equivalent or version. When working with a large number of constant elements, the in operator reduces the number of operations. For example, if the collection has 1000 elements, the in operator may take up to 8 operations to find if an element is in the set, while using the or statement could require up to 1000 operations. Therefore, the in operator is generally faster and recommended for large collections.expression switch (default,c1,c2,c3,...,cn)
Where c1, c2, ..., are constant elements, and default is the value returned if the element is not found in the collection. The constant elements can be numeric, date, or string expressions. The equivalent syntax is: "%0 = c 1 ? c 1 : ( %0 = c 2 ? c 2 : ( ... ? . : default) )". The switch operator is very similar to the in operator, except that it returns the value itself instead of -1. The first element in the switch is always returned when the element is found, and the default value is returned if the element is not found. For instance, the %0 switch ('not found',1,4,7,9,11) will return 1, 4, 7, 9 or 11, or 'not found' for any other value. Like the in operator, the switch operator uses binary search to find the fitting element, making it faster than using ? (immediate if operator) alternatives.expression case ([default : default_expression ; ] c1 : expression1 ; c2 : expression2 ; c3 : expression3 ;....)
The constants (default, c1, c2, ...) and expressions (expression1, expression2, ...) can be numbers, dates, or strings.
For instance, the date(shortdate(value)) case (default:0 ; #1/1/2002#:1 ; #2/1/2002#:1; #4/1/2002#:1; #5/1/2002#:1) indicates that only the dates #1/1/2002#, #2/1/2002#, #4/1/2002#, and #5/1/2002# will return 1, while all other dates will return 0. Another example specifies non-working hours for specific dates: date(shortdate(value)) case(default:0;#4/1/2009# : hour(value) >= 6 and hour(value) <= 12 ; #4/5/2009# : hour(value) >= 7 and hour(value) <= 10 or hour(value) in(15,16,18,22); #5/1/2009# : hour(value) <= 8). This defines the working hours for specific dates as follows::
- #4/1/2009#, from hours 06:00 AM to 12:00 PM
- #4/5/2009#, from hours 07:00 AM to 10:00 AM and hours 03:00PM, 04:00PM, 06:00PM and 10:00PM
- #5/1/2009#, from hours 12:00 AM to 08:00 AM
This shows how the case operator allows for flexible date and time-based logic, defining specific conditions for various cases and defaults.
The in, switch, and case statements use binary search to look for elements, making them faster than using iif and or expressions. The priority of operations inside the expression is determined by parentheses () and the priority of each operator.