beautypg.com

ProSoft Technology ProSoft i-View User Manual

Page 49

background image

ProSoft i-View ♦ Mobile Process Monitoring and Control Application

Data Source Files

Version 2.0.2

User Manual

ProSoft Technology, Inc.

Page 49 of 106

September 29, 2011

Mixing Numbers, Strings or Arrays is only possible through the use of the
appropriate operators and methods that result in compatible types. An immediate
consequence is, for instance, that you are not allowed to add directly a number to
a string unless you convert the string to a number first. Thus, some operators
take particular significance depending on type as it is commonly accepted on
most modern scripting languages including Ruby. See next sections for a further
discussion on this and other subjects.

Numeric values.

Numeric values in expressions and variables are internally stored as Double
Float values (64 bits) Values read from PLCs including BOOL and INT tags are
scaled and converted to Double Float type before they are used in expressions.
All Arithmetic, Logical and Comparison operations are performed as Double Float
operations, so you may never expect to obtain truncated values from arithmetic
calculations.

The above statement may change in the future to give support for true integer
arithmetic. Currently, an implicit conversion to an integer type is only performed
for bit or bitwise operations on numbers, and indexed access to string or array
elements. In other cases you can use the to_i method to explicitly get the integral
part of a numeric value according to your needs.

Constant numbers can be represented with optional decimal point and a base 10
exponent. Additionally, hexadecimal and binary notations are supported by using
the 0x or 0b prefixes. The special forms true, false +inf and -inf are supported as
well.

Examples:

-1.42 (decimal representation)
1.1666e+2 (decimal representation with exponent)
0xe0af (hexadecimal representation)
0b011011101 (binary representation)
true (same as 1)
false (same as 0)
-inf (very big negative number)
+inf (very big positive number)

Strings.
Strings are arbitrary sequences of characters that are manipulated as a whole.
Strings can be read from or written to PLCs,. Several operations can be
performed on strings such as concatenating, splitting or substring extraction by
using the appropriate operators or methods. String literals are represented
enclosed in double quotes.