Class LogicExpression
Parses and evaluates a logic (boolean) expression
Namespace: ABB.Robotics.Math
Assembly: ABB.Robotics.Math.dll
Syntax
public class LogicExpression
Constructors
LogicExpression(String)
Creates an expression.
Declaration
public LogicExpression(string expression)
Parameters
Type | Name | Description |
---|---|---|
String | expression |
LogicExpression(String, Boolean)
Creates an expression without variables, if 'literal' is true. Any non-operators are evaluated by string comparison.
Declaration
public LogicExpression(string expression, bool literal)
Parameters
Type | Name | Description |
---|---|---|
String | expression | |
Boolean | literal |
Properties
ExpressionString
Gets or sets the source expression string
Declaration
public string ExpressionString { get; set; }
Property Value
Type | Description |
---|---|
String |
IsValid
Returns True if the expression is valid and can be evaluated
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
Boolean |
VariableNames
Returns the names of variables used in the expression
Declaration
public IEnumerable<string> VariableNames { get; }
Property Value
Type | Description |
---|---|
IEnumerable<String> |
Methods
Evaluate()
Evaluates the expression
Declaration
public bool Evaluate()
Returns
Type | Description |
---|---|
Boolean | The evaluated value of the expression |
GetAllowedOperators()
Returns the allowed operators
Declaration
public static string[] GetAllowedOperators()
Returns
Type | Description |
---|---|
String[] |
SetVariableValue(String, Boolean)
Sets the value of a variable, which will be used the next time the expression is evaluated.
Declaration
public void SetVariableValue(string variable, bool val)
Parameters
Type | Name | Description |
---|---|---|
String | variable | Name of the variable to set |
Boolean | val | New value of the variable |
TrySetVariableValue(String, Boolean)
Sets the value of a variable, which will be used the next time the expression is evaluated.
Declaration
public bool TrySetVariableValue(string variable, bool val)
Parameters
Type | Name | Description |
---|---|---|
String | variable | Name of the variable to set |
Boolean | val | New value of the variable |
Returns
Type | Description |
---|---|
Boolean | True if the variable could be set (i.e. if it exists), false otherwise |