0 - expressions, 1 arithmetic expressions, 0 expressions – Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 33

Advertising
background image

5Ć1

5.0 EXPRESSIONS

An expression is a symbol or a group of symbols that BASIC can

evaluate. These symbols can be numbers, strings, constants,

variables, functions, array references, or any combination of these.

The following are the different types of operations which can be

performed:
1. Arithmetic expressions/operators
2. String expressions/operators
3. Boolean expressions/operators
4. Relational expressions/operators

5.1

Arithmetic Expressions

BASIC allows you to perform addition, subtraction, multiplication,

division, and exponentiation with the following operators:

**

Exponentiation

*

Multiplication

/

Division

+

Addition, Unary+

-

Subtraction, Unary-

The unary plus and minus are different from the other operators

because they operate on only one operand, not two. The standard

operators (binary operators) require two operands.
The following expressions use binary operators:

MOTOR_SPEED% + JOG_SPEED%

GAIN% Ć GAIN_CHANGE%

GAIN% * GAIN_FACTOR%

The following expressions use unary operators:

GAIN - SPEED (Legal but results in a positive value)

-MOTOR_SPEED%

-(GAIN%+GAIN FACTOR%)

+MOTOR_SPEED% (This form is not typically used because

it is assumed that the absence of an operator in front of a

variable means plus or positive)

Unary minus makes a positive expression negative. Unary plus does

not make a negative expression positive. A unary minus applied to a

variable already having a negative value will, of course, make the

variable (or expression) positive.
The symbols for unary plus and minus (+ and -)are the same as

the binary plus and minus, but the operation is different. For

example, A% - B% means subtract B% from A%, whereas -(A%)

means negative the value of A%.
Performing an operation on two arithmetic expressions of the same

data type yields a result of that same data type. For example, A% +

B% yields an integer, and K$ + M$ yields a string.
When a real value (constant or variable) is used in an expression

with any other numeric data type (single integer, double integer, or

real) the result is always real. When a boolean value is used in an

Advertising
This manual is related to the following products: