Back

Topic

[KB680]Application Architect Expression Function and Operator Reference

Tags: Architect, Expression

10 years ago
By FABO
Options
Print
Applies to:

PcVue 10.0, PcVue 11


Summary:

When using Application Architect, it is possible to use expressions when defining parameters or directly in a variable property such as domain or nature.

This article explains gives an overview of instructions, operators and functions that can be used


Details:

An expression can be created with operators and functions.

Operators

Expressions can be combined using operators. Each operator has a precedence. Here is the list of these expressions’ priorities.

1. primary

2. unary

3. power

4. multiplicative

5. additive

6. relational

7. logical

Logical
These operators can do some logical comparison between other expressions:
or, ||
and, &&

true or false and true

The “and” operator has more priority than the “or”, thus in the example above, “false and true” is evaluated first.

Relational
=, ==, !=, <>
<, <=, >, >=

1 < 2

Additive
+, –

1 + 2 – 3

Multiplicative
*, /, %

1 * 2 % 3

Bitwise
& (bitwise and), | (bitwise or), ^(bitwise xor), << (left shift), >>(right shift)

2 >> 3

Unary
!, not, -, ~ (bitwise not)

not true

Primary
(, )

2 * ( 3 + 2 )


Functions

The following table describes standard functions:

Name Description
Usage Result

Abs

Returns the absolute value of a specified number

Abs(-1)

1

Acos

Returns the angle whose cosine is the specified number

Acos(1)

0

Asin

Returns the angle whose sine is the specified number

Asin(0)

0

Atan

Returns the angle whose tangent is the specified number

Atan(0)

0

Ceiling

Returns the smallest integer greater than or equal to the specified number

Ceiling(1.5)

2

Cos

Returns the cosine of the specified angle

Cos(0)

1

Exp

Returns e raised to the specified power

Exp(0)

1

Floor

Returns the largest integer less than or equal to the specified number

Floor(1.5)

1

IEEERemainder

Returns the remainder resulting from the division of a specified number by another specified number

IEEERemainder (3, 2)

-1

Log

Returns the logarithm of a specified number

Log(1, 10)

0

Log10

Returns the base 10 logarithm of a specified number

Log10(1)

0

Max

Returns the larger of two specified numbers

Max(1, 2)

2

Min

Returns the smaller of two numbers

Min(1, 2)

1

Pow

Returns a specified number raised to the specified power

Pow(3, 2)

9

Round (available in PcVue 10 SP2, PcVue 11)

Rounds a value to the nearest integer or specified number of decimal places. The mid number behaviour can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object.

Round (3.222, 2)

3.22

Sign

Returns a value indicating the sign of a number

Sign(-10)

-1

Sin

Returns the sine of the specified angle

Sin(0)

0

Sqrt

Returns the square root of a specified number

Sqrt(4)

2

Tan

Returns the tangent of the specified angle

Tan(0)

0

Truncate

Calculates the integral part of a number

Truncate(1.7)

1

It also includes other general purpose ones.

Name Description Usage Result

if

Returns a value based on a condition

if(3 % 2 = 1, ‘value is true’, ‘value is false’)

‘value is true’

Then, those following functions can be used in an expression:

int StrIndexOf(string String, string StringSeek)
Reports the index of the first occurrence of the string seek in the string parameter.

int StrLastIndexOf(string String, string StringSeek)
Reports the index of the last occurrence of the string seek in the string parameter.

string StrSubstring(string String, int StartIndex)
Returns a substring from the string parameter. The substring starts at the startIndex position.

string StrSubstring(string String, int StartIndex, int Length)
Returns a substring from the string parameter. The substring starts at the startIndex position and has the count length.

string StrRemove(string String, int StartIndex)
In the returning string, deletes all the characters from this string beginning at a specified position and continuing through the last position.

string StrRemove(string String, int StartIndex, int Length)
In the returning string, deletes all the characters from this string beginning at a specified position for count characters.

string StrLeft(String string, int Length)
Returns a string containing the count first character of the string parameter.

string StrRight(string String, int Length)
Returns a string containing the count last character of the string parameter.

string StrTrim(string String)
Returns a string with all leading and trailing white-space characters removed from the string parameter.

string StrTrim(string String, string ParseChars)
Returns a string with all leading and trailing occurrences of a set of characters specified in trimChars removed from the string parameter.

string StrTrimEnd(string String, string ParseChars)
Returns a string with all trailing occurrences of a set of characters specified in trimChars removed from the end of the string parameter.
For example, if the current string is “123abc456xyz789” and trimChars is “123456789”, the TrimEnd method returns “123abc456xyz”.

string StrTrimStart(string String, string ParseChars)
Returns a string with all trailing occurrences of a set of characters specified in trimChars removed from the start of the string parameter.
For example, if the current string is “123abc456xyz789” and trimChars is “123456789”, the TrimStart method returns “abc456xyz789”.

string StrPadLeft(string String, int totalWidth, char paddingChar)
Left-aligns the characters in this instance (string), padding on the left with a specified character (Char) for a specified total length (Count)

string StrPadRight(string String, int totalWidth, char paddingChar)
Right-aligns the characters in this instance (string), padding on the left with a specified character (Char) for a specified total length (Count)

string StrToUpper (string String)
Converts all characters in a string to uppercase

string StrToLower(string String)
Converts all characters in a string to lowercase

string StrReplace(string String, string OldValue, string NewValue)
Replaces all occurrences of a specified String in string parameter, with another specified String.

string StrExtract(string String, char separatorChar, int Pos)
Returns a string that contains the substring of string parameter at the given zero based position (Pos) in string parameter that is delimited by one of the characters (separatorChars)
For example, if the current string is ” My.name.is.John “, separatorChar is “.” and Pos is 1, the StrExtract method returns ” name “.

string StrReverseExtract (string String, char separatorChar, int Pos)
Returns a string that contains the substring of string parameter at reverse position (Pos) in string parameter that is delimited by one of the characters (separatorChars)
For example, if the current string is ” My.name.is.John “, separatorChar is “.” and Pos is 1, the StrExtract method returns ” is “.

int StrCompareMethod (String, StringToCompare)
Compares two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relationship to one another in the sort order.

int StrCompareNoCase Method (String, StringToCompare)
Compares two specified String objects, ignoring their case, and returns an integer that indicates their relationship to one another in the sort order.

bool StrEqualMethod (String, StringToCompare)
Compares two specified String objects, ignoring or honoring their case, and returns a Boolean that indicates their equivalence.

bool StrEqualNoCaseMethod (String, StringToCompare)
Compares two specified String objects, ignoring their case, and returns a Boolean that indicates their equivalence.


Example

Sample project “Expression_AA” attached illustrates use of expressions with operators and functions. In Application Architect as shown below, all the above operators and functions are used in the different parameters of the project.

Expressions Parameters

Download attachments: Expression_AA.7z


Created on: 13 Apr 2015 Last update: 13 May 2024