An expression in EASA is a mathematical or logical statement that involves a combination of:
An example of an expression is as follows:
where first the object value of W will be multiplied by five, then one-half of the value t will be subtracted from the first term, and finally, the previous result will be raised to the power two.
The Builder allows the use of object names within expressions. When the name of an object is entered as part of an expression it becomes an object reference, the value of the object referred to will be substituted into the expression just before the expression is evaluated while the EASAP is running.
To be used in expressions, object names must adhere to a few rules. Names must:
Valid object name examples: x, xx, aVariable, var1, var2
Invalid object name examples: 3x, my2variable
Use of object names is case sensitive, be consistent in object names to minimize errors.
Tip: As a rule, it is a good idea to name all your objects using the rules for expression use because you will not always be able to anticipate when you’ll use an object in an expression.
Operators are used in expressions to perform mathematical or logical operations. For mathematical operations, operators exist to allow the basics, like addition, subtraction, multiplication, and division, but others exist for performing more advanced operations, like trigonometric functions, logarithmic functions, etc.
The table below contains the set of mathematical operators available for use in expressions.
|+, -, * , /, ^||Add, Subtract, Multiply, Divide, Raise to power of|
|%||Modulo or remainder, e.g. 7%3 returns 1|
|abs(..)||Return absolute value|
|round(..)||Round to closest integer|
|fpart(..)||Returns decimal value of argument, e.g. fpart(2.345) returns 0.345|
|ceil(..)||Returns next integer greater than or equal to argument|
|floor(..)||Returns next integer less than or equal to argument|
|sin(..), cos(..), tan(..), cotan(..)||Trigonometric functions: Arguments within parentheses have units of radians|
|asin(..), acos(..), atan(..), acotan(..)||Trigonometric functions: Angles returned from function have units of radians|
|sinh(..), cosh(..), tanh(..)||Hyperbolic functions|
|ln(..), exp(..), [base]log(..)||Logarithmic functions|
|fac(..)||Factorial of integer argument, n, i.e. n *(n-1)*(n-2)*…*1|
|sfac(..)||Semi-factorial of integer argument, n, i.e. n * (n -2)*(n-4)*…*4*2 if n is even, or n *(n-2)*(n-4)*…*3*1 if n is odd|
Logical operators can be used to create expressions that will produce different values depending on a logical condition. The result of an expression using a logical operator will be 0.0 for false or 1.0 for true. Complete logical expressions can be nested within a larger mathematical expression to allow the value of the overall expression to be a function of one or many logical conditions. The table below contains the set of logical operators available for use in expressions.
|==, !=||Equal to, Not equal to|
|&&, ||||And, Or|
|>, <||Greater than, Less than|
|>=, <=||Greater than or equal to, Less than or equal to|
|!||Not (Reverts true to false & false to true)|
This list shows the order in which operators are evaluated within an expression.
Parentheses may be used to override the order of evaluation.
EASA’s Expression Language also contains a few common constants for use in expressions. The constants are provided in the table below.
Constants and object references in expressions are case-sensitive→ constants must be lower case.
Below are a number of mathematical expression examples using hypothetical SCALAR references.
Consider the REALBOX's:
|2*(A + B)^2 - C||2*(9) - 3 = 15|
|(A>=2)*B + (A<2)*C||0.0*2 + 1.0*3 = 3|
|10log(2*(B+C))||1.0 (note: 10log is 'log base ten')|
A logical expression evaluates to a true or false value. Below are some examples using hypothetical object references and initial values:
|(C==“choice1”) && (A<3)||true (1.0)|
Characters and text strings have different syntax for equality checking equality is different for than for numbers. For text/characters:
Due to the reserved use of double-quotes, a string equality test will fail when the text actually contains double quotes. In this case use a STRING or REPEATED STRING.
Usually it only makes sense to use string constants or string variables for equality comparisons. The table below illustrates the behavior if they are used in more general expressions.
|2*”choice2“||NaN (not a number)|
|2* C||NaN (not a number)|
Since the possible values of logical expressions of TRUE and FALSE have numerical values of 1.0 and 0.0, respectively, logical expressions can be mixed with mathematical expressions to create a combined expression. Some combined expression examples are contained within the table below. The example expressions will make use of object references using the object names: A, B, C and D, where A = 2.0, B = 5.0, C = choice1 (CHOICE LIST) and D = 3 (INTEGERBOX).
|(C==“choice1”)*A + (C==“choice2”)*B||(1.0)*2.0 + (0.0)*5.0 = 2.0|
|(C!=“choice2”)*B||(1.0)*5.0 = 5.0|
|(D>4)*(A+B) + (D⇐4)*(B-A)||(0.0)*(7.0) + (1.0)*(3.0) = 3.0|
Expressions are intended to be used both by Authors in the generation of EASAPs and by Users in the EASAP itself as a substitute for entering numbers.
As an Author, you will use expressions when setting the values of object parameters. Common uses for parameters include:
Many more examples can be found at the Diagramming and Coupling To Software Applications pages. When an expression is typed into a Parameter Value box, error checking is performed to ensure that the expression is valid. If the expression is deemed to be valid, it will be colored blue. If deemed invalid, it will be colored red. In some cases, the validity of an expression cannot be determined definitively, and in such cases, the expression will be colored black. In a comma separated list of expressions, only the invalid expressions in the list will be colored red, the rest will be blue or black.
Before saving an EASAP or checking an EASAP’s user interface using the Toggle to Preview button, all invalid expressions must be fixed or a pop-up error message will appear.
A typical mistake that can be made when entering an expression is to type in an incorrect object name. To help with this issue, the EASAP Builder will display a drop-down list of available object names that can be selected as you type in your expressions. The list of objects will be filtered by the characters you type. An example of the object name auto-completion dropdown is shown below.
The list of available objects shown in the auto-completion dropdown is derived from the global list of objects. It is therefore exhaustive and may contain objects that are not appropriate selections. For instance, it might contain LIST when only a SCALAR is valid.