Summary

Formula interpreter 3.0 


Getting started

Core idea is to let define users rules either directly (e.g. via editable Grid)
OR via specialized EXCELS thare are used to specify rules (talk with or WernerS about it).

It allows testing a solution and makes calculations and results visible.

Define a table for the formula interpreter.

For the formula interpreter you need a table with the following columns:

  • Identifier
  • Variable
  • Formula
  • Value

    This table can origin from several other tables which will be merged or from an Editable Grid from the [TIS]Board.
    Example:

    Here we have defined three variables (Length, Depth and Height) which should be multiplied (Rows 4, 5 and 6).
    Additionally several columns representing indices can be defined.

Insert the operation, choose the suitable columns, define names for the description column and the error column and define the formatting of the number values.


PLEASE NOTE:

  • Column INDEX must be an Integer Column
  • Column GLOBAL (from Version 3.1. on) must be boolean 


Indices are used like this: [L215](1), or if there are several indices [L215](2,2) 

Calculation

As soon as the formula field is defined, the formula interpreter tries to solve the formula and overwrite the value filed.
The formula itself can hold the names of one or several variable names and/or numbers.
The following formula inputs can be made:

  • Variables are defined by square brackets: [variable name]
  • if-then formulas are defined like that: IF ([V1] == [V2], 1, 2)
  • AND and OR is defined like in the formula operator: && and  ||
  • MIN([V1], [V2]) for minimum value
  • MAX([V1], [V2]) for minimum value
  • ABS([V1]) for absolute values
  • ROUND([V1]) for rounding to an integer; see also MidpointRounding.AwayFromZero (MSDN)
  • ROUND([V1], x) for rounding to an defined number of decimals (x).
  • MOD([V2], 3) for Modulo calculations

Result


As mentioned before, the value fields in rows holding a formula were calculated.
Two additional columns were generated. The description column gives information about the calculation steps. The error column shows errors within the calculations. In the example the variable Height2 does not exist.

Configuration

Input settings of existing table

Parameter

Value

Opt.

Description

Example

Identifier

System.Object

opt.

Which columns should be evaluated for the identifier?

-

Variable column

System.String

-

Column containing the name of the variable.

-

Variables index column

System.Int32

opt.

Index columns for variable arrays

-

Formula column

System.String

-

Column containing the formula.

-

Value column

System.Double

-

Column containing the value of the variable.

-

Global variable column

System.Boolean

opt.

Column used to specify that this line contains a global variable (valid for all identifiers).

-

Trace column

System.Boolean

opt.

Column used to specify that only this line including its predecessors (on which the calculation is based) will be displayed.

-

Settings

Parameter

Value

Opt.

Description

Example

Name of description column

System.String

-

-

-

Name of error column

System.String

-

-

-

Name of direct errors column

System.String

opt.

-

-

Debug Mode

System.Boolean

-

-

-

Format string for small numbers

System.String

-

-

-

Format string for large numbers

System.String

-

-

-

Format string for percentages

System.String

-

-

-

Limit sm/la numbers (+/-)

System.Double

-

-

-

Grammer in EBNF (further definitions in XFormulas.g3)
/* converted on Wed Jan 20, 2016, 15:17 (UTC+01) by antlr_3-to-w3c v0.35.1152 which is Copyright (c) 2011-2015 by Gunther Rademacher <grd@gmx.net> */
 
xformula ::= xformula_expression EOF
xformula_expression
::= xformula_logicalandexpr
xformula_logicalandexpr
::= xformula_logicalorexpr ( '&&' xformula_logicalorexpr )*
xformula_logicalorexpr
::= xformula_compareexpr ( '||' xformula_compareexpr )*
xformula_compareexpr
::= xformula_sumexpr ( ( '==' | '!=' | '>' | '>=' | '<' | '<=' ) xformula_sumexpr )*
xformula_sumexpr
::= xformula_prodexpr ( ( '+' | '-' ) xformula_prodexpr )*
xformula_prodexpr
::= xformulaexpr ( ( '*' | '/' ) xformulaexpr )*
sign ::= '+'
| '-'
primary_expression
::= numeric_constant
parameter
::= xformula_expression
| xformulaexpr
| '(' xformula_expression ')'
xifunc ::= '#' XIFUNCIDENTIFIER '(' parameter* ( ',' parameter )* ')' '#'
function ::= FUNCTIONIDENTIFER '(' parameter ( ',' parameter )* ')'
vardef ::= VARIDENTIFIER ( '(' parameter ( ',' parameter )* ')' )*
compareop
::= '=='
| '!='
| '>'
| '>='
| '<'
| '<='
op ::= '+'
| '-'
| '/'
| '*'
numeric_constant
::= INTEGER
| DOUBLE
xformulaexpr
::= vardef
| function
| '-'* primary_expression
| op
| compareop
| xifunc
| CHARACTER_LITERAL
| STRING_LITERAL
| '(' xformula_expression ')'
 
<?TOKENS?>
 
BOOLEAN ::= 'true'
| 'false'
| 'True'
| 'False'
ESCAPELDELIM
::= '\' '['
ESCAPERDELIM
::= '\' ']'
INTEGER ::= DIGIT+ INTEGER_TYPE_SUFFIX?
DOUBLE ::= ( DIGIT* '.' )? DIGIT+ REAL_TYPE_SUFFIX?
INTEGER_TYPE_SUFFIX
::= 'I'
| 'i'
REAL_TYPE_SUFFIX
::= 'F'
| 'f'
VARIDENTIFIER
::= '[' ( ESCAPEDELIM | [^[#x5D] )+ ']'
FUNCTIONIDENTIFER
::= ( UPPER | LOWER ) ( UPPER | LOWER | DIGIT )*
XIFUNCIDENTIFIER0
::= '#' XIFUNCIDENTIFIER
XIFUNCIDENTIFIER
::= 'XI.TIS' UPPER LETTERS*
ESCAPEDELIM
::= ESCAPELDELIM
| ESCAPERDELIM
LOWER ::= [a-z]
UPPER ::= [A-Z]
SPECIALS ::= [ -@#x80-#xFF]
LETTER ::= LOWER
| UPPER
| SPECIALS
LETTERS ::= LOWER
| UPPER
DIGIT ::= [0-9]
ESCAPESEQUENCE
::= '\' ( 'b' | 't' | 'n' | 'r' | '"' | "'" | '\' )
CHARACTER_LITERAL
::= "'" ( ESCAPESEQUENCE | [^'\] )* "'"
STRING_LITERAL
::= '"' ( ESCAPESEQUENCE | [^"\] )* '"'
WS ::= [ #x9#xA#xD]+
COMMENT? ::= '/*' .* '*/'
EOF ::= $

Want to learn more?

Troubleshooting

Nothing known up to now.


Related topics