05.05.2014 Views

csmstr - Omega Engineering

csmstr - Omega Engineering

csmstr - Omega Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INDEXING ARRAYS<br />

CRIMSON USER MANUAL - MODULAR CONTROLLER<br />

INDEXING ARRAYS<br />

Elements within an array tag can be selected by following the array name with square<br />

brackets that contain an indexing expression. This expression must range from 0 to one less<br />

than the number of elements in the array. If you create a 10-element array, for example, the<br />

first element will be Name[0] and the last will be Name[9].<br />

INDEXING STRINGS<br />

Square brackets can also be used to select characters within a string. For example, if you have<br />

a tag called Text that contains the string “ABCD”, then the expression Text[0] will return a<br />

value of 65, this being equal to the ASCII value of the first character. Index values beyond the<br />

end of the string will always return zero.<br />

ADDING STRINGS<br />

As well as adding numbers, the addition operator can be used to concatenate strings. Thus, the<br />

expression "AB"+"CD" evaluates to "ABCD”. You may also use the addition operator to add<br />

an integer to a string, in which case a single character equal to the ASCII code represented by<br />

the integer is appended to the data in the string.<br />

CALLING PROGRAMS<br />

Programs that return values may be invoked within expressions by following the program<br />

name with a pair of parentheses. For example, Program1()*10 will invoke the associated<br />

program, and multiply the return value by 10. Obviously, the return type for Program1 must<br />

be set to integer or floating-point for this to make sense.<br />

USING FUNCTIONS<br />

Crimson provides a number of predefined functions that can be used to access system<br />

information, or to perform common math operations. These functions are defined in detail in<br />

the Function Reference. They are invoked using a syntax similar to that for programs, with<br />

any arguments to the function being enclosed within the parentheses. For example, cos(0)<br />

will invoke the cosine function with an argument of 0, returning a value of +1.0.<br />

PRIORITY SUMMARY<br />

The table below shows the priority of all the operators defined in this section…<br />

GROUP<br />

OPERATORS<br />

Group 1 .<br />

Group 2 ! ~<br />

Group 3 * / %<br />

Group 4 + -<br />

Group 5 ><br />

Group 6 < > =<br />

PAGE 266<br />

http://www.redlion.net/controller

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!