Structured text language
166
35015365.01 07/2008
Example 1 In the example below the NOT is applied on the %MW3 then the result is multiplied by
25. The sum of %MW10 and %MW12 is then calculated then the logic AND from the
result of the multiplication and the addition.
NOT %MW3 * 25 AND %MW10 + %MW12
Example 2 In this example multiplying%MW34 by 2 is done first then the result is used to carry
out the rollover.
%MW34 * 2 REM 6
Using brackets Brackets are used to modify the order in which operators are evaluated to allow, for
example, an addition to be carried out before a multiplication.
You can overlap parentheses and there is no limit to the level of overlap.
Parentheses can also be used in order to prevent the program being wrongly
interpreted.
Example 1 In this example, addition is done first, then multiplication:
(%MW10+%MW11)*%MW12
Example 2 This example shows that parentheses can be used to avoid any misinterpretation
of the program.
NOT %MW2 <> %MW4 + %MW6
Using these operator priority rules, the interpretation is as follows :
((NOT %MW2) <> (%MW4 + %MW6))
But you may think that the operation is as follows:
NOT (%MW2 <> (%MW4 + %MW6))
Therefore parentheses serve to clarify the program.
Implicit
conversions
Implicit conversions are about words and double words.
The operators that you use in arithmetic expressions, in comparisons and operator
allocation carry out these implicit conversions (which are therefore not under the
user's control).