1 simple expressions, 2 constant expressions, 3 assignment expressions – ElmoMC SimplIQ Software Manual User Manual

Page 37: 4 user variables, Ole_link4

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-8

5.4.8.1 Simple Expressions

The description and syntax of simple expressions is the same as for the Interpreter language
(refer to

section

4.2.6.1

).

5.4.8.2 Constant Expressions

A constant expression is a simple expression that contains only operations with immediate
numbers as operands. The Compiler recognizes the constant expression, evaluates it and
uses the final result to generate the executable code of the

SimplIQ

drive. Note that the result

of evaluating a constant expression by the Compiler may differ from the result calculated
inside the

SimplIQ

drive, because the Compiler uses more resources and may evaluate and

operate with double-precision floating-point numbers.

5.4.8.3 Assignment Expressions

The description and syntax is the same as for the Interpreter language (refer to

section

4.2.6.2

). User programming language allows multiple assignments to multiple

outputs of the function.

5.4.8.4 User Variables

User variables are defined within the program, using the “int” or “float” declaration, with
the following syntax:
int int_var1, int_var2[12], …, int_varN;
float flt_var1[13], flt_var2, flt_varN;
int a;
float b;

A variable must first be declared before it is used (in the expression or assignment).
The variable definition line consists of type name (int or float) and variable names. Variables
on the definition line must be separated by commas; alternatively, each variable may be
declared on a separate line. Variables may be scalar (for example, int var1, float temp)
or one-dimensional arrays (for example, int arr[10], float ftemp[4]). If a variable is
a vector, it must be declared with its dimension in brackets after its name. The vector
dimension must be a positive constant number. If the dimension is defined as a floating-
point number, it will be truncated to an integer. A dimension of less than 1 is illegal.

Examples:
int arr[12.5];

The floating-point number defining dimension will be truncated to 12.

int arr[-2];

This variable definition is illegal because the dimension is negative.

Only global variables may be one-dimensional arrays. Neither a local variable nor an
input/output argument of a function may be a vector.

Local variables must be defined at the beginning of function bodies. Any local or global
variable definition after executable code of the function is illegal.

Advertising