PCL and Customization > The PATRAN Command Language (PCL) Introduction > PCL Operators and Expressions
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
PCL Operators and Expressions
Hierarchy of Operators
PCL supports a wide range of operators including basic math and Booleans. Expressions are built from a set of operators, constants, variables, and functions. User functions and intrinsic functions can be used as operands. Uniary operators take a single operand to the right, and binary operators are placed between two operands. Numeric, logical and string operators are provided.
Certain operators take precedence over others (i.e., multiplication is done before addition). The precedence can be overridden by use of parentheses. The following list gives the operators in order of precedence from highest to lowest
.
Table 2‑1
Operators
 
 
 
Definitions
+
-
 
 
 
 
Uniary Plus or Minus, Logical Not
**
 
 
 
 
 
Exponentiation
*
/
 
 
 
 
Multiplication and Division
+
-
 
 
 
 
Addition and Subtraction
//
 
 
 
 
 
String Concatenation
<
>
<=
>=
==
!=
Relational Operators
||
&&
 
 
 
 
Logical Or, Logical And
+=
-=
=
 
 
 
Increment, Decrement, Assignment
The following table is list of operators giving the datatypes that they can operate on and the result datatype for the operation. In the table, the letters I, R, S, L, and W stand for INTEGER, REAL, STRING, LOGICAL, and WIDGET respectively.
.
Table 2‑2
Operators
 
 
 
 
Operands
Result
**
*
/
+
-
+=
-=
I,R
I,R
//
 
 
 
 
 
 
S
S
<
>
<=
>=
 
 
 
I,R,S
L
==
!=
 
 
 
 
 
I,R,S,L,W
L
=
 
 
 
 
 
 
I,R,S,L,W
I,R,S,L,W
||
&&
 
 
 
 
 
L
L
 
Note:  
Expressions with a mixture of INTEGER and REAL data types are valid and will be converted to the assigned data type. Real to integer conversion truncates the fraction. All arithmetic expression evaluations are done in single precision.
Examples:
 
IVAL += 4 * SIND( MYANGLE )
IVAL is incremented by the integer value resulting from the calculation of (4 x sin(MYANGLE) and the truncation of all digits after the decimal point.
MYFUNC( ) >= (A+1)*2 && STR1 // STR2 == “TESTING”
Test for MYFUNC( ) greater or equal to (A+1)*2 and the concatenation of STR1 with STR2 logically equal to the string “TESTING”.
An example of using operators to find the two real roots of a quadratic equation in PCL:
	IF ( b**2 > 4.0 * a * c && ABS(a) >= 1.0E-7) THEN
    	root(1) = ( -b + SQRT( b**2 - 4.0 * a * c )) / (2.0*a)
    	root(2) = ( -b - SQRT( b**2 - 4.0 * a * c )) / (2.0*a)
	END IF
String Comparisons:
The string comparison operators are special in that they ignore trailing blanks and uppercase and lowercase. Therefore, all the following expressions are TRUE.
“ABC” == “ABC”
“ABC” == “abc”
“TEST” == “TEST”
“HELLO” < “help”
“hello” < “HELP”