Since INScore version 1.20, mathematical expressions have been introduced as messages arguments. These expressions allows to compute values at parsing time.
Basic mathematical expressions are supported. They are listed below.
Note that matharg could be a mathexpr as well (see section 18.2).
Some simple mathematical expressions used as message parameters:
Boolean operations are the following:
Compare two variables:
Arguments of mathematical operations are the following:
Since INScore’s parameters are polymorphic, the semantic of the operations are to be defined notably when applied to non numeric arguments. Actually, a basic OSC message parameter type is between int32, float32 and string. However, due to the extension of the scripting language, parameters could also be arrays of any type, including mixed types (e.g. resulting from variable declarations).
For numeric arguments, automatic type conversion is applied with a precedence of float32 i.e. when one of the argument’s type is float32, the result is also float32 (see Table 18.1).
For string parameters, operations that have an obvious semantic (like + applied to two strings) are defined (see Table 18.2) , the others are undefined and generate an error (see Table 18.3).
|string + string||string||concatenate the two strings|
|string + num||string + string(num)||num is converted to string|
|num + string||string(num) + string||"|
|@max(stringstring)||string||select the largest string|
|@min(stringstring)||string||select the smallest string|
|string op string||where op is in [- * / %]|
|string op num||"|
|num op string||"|
|prefixed or postfixed string|
Boolean operations are supported on string only when both arguments are strings (see Table 18.4). Other types combination generate an error.
|boolean operation||evaluated as|
|string == string||regular strings comparison|
|string > string||alphabetical strings comparison|
|string >= string||"|
|string < string||"|
|string <= string||"|
For arrays, the operation is distributed inside the array elements:
When both parameters are arrays, the operation is distributed from one array elements to the other array elements when the arrays have the same size and it generates an error when the sizes differ:
Boolean operations on arrays are evaluated as the logical and of it’s element’s boolean values and generate an error when the arrays sizes differ.