| # Constraint editor Syntax of constraint expressions The constraint expressions syntax is a subset of the ERP Enterprise Tools syntax. You can make constraint expressions with the following basic instructions. Arithmetic operators: * (multiplication) / (division) + (addition) - (subtraction) \ (remainder after division) & (linking alphanumeric arrays) Logical operators: or and not Relational operators: = (equal to) > (greater than) >= (greater than or equal to) <> (not equal to) < (less than) <= (less than or equal to) Domain expresssions A is {a1,a2,a3-a4,..} means: (A=a1 or A=a2 or A >= a3 and A <= a4 and so on). The domain expression syntax is an abbreviated notation for logical expressions regarding the domain of a variable. Priority in expressions Arithmetic operators have a higher priority than relational operations. Relational operations have a higher priority than logical operators. The priority sequence for arithmetic operators : * / \ + - The priority sequence for logical operators : not, and, or Round brackets ('()') can be used to change the priority sequence for arithmetic and logical operators. Example 3 + 4 * 5 = 23 (3 + 4) * 5 = 35 Boolean expressions Boolean expressions can have the value true or false (1 or 0). This can be applied in constraints, especially conditional expressions. Example If not e then ' means: If e = false then' or If e = 0 then' If-then-else constructions Extensive if-then-else constructions can be used in constraints. Nesting of statements is allowed. Example If expression1 then expression2 else expression3 endif An if-then-else construction is always closed with an endif statement. The else statement is not mandatory. If, else and endif statements always start on a new line. (Conditional) expressions can be divided over several lines. A validation constraint may be defined without if-then-else statements; this constraint must start with c:. A constraint can be provided with comments using the | sign. During the configuration process, you can generate messages using the variable message (up to 80x25 lines of text). Constraint variables Both global and local variables can be used in constraint expressions. Global variables are product features and user-defined constraint variables that are declared as global. The variables predefined by the product configurator, such as input, display, length, width, and so on, are local ones. Global variables retain their value throughout the configuration process unless their values are changed. A constraint variable can have the following type declarations: string (alphanumeric) (for example: string machine global) long (integers) (for example: long i) double (fractions) (for example: double j) The user-defined constraint variables must always be declared at the top of the constraint. All local variables are initialized before execution of the constraint: alphanumeric variables are cleared and numeric variables are given the value zero. The global variables input and validating are initialized with the value true. Use of constraint variables Product features must be provided with opening and closing square brackets ([......])in constraint expressions. The remaining variables can directly be used in expressions. Alphanumeric variables (string arrays) can be indexed according to the notation: (startposition[;length]). Example [color] = "red" validating = true The values of variables can be alphanumeric or numeric. Alphanumeric values must be written in quotation marks ("...."). Numeric values can directly be entered. The decimal sign is a point ('.'). Example machine(1;2) = "A5" volume = 28.673 The constants true/false can be used for boolean expressions. Arithmetic functions round(X,Y,Z): produces rounded value of X; Y is number of decimals and Z is rounding method (0 = down, 1 = normal, 2 = up) val(A) : produces numeric value of string A (val("8.7") = 8.7) abs(X) : calculates absolute value of X (abs(-10.3) = 10.3) int(X) : produces integer value of X (int(11.6) = 11) pow(X,Y) : raises X to the power of Y (pow(10,2) = 100) sqrt(X) : produces square root of X (sqrt(16) = 4) min(X,Y) : produces smallest value of X and Y (min(6,10) = 6) max(X,Y) : produces largest value of X and Y (max(6,10) = 10) pi : constant with value PI (3.1415926...) Goniometric functions sin(X), cos(X), tan(X) : produces sine, cosine, or tangent of X (radials) asin(X), acos(X), atan(X): produces arc sine, cosine, or tangent of X hsin(X), hcos(X), htan(X): produces hyperbolic sine, cosine, or tangent of X Logarithmic functions exp(X) : raises e to the power of X log(X) : produces natural logarithm of X on the basis of e log10(X): produces logarithmic value of X on the basis of powers of 10 String functions edit(X,Y) : formats numeric value X according to format Y (edit(10.3,"ZZZ9V.99") = " 10.30" str(X) : puts numeric value in string (str(10.3) = "10.3") len(X) : produces length of string X (len("abc") = 3) strip(X) : deletes spaces after last character (strip("A ") "A") pos(X,Y) : produces position of string Y in string X from left rpos(X,Y) : produces position of string Y in string X from right Date functions date() : produces the number of days between day 0 and current date date(y,m,d): produces the number of days between day 0 and entered date Example date(1995,06,01) = 728445 |