The JGrafchart textual language uses loose typing and automatic type-casting. It is the context that decides how an expression is evaluated. An expression can be evaluated as a bool, an int, a real, or a string.
In an assignment action it is the type of the assigned variable that decides how the expression for the value is evaluated.
For example, consider the stored action: S Variable = 0;
If Variable is a bool the expression is evaluated as the bool value false.
If Variable is an int the expression is evaluated as the int value 0.
If Variable is a real the expression is evaluated as the real value 0.0.
If Variable is a string the expression is evaluated as the string "0".
From | To | Conversion rules |
---|---|---|
bool | int | false → 0, true → 1. |
bool | real | false → 0.0, true → 1.0. |
bool | string | false → "0", true → "1". |
int | bool | 1 → true, false otherwise. |
int | real | Ordinary cast. |
int | string | The int value as a string. |
real | bool | If the value cast to an int is 1 then true, otherwise false. |
real | int | Ordinary cast. |
real | string | The real value as a string. |
string | bool | "1" → true, false otherwise. |
string | int | The parsed int value if possible, 0 otherwise. |
string | real | The parsed real value if possible, 0.0 otherwise. |