In Envision basic, there are many useful functions that comes handy. Especially when performing some quick mathematical operations, it saves us a few lines of code.
ABS and NEG are a couple of those kinds of functions that comes handy for math operations.
These functions are really easy to use and mostly don’t require any complex logic to use them.
ABS Function
The ABS function is nothing but an absolute value function. It returns the positive numeric value of the
argument.
Syntax
ABS(expr)
Example
This will change X.NUMBER variable’s value to a positive 1 from a negative 1.
X.NUMBER = -1
X.NUMBER = ABS(X.NUMBER)
NEG Function
The NEG function changes the value of the passes numeric value to the opposite sign value.
So, if the passes expression is of a positive value, it’ll change it to a negative value and return it.
If the passes expression is of a negative value, it’ll change it to a positive value and return it.
Syntax
NEG(expr)
Example
This will change X.NUMBER variable’s value to a positive 1 from a negative 1.
X.NUMBER = -1
X.NUMBER = NEG(X.NUMBER)
This will change X.NUMBER variable’s value to a negative 1 from a positive 1.
X.NUMBER = 1
X.NUMBER = NEG(X.NUMBER)
absolute colleague examples functions studio