INCASE returns a valid switch value based on logical expressions

Syntax

INCASE(LogExpr,[ElseIf],LogExpr,[Else],Expr)

Arguments

  • LogExpr is a logical Expression in the form: Expr,Logical Operator,Expr,THEN,Expr
  • Expr is a numeric or String expression

Remarks

  1. INCASE is an alternative for structures in the knowledge base consisting of Relations and connected Constraints.
  2. INCASE may be a more compact way of expressing rules, but in contradistinction to Relations and Constraints, all expressions need to be determinable, even if they are invalid based on the logical expressions. Complex logical expressions with brackets and AND, OR etc. are not possible in INCASE, however.
    If the various logical expressions contain the same parameters, the INCASE function is an efficient option. If the various logical expressions contain entirely different parameters which need to be chained to different Relations, the Solution may become inefficiently large and may require lots of input which may not be relevant to your case since the Modeller requires all expressions in the INCASE function to be DETERMINED. In such cases it is much more efficient to use combinations of Relations and Constraints.
  3. IMPORTANT: In a Logical Expression, expression of the same type (STRING or VALUE) should be compared.
  4. Options for Logical Operator:
    1. EQ -> Equal to (=)
    2. NE -> Not Equal to ()
    3. LT -> Lower Than (<)
    4. GT -> Greater Then (>)
    5. LE -> Lower than or Equal to (<=)
    6. GE -> Greater of Equal to (=>)
  5. Please note that in addition to the two letter operators you can also use the logical operators itself

Examples

The relation
B=INCASE(A,LT,5,THEN,1,ELSEIF,A,GT,9,THEN,3,ELSE,2)

is equivalent to the algorithm:

   

If A<5 Then
    B=1
   ElseIf A>9 Then
    B=3
   Else
    B=2
   EndIf


A number of ELSEIF, LogExp can be provided in sequence in INCASE to simulate a Select Case function.

Please note that you can also write the relation as:

 

B=INCASE(A<5,THEN,1,ELSEIF,A>9,THEN,3,ELSE,2)

 
 

Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview


  • No labels