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:
The ' flags' for format operator is a list of values separated by | character such as 'NumDigits|DecimalSep|Grouping|ThousandSep|NegativeOrder|LeadingZero' with the following meanings:
- 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
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.