beautypg.com

ProSoft Technology ProSoft i-View User Manual

Page 47

background image

ProSoft i-View ♦ Mobile Process Monitoring and Control Application

Data Source Files

Version 2.0.2

User Manual

ProSoft Technology, Inc.

Page 47 of 106

September 29, 2011

Using Expressions
ProSoft i-View expression syntax is based on the open source Ruby scripting
language syntax. For basic operations this syntax is similar to that of the ‘C’
programming language and virtually identical to all modern scripting languages.

The Ruby language was chosen because it features a clean, easy to learn,
object-oriented syntax with a particular focus on expressions allowing for
practical ways to represent and dealt with several data types and formats with
great flexibility. ProSoft i-View supports most operators including all common
Logical, Arithmetic and Comparison operators, as well as commonly used Ruby
functions and methods.

Support of Ruby expressions in ProSoft i-View is a subset of the Ruby language.
Expressions are not, and do not pretend to be a complete implementation of
Ruby. In some cases we provided a single way to accomplish something that can
be done in several ways on Ruby, and in other cases we integrated several
functionalities in single methods instead of implementing all of them. So it is
important to refer to this manual if you are also using a Ruby tutorial to determine
what it is actually supported on ProSoft i-View and which behavior differences
may apply.

For those who already used Ruby, one of the most obvious differences between
‘pure’ Ruby and ProSoft i-View is treatment of boolean values. Ruby treats
everything as objects, including numbers, while ProSoft i-View keeps the
traditional ‘C’ like behavior. For example, in Ruby any number used in a boolean
expression is a true value even if it holds zero. ProSoft i-View, on the other hand,
will still interpret 0 (zero) as false and non-zero as true, in the traditional sense of
earlier programming languages, and hopefully in accordance to what PLC
programmers would expect or feel more natural.

NOTE: If you are not familiarized with Ruby and want to test some ProSoft i-View
expressions before you start using them in your project you can try them on any
of the available Ruby interpreters to help you understand how they work.
On any Mac OS X or Linux computer open the Terminal and type irb. This will
launch the interactive Ruby interpreter. On the >> prompt type or paste any
expression you would like to try.
Ruby can be installed on Windows as well. Refer to this to begin with:

http://www.ruby-lang.org/en/downloads/

.

You can even type Ruby expressions right on your Internet Browser!. Go here:

http://TryRuby.org

/

Just type or paste the expression examples in this manual on any of the
mentioned tools and see whether they give the expected results.