calculateContainerBlock & calculateMathAddOnBlock
calculateContainerBlock
This Block accepts source VC as input and generates output as new VC document.
Input Parameters:
inputSchema : source VC schema
inputFields : array of variables which would be taken from the source VC.
Variable | Definition | Example of Input |
---|---|---|
name | Refer to the specified field value | field0 |
title | Title of the operation | Summary |
value | Variable to store the value of the field | E0 |
New variable "E0" would be created with a value set to one from the "field0" in the VC document.
"title" is not a mandatory parameter. The value is set automatically as per the user convenience.
Output Parameters
outputSchema : output VC schema
outputFields : array of variables of output VC, which will be the field with the values from the variables.
Variable | Definition | Example of Input |
---|---|---|
name | Variable that refers to specified field | field0 |
title | Title of the operation | Summary |
value | Points to the value of specified variable | E1 |
The output variable "field0" will contain the value from the variable "E1".
"title" is not a mandatory parameter. The value is set automatically as per the user convenience.
calculateMathAddonBlock
This Block performs mathematical calculations sequentially.
equations : array of formulas.
When above code is executed, a new variable, "E1" will be created which would contain the value of the calculation "E0*10".
Note: All the expressions available in Math.js are supported by calculateMathAddOnBlock.
Operator | Name | Syntax | Associativity | Example | Result |
---|---|---|---|---|---|
| Grouping |
| None |
|
|
| Matrix, Index |
| None |
|
|
| Object |
| None |
|
|
| Parameter separator |
| Left to right |
|
|
| Property accessor |
| Left to right |
|
|
| Statement separator |
| Left to right |
|
|
| Row separator |
| Left to right |
|
|
Statement separator |
| Left to right |
|
| |
| Add |
| Left to right |
|
|
| Unary plus |
| Right to left |
|
|
| Subtract |
| Left to right |
|
|
| Unary minus |
| Right to left |
|
|
| Multiply |
| Left to right |
|
|
| Element-wise multiply |
| Left to right |
|
|
| Divide |
| Left to right |
|
|
| Element-wise divide |
| Left to right |
|
|
| Percentage |
| None |
|
|
| Addition with Percentage |
| Left to right |
|
|
| Subtraction with Percentage |
| Left to right |
|
|
| Modulus |
| Left to right |
|
|
| Power |
| Right to left |
|
|
| Element-wise power |
| Right to left |
|
|
| Transpose |
| Left to right |
|
|
| Factorial |
| Left to right |
|
|
| Bitwise and |
| Left to right |
|
|
| Bitwise not |
| Right to left |
|
|
| Bitwise or |
| Left to right |
|
|
| Bitwise xor |
| Left to right |
|
|
| Left shift |
| Left to right |
|
|
| Right arithmetic shift |
| Left to right |
|
|
| Right logical shift |
| Left to right |
|
|
| Logical and |
| Left to right |
|
|
| Logical not |
| Right to left |
|
|
| Logical or |
| Left to right |
|
|
| Logical xor |
| Left to right |
|
|
| Assignment |
| Right to left |
|
|
| Conditional expression |
| Right to left |
|
|
| Range |
| Right to left |
|
|
| Unit conversion |
| Left to right |
|
|
| Equal |
| Left to right |
|
|
| Unequal |
| Left to right |
|
|
| Smaller |
| Left to right |
|
|
| Larger |
| Left to right |
|
|
| Smallereq |
| Left to right |
|
|
| Largereq |
| Left to right |
|
|
Example
In the input VC is { "field0" : 5 }
Then
input VC variable "E0" will contain 5 (eg. "E0" = 5)
When executed a new variable "E1" will be created with the value "E1" = E0*10 = 5 * 10 = 50
In the output VC there will be "E1" variable
The result will be VC = { "field0" : 50 }
Last updated