PCL and Customization > The PATRAN Command Language (PCL) Introduction > Basic Concepts
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Basic Concepts
Patran and PCL
PCL is tightly coupled with Patran. The user interface system is integrated with PCL via callbacks. What this means is whenever a menu item is selected or a button clicked on, a PCL function is called to process the operation. In a similar fashion, after entering a line into the command line, that line is sent to PCL for processing. If a session file for processing is selected, the session file manager passes to PCL any lines that it does not handle itself.
 
Important:  
Examples in the following sections are excerpts from working PCL functions. By themselves, they are incomplete and will not execute properly.
PCL Commands
PCL statements come in many forms. Some examples of PCL statements include:
theta = 360.0 - MTH_ASIND( value )
IF ( radius > 20.0 ) THEN radius = 20.0
make_gear ( 30, 100 )
PCL commands may be entered interactively through the command line, or processed in a session file or retrieved from an external PCL file or library.
A PCL statement is normally terminated by a carriage return. A statement can be continued across multiple lines by using an at sign “@” as the last non-blank character of the line to be continued. It is not permissible to break a statement in the middle of an identifier, keyword, or constant value. It is possible to have multiple statements on a single line by separating them with a semicolon “;”. In general, break a line at a space, comma, or operator. Multiple spaces and/or tabs are treated as a single space.
Example:
IF( str_length( mystring ) >= 100 || @
		bigarray(n) < bigarray(n+1) ) THEN quit = TRUE
x = 5; y = 10; z = x * ( y + 5 )
PCL Comments
In PCL a comment is specified by starting with the sequence /* and ending with the sequence */. Comments may appear anywhere within a PCL statement except in the middle of a string constant. A comment may span multiple lines. A one line comment can also be specified by a dollar or pound sign as the first non-blank character. Examples of PCL comments include:
FillRadius = 5.0   /* Outside fillet radius */
and the following sequence:
/*
* A typical header block comment might look like this
*/
 
or a one line comment with:
$ This is a comment.
# This is a comment too.
PCL Embedded in NOODL Commands and Databoxes
A PCL expression can be embedded within any NOODL command by enclosing it in a set of backquote characters, ( ` ). Also PCL expressions can be embedded within most of the user interface databoxes in the same manner.
An example use of PCL within a NOODL would be:
LI,3#,ARC,5(0)/1/`30 + offset`,10
To use Patran as a calculator for example, enter:
!$` SQRT(250.) * 12.4`
and the response is made into the originating TTY window:
$ 196.0612
Be sure to preface any calculator directives with the “!$” sequence so that Patran does not attempt to process the line as a Patran command.
Another way to use Patran as a calculator is to use the write function.
WRITE (SQRT(250.) *12.4)
And the response is made into the command line:
$# 196.0612
In a user interface databox, use the backquote syntax such as:
Angle: ‘360/5‘
Identifiers
An identifier is a one to thirty-one character name containing letters, digits, and underscores and beginning with a non-digit character. Variable names and function names are identifiers. PCL is not sensitive to uppercase and lowercase for all uses of identifiers and keywords. String contents are retained as case sensitive, but string comparisons are case insensitive.
Keywords are identifiers reserved for use by PCL. These cannot be used as variable or function names. Current PCL keywords include:
 
BREAK
BY
CASE
CLASS
CLASSWIDE
CONTINUE
DEFAULT
DUMP
ELSE
END
FALSE
FOR
FUNCTION
GLOBAL
 
 
IF
INFORMATIVE
INTEGER
LIST
LOCAL
LOGICAL
ON
READONLY
REAL
REPEAT
RETURN
STATIC
STRING
SWITCH
THEN
TO
TRUE
UNTIL
VIRTUAL
WHILE
WIDGET
WIDGET_NULL
 
 
Some examples of valid identifiers are:
a, b, c, X1, x_2, InnerRadius
TryAgain, not_done
While the following are invalid:
_status, 10b (Variable names must begin with a letter.)
real, list (Variable names must not be reserved.)
This_is_Much_Much_Much_Much_too_long (Variable names may contain up to 31 characters.)
Directives
Directives begin with “!!” and are processed differently than regular PCL statements. Directives are processed immediately when encountered. Do not embed directives into PCL functions. Unexpected results may occur. Directive key words are:
 
!!INPUT file
Direct Patran to process all further input from the specified file.
!!LIBRARY file
Access PCL libraries.
!!PATH Directory
Specific directory search path for opening files.
!!TRACE option
PCL execution verification.
!!DEBUG option
Store PCL line contents in file for future reference when debugging PCL code.
!!COMPILE file into library
Compiles a PCL text file into library format.
!!OPTIONS option
PCL environment options setting.
!!SIZE CODE newsize
Set new size for compiler code area.
!!CLEAR GLOBAL name
Erase definition of global variable.
!!CLEAR FUNCTION name
Erase definition of a function.