1.2.7. Expressions

An expression consists of constants, variables, and function calls that are combined with operators.

Parentheses can be used to group expressions to alter the evaluation sequence from that defined by the precedence:

3*(4+7)

Unlike in C, there is no automatic type casting in MxScript. The expression (3.14 *2) causes an error because double and int types are mixed. Both C and C++ forms of casts are permitted.

A string can be multiplied by an integer to create a concatenated string:

String/integer casts are permitted:

The results of the different cast combinations are listed in Table 1.4.

Table 1.4. Results of cast operation

Original typecasting to intcasting to stringcasting to boolcasting to double
intError.Convert to string containing decimal integer format.false if integer is 0, otherwise true.Convert to double with same value.
stringInterpret string as integer number. Prefixes 0b (binary), 0x (hexadecimal) and 0 (octal) are recognized.Error.Error.Interpret string as a decimal floating-point number in C format.
bool1 if true, 0 if false.“true” if true, “false” if false.Error.Error.
doubleRound down to a lower integer value. Same as floor() function in C.Convert to string containing decimal floating-point format.Error.Error.

Copyright © 2007-2011 ARM. All rights reserved.ARM DUI 0371J
Non-ConfidentialID051712