SET instruction
This instruction assigns (sets) a value to a parameter declared in the current object. If anything goes wrong with the assignment, the instruction is ignored and a warning message is printed in the log file.
Syntax
either
SET
or
SET
where
object-parameter-name - is the name of one of the parameters declared for the current object.
item1(2) - are indiValues as described in indiValue
- arithmetic-operator
- is one of the following
+ addition item1 plus item2 - subtraction item1 minus item2 * multiplication item1 times item2 / division item1 divided by item2 % remainder of item1 divided by item2
Caveats
- For strings, only + operator is allowed and implies concatenation.
- % operator is allowed only for integers.
Generally, the above operations are performed only between items representing values of the same type. If items do not represent values of the same type, then this can be achieved by type casting one of them or both. See discussion bellow.
Item Type casting and Type mixing
The right side of SET instruction
It is identical to the treatment of Simple Condition Type4. See APENDIX on Condition Handling- the end of the section about Simple Condition Type4.
When at the running stage (State Manager stage) the actual string value of an operand that should be casted to integer can not be interpreted as integer, warning message is printed in the State Manager log file and the SET instruction is not executed.
The left side versus the right side of SET instruction
The result of the operation has to be of the same type as that
of the left side. If this is not the case, than it can be achieved
by type casting the right side of the SET instruction e.g.
SET A = (string)( B + C)
If user used casting, then Translator will insist on the result of the right side being the same as that of the left. If user did not used casting, then Translator will attempt its own as follows:
- when the left side represents string, the right side is casted to string regardless its type.
- when the left side represents integer, the right side is casted to integer regardless its type, but see the note below)
- when the left side represents floating point value and the right side integer, the right side is casted to floating point
when the left side represents floating point value and the right side string, this is not allowed and will fail at Translator stage.
Note: In case 2, when at the running (State Manager stage) the actual string value can not be interpreted as integer, warning message is printed in the State Manager log file and the SET instruction is not executed.
Examples
To be supplied!!