patran 2010 pcl and customization

of 918 /918
Patran 2010 PCL and Customization

Author: don

Post on 18-Nov-2014

116 views

Category:

Documents


7 download

Embed Size (px)

DESCRIPTION

This manual describes how to use PCL to customize Patran by adding new functionalities.

TRANSCRIPT

Patran 2010PCL and Customization

CorporateMSC.Software Corporation 2 MacArthur Place Santa Ana, CA 92707 USA Telephone: (800) 345-2078 Fax: (714) 784-4056

EuropeMSC.Software GmbH Am Moosfeld 13 81829 Munich, Germany Telephone: (49) (89) 43 19 87 0 Fax: (49) (89) 43 61 71 6

Asia PacificMSC.Software Japan Ltd. Shinjuku First West 8F 23-7 Nishi Shinjuku 1-Chome, Shinjuku-Ku Tokyo 160-0023, JAPAN Telephone: (81) (3)-6911-1200 Fax: (81) (3)-6911-1201

Worldwide Webwww.mscsoftware.com

DisclaimerThis documentation, as well as the software described in it, is furnished under license and may be used only in accordance with the terms of such license. MSC.Software Corporation reserves the right to make changes in specifications and other information contained in this document without prior notice. The concepts, methods, and examples presented in this text are for illustrative and educational purposes only, and are not intended to be exhaustive or to apply to any particular engineering problem or design. MSC.Software Corporation assumes no liability or responsibility to any person or company for direct or indirect damages resulting from the use of any information contained herein. User Documentation: Copyright 2010 MSC.Software Corporation. Printed in U.S.A. All Rights Reserved. This notice shall be marked on any reproduction of this documentation, in whole or in part. Any reproduction or distribution of this document, in whole or in part, without the prior written consent of MSC.Software Corporation is prohibited. The software described herein may contain certain third-party software that is protected by copyright and licensed from MSC.Software suppliers. Contains IBM XL Fortran for AIX V8.1, Runtime Modules, (c) Copyright IBM Corporation 1990-2002, All Rights Reserved. MSC, MSC/, MSC Nastran, MD Nastran, MSC Fatigue, Marc, Patran, Dytran, and Laminate Modeler are trademarks or registered trademarks of MSC.Software Corporation in the United States and/or other countries. NASTRAN is a registered trademark of NASA. PAM-CRASH is a trademark or registered trademark of ESI Group. SAMCEF is a trademark or registered trademark of Samtech SA. LS-DYNA is a trademark or registered trademark of Livermore Software Technology Corporation. ANSYS is a registered trademark of SAS IP, Inc., a wholly owned subsidiary of ANSYS Inc. ACIS is a registered trademark of Spatial Technology, Inc. ABAQUS, and CATIA are registered trademark of Dassault Systemes, SA. EUCLID is a registered trademark of Matra Datavision Corporation. FLEXlm is a registered trademark of Macrovision Corporation. HPGL is a trademark of Hewlett Packard. PostScript is a registered trademark of Adobe Systems, Inc. PTC, CADDS and Pro/ENGINEER are trademarks or registered trademarks of Parametric Technology Corporation or its subsidiaries in the United States and/or other countries. Unigraphics, Parasolid and I-DEAS are registered trademarks of UGS Corp. a Siemens Group Company. All other brand names, product names or trademarks belong to their respective owners.

P3:V2010:Z:CUS:Z: DC-USR-PDF

ContentsPCL and Customization

PCL a tion,

1

Introduction to CustomizationUnderstanding PCL 2 3 Steps to Adding a New Functionality to Patran

2

The PATRAN Command Language (PCL) IntroductionIntroduction 6 Basic Concepts 7 Patran and PCL 7 PCL Commands 7 PCL Comments 7 PCL Embedded in NOODL Commands and Databoxes Identifiers 8 Directives 9 PCL Variables and Constants Data Types 10 Scope 12 Arrays 13 Variable Initialization 17 Argument Declaration 18 PCL Operators and Expressions Hierarchy of Operators 19 Control Statements 21 Branching 21 Break and Continue 21 Simple If Then 21 If Then Else 21 Switch and Case 22 Looping 23 For 23 While 23 Repeat 24 10

8

19

4 PCL and Customization

List

24

PCL Functions 25 Structure of a PCL Class 25 Structure of a PCL Function 26 Accessing PCL Functions 28 Libraries 28 Path Directive 29 The C Preprocessor 31 33

Finding Programming Errors with PCL Trace Directive 33 Debug Directive 33 Initializing the Session 35 PCL Start-Up File 35 Session Files Support in PCL

35

3

Basic FunctionsIntrinsic Functions 44 Math Functions 44 String Functions 59 Block I/O Functions 78 File Utility Functions 81 Record I/O Utility Functions 97 Stream I/O File Utility Functions 110 String I/O Conversion Utility Functions Text File I/O Utility Functions 126 Virtual I/O Scratch File Utility Functions Console I/O Functions 144 Message System Functions 155 Event Manager 161 Session File Functions 163 Obsolete File I/O Functions 169 Graphics Functions 175 Graphics Manager 175 Retained Graphics 175

120 136

4

System and Utility FunctionsSpawning a Process 186

CONTENTS 5

Database Locking System Functions

187 188

5

User Interface and List Processor FunctionsIntroduction 220 General Form Style 225 General Forms 225 General Widgets 229 Box Widgets 239 Switch 244 Creating Forms and Widgets Using PCL widget Function Descriptions 256 246

List Processor 258 File lpenums.i 259 Example: Creating a Simple Customized Menu and Form User Interface Functions 297

293

6

Creating New Analysis Forms Using PCLIntroduction 422 423 Updating Patran Release 1.1 Analysis Forms Naming Convention 424 425 426

The Analysis PCL Library

Contents of the Analysis Library The Main Analysis Form 427

Main Analysis Form Functions 429 Changing the Appearance 429 _load_aom_data 432 Subordinate Analysis Forms and Functions The Class 438 Fetching Data From analysis_main 440

437

6 PCL and Customization

7

Modifying the Database Using PCLIntroduction 446 447 451 452 Querying the Patran Database

Loading Definitions for MSC Supported Preferences Loading Definitions for User Defined Preferences Loading Basic Definitions 453 459

Adding A New Analysis Preference 454 Custom Data and Application Region Sub-Forms Adding New Element Types/Properties Adding the New Material Properties 517 468

Adding New Loads and Boundary Conditions Adding Custom General Field Functions Adding Functions to the Database 568 Evaluator PCL 570 An Example Case 574 567

540

Adding New Multi-Point Constraint Definitions Adding Element Verification Parameters Examples of Modifying the Database 586 582

577

8

Accessing the Patran DatabaseIntroduction 591 592 593 Syntax of Documented Calls

Calling the Database Access Functions from C and FORTRAN External Access of the Patran Database Miscellaneous Database Functions Groups 600 602 607 596 595

Nodes 602 Exporting Node Data Importing Node Data

CONTENTS 7

Coordinate Frames 609 Exporting Coordinate Frame Data Importing Coordinate Frame Data Patran Element Topology Codes Elements 615 Exporting Element Data Importing Element Data 615 622

609 609 613

Element Properties 625 Exporting Element Property Data Importing Element Property Data

625 635 640

Association between Elements and Element Properties 640 Extracting Association between Elements and Element Properties Data Fields 643 Importation of Data Fields 653

Material Properties 672 Exportation of Material Data 672 Importation of Material Data 683 Exportation of Composite Material Creation Data Load Cases 692 Exportation of Load Case Definitions 692

687

Loads 700 Evaluation of Loads on Finite Element Entities Exportation of Load Data 700 Importation of Load Data 729 Multi-point Constraints 751 Exportation of Multi-point Constraint Data Importing Results 767 Drop Results Indexing 767 Create/Find Loadcases 768 Associate Global Variables 770 Create Result Types 770 751

700

Examples of Translation 790 Results Reader 790 Extracting Temperature Dependent and/or Non-Linear Material Data Extracting Transient Load Histories 812 Forward Moldflow Translator 816

797

8 PCL and Customization

9

PATRAN 2.5 Database CompatibilityIntroduction 822 823 PATRAN 2.5 Compatible Database Functions

10

Broken, Obsolete, Modified and New FunctionsIntroduction 842 843 844 847 865 Basic Functions (Chapter 3)

System and Utility Functions (Chapter 4)

User Interface and List Processor Functions (Chapter 5) Possible parm names: 854 Creating New Analysis Forms Using PCL (Chapter 6) Modifying the Database Using PCL (Chapter 7) Accessing the Patran Database (Chapter 8) 873 879 866

PATRAN 2.5 Database Compatibility (Chapter 9)

Chapter 1: Introduction to Customization PCL and Customization

1

Introduction to Customization

Understanding PCL Steps to Adding a New Functionality to Patran

2 PCL and CustomizationUnderstanding PCL

Understanding PCLThe PATRAN Command Language, or PCL, is central to all Patran customization. PCL is used to: Create functions to be called directly from Patran. Create forms and widgets. Call functions from all areas of Patran including all applications, graphics, the user interface, and

the database. Spawn individual remote processes outside of Patran.

The chapters listed below will present information covering all of these topics. The PATRAN Command Language (PCL) Introduction User Interface and List Processor Functions System and Utility Functions

For more information concerning a particular function, refer to the Introduction (p. 9) in the PCL Reference Manual. Important:As with any powerful programming language, the user is encouraged to take formalized training available from the MSC Institute of Technology to best exploit the underlying functionality and to minimize resulting problems.

Chapter 1: Introduction to Customization 3Steps to Adding a New Functionality to Patran

Steps to Adding a New Functionality to PatranIn order to add a new analysis code to Patran three steps must be performed. First, modify the database to contain data about the new analysis code. This is done through PCL function calls. The resulting database will possess the information needed to display the new analysis code on the analysis preferences form. The preferences form allows the creation of element property, material property, loads and boundary condition, and multi-point constraint forms specific to the new analysis code. Also, element verification parameters specific to the new analysis code can be employed. This first step is fully described in Modifying the Database Using PCL. Second, specific PCL functions to control the Analysis forms used for the new analysis code must be created. These routines will be used to create a PCL library which will be brought into Patran automatically when the analysis preference is set to the new analysis code. These forms can be as simple or as complex as desired. Creation of these Analysis forms is described in detail in Creating New Analysis Forms Using PCL. Third, a translator must be created to import and export data to and from the Patran database. The functions used to extract, add or evaluate data stored in a database are discussed in the final two chapters. Accessing the Patran Database (Ch. 8) describes the standard Patran database interface, and PATRAN 2.5 Database Compatibility (Ch. 9) discusses database functions which are compatible with PATRAN 2.5.

4 PCL and Customization

Steps to Adding a New Functionality to Patran

Chapter 2: The PATRAN Command Language (PCL) Introduction PCL and Customization

2

The PATRAN Command Language (PCL) Introduction

Introduction

6 7 10 19

Basic Concepts

PCL Variables and Constants PCL Operators and Expressions Control Statements PCL Functions 25 31 21

The C Preprocessor

Finding Programming Errors with PCL Initializing the Session 35

33

6 PCL and CustomizationIntroduction

IntroductionThe PATRAN Command Language (PCL) is a programming language which is an integral part of the Patran system. It can be used to write application or site specific commands and forms, perform variational or connatural modeling, and completely integrate commercial or in-house programs. The entire Patran user interface is driven by PCL. PCL is a high level block structured language. It provides many features found in traditional programming languages including: Operators for arithmetic, relational, and string expressions. Intrinsic functions for math, string, and other operations. Variables with type, scope, and dimension attributes. Dynamically allocated virtual strings and arrays. Loop control structures such as WHILE, FOR, LIST, and REPEAT. Conditional control such as IF-THEN-ELSE and SWITCH-CASE. Subroutine and function calls from within PCL functions. Class grouping of related functions. Read/write access to external files. Support for PATRAN 2.5 NOODL rule. Preference to user interfaces, applications, databases, and graphics. PCL specific start-up files. Text output to the history window, session file, or TTY terminal.

PCL is a complete MCAE programming environment that greatly enhances the versatility of the Patran system. Some of the benefits of PCL include: Application specific commands provide more accurate modeling. For example, pressure applied

as a function of chord length along a turbine blade. In-line expressions make Patran more versatile for the everyday user. Allows Patran to be integrated more easily and completely with other commercial or in-house

codes. Provides a mechanism for parametric design studies. Patran may be customized to service specific customer requirements.

Chapter 2: The PATRAN Command Language (PCL) Introduction 7Basic Concepts

Basic ConceptsPatran and PCLPCL 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 CommandsPCL 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 CommentsIn 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 */

8 PCL and CustomizationBasic Concepts

or a one line comment with:$ This is a comment. # This is a comment too.

PCL Embedded in NOODL Commands and DataboxesA 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

IdentifiersAn 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:

Chapter 2: The PATRAN Command Language (PCL) Introduction 9Basic Concepts

BREAK CONTINUE FALSE LOCAL REPEAT THEN WHILE

BY DEFAULT FOR IF LOGICAL RETURN TO WIDGET

CASE DUMP FUNCTION INFORMATIVE ON STATIC TRUE WIDGET_NULL

CLASS ELSE GLOBAL INTEGER READONLY STRING UNTIL

CLASSWIDE END LIST REAL SWITCH VIRTUAL

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.)

DirectivesDirectives 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 !!LIBRARY file !!PATH Directory !!TRACE option !!DEBUG option !!COMPILE file into library !!OPTIONS option !!SIZE CODE newsize !!CLEAR GLOBAL name !!CLEAR FUNCTION name Direct Patran to process all further input from the specified file. Access PCL libraries. Specific directory search path for opening files. PCL execution verification. Store PCL line contents in file for future reference when debugging PCL code. Compiles a PCL text file into library format. PCL environment options setting. Set new size for compiler code area. Erase definition of global variable. Erase definition of a function.

10 PCL and Customization

PCL Variables and Constants

PCL Variables and ConstantsPCL variables have the attributes of type, scope, and dimension. All variables must be defined before they are used. Variable names may be 1 to 31 characters in length. Valid variable types are integer, real, logical, string, and widget. Scope defines a variable's visibility and lifetime.

Data TypesAll PCL variables must be declared before they are used. The declaration specifies the variable's type, scope and dimension.

DynamicA dynamic data type is a data type that is used to describe an input argument, output argument, or return value from a built in PCL function that can be any combination of an integer, logical, real, string, or widget data type. This data type is denoted in a PCL function description in this manual using an acronym: DYNAMIC_ILRSW. The ILRSW component in the acronym will be used to denote the exact data types that can be used with that value where I is used for an integer, L is used for logical, R is used for a real, S is used for a string, and W is used for a widget data type. The dynamic data type is not supported by the PCL language and trying to declare a variable with a dynamic data type will generate an error. While it is possible for built in functions to use the dynamic data type, it is not possible to write a PCL function that uses this data type. An example of a PCL function that returns a dynamic data type is the function sys_eval, 200.

IntegersAn integer variable is defined by prefixing the variable name with the keyword INTEGER. Example:INTEGER a, b, c

An integer constant is represented by an optional plus or minus sign followed by a set of digits. The range of an integer is machine dependent but will always be able to represent a number between -2147483647 and 2147483647. It is also acceptable to use a hexadecimal constant by having the prefix 0x or 0X followed by hexadecimal digits in uppercase or lowercase.

Examples:

Chapter 2: The PATRAN Command Language (PCL) Introduction 11PCL Variables and Constants

4510, -17, 0X11E0

(The first two examples show positive and negative integer constants. In the third example, the prefix 0X indicates that 11E0 is a hexadecimal constant.)

LogicalsA logical variable is defined by prefixing the variable name with the keyword LOGICAL. Example:LOGICAL exit_flag

A logical constant is represented by the reserved identifiers TRUE and FALSE. Examples:exit_flag = TRUE

orexit_flag = FALSE

RealsA real variable is defined by prefixing the variable name with the keyword REAL.Example: REAL x, y, z, height

A real constant is represented by an optional plus or minus sign followed by an optional set of digits, a required decimal point, another optional set of digits, and an optional E followed by an optional plus or minus sign and a set of digits. There always needs to be at least one digit before or after the decimal point. The range and precision of real numbers is machine dependent, but count on 5 digits of accuracy and an exponent range of 1.E-30 through 1.E30. Examples:x = 4100.06; y = -22.E-4; z = -1.0E3

StringsA string variable is defined by prefixing the variable name with the keyword STRING and appending the maximum string length as a positive integer within square brackets. Example:STRING name[20], option[130]

A character string constant is represented by a double quote, a string of characters, and another double quote. A character string which spans lines should do so by splitting it into smaller pieces and

12 PCL and Customization

PCL Variables and Constants

concatenating the pieces together. A character string has both a maximum length and a current length. The current length of a character string can be anywhere from zero up to its maximum length. Examples:name = I multiplier = 23*A option = A CHARACTER STRING WHICH SPANS LINES SHOULD DO SO // @ BY SPLITTING IT INTO SMALLER PIECES AND // @ CONCATENATING THE PIECES TOGETHER.

PCL strings are variable length up to the maximum size that they are declared. Therefore, the series of statements:STRING line = line = line = line[40] ABC line // line // DEF

produces the variable line defined as ABC DEF with no trailing blanks. This is quite different than the way FORTRAN strings work.

WidgetsA widget variable is defined by prefixing the variable name with the keyword WIDGET and is used only for working with the user interface routines. A widget can be assigned from a user interface function or other widget or can be compared against another widget. Example:WIDGET myform, mybutton

The only widget constant defined is WIDGET_NULL. If a user interface routine fails to operate sucessfully, the widget value returned will normally be WIDGET_NULL. To initialize widget variables, initialize them to WIDGET_NULL. Examples:IF ( myform == WIDGET_NULL ) THEN WRITE (Form not initialized)

ScopeScope defines a variable's visibility and lifetime. Variables that are not assigned a scope behave like LOCAL variables if declared within a function definition or like GLOBAL variables if declared outside of a function. PCL variables may have the scope of global, local, static, or classwide. These scopes are defined below.

Chapter 2: The PATRAN Command Language (PCL) Introduction 13PCL Variables and Constants

GLOBAL LOCAL

Variable definition is available to all functions. Global variables become undefined when Patran terminates. Variable definition is local to a single function. A local definition temporarily overrides any global definition. Local variables become undefined when the function exits. Variable definition is local to a single function. A Static variable retains its value between function calls. Static variables become undefined when Patran terminates. Variable definition is local to a group of functions. A classwide variable retains its value between function calls. Classwide variables become undefined when Patran terminates.

STATIC

CLASSWIDE

Important: PCL uses a flat name space for both function names and variable names. The user should be careful not to use conflicting names for PCL variables and functions. Examples: GLOBAL LOGICAL flag. Flag is defined global and since outside of a function definition is defined for use in the command line and in databoxes.

CLASS my_class The string line is defined within all the functions within the class CLASSWIDE STRING line[80] my_class. FUNCTION MY_FUNCTION (arg_list) STATIC INTEGER entries LOCAL REAL x,y,z. REAL arg_list () GLOBAL LOGICAL flag. The value established for entries in MY_FUNCTION remains the same between function calls. These variables are only defined within my_function. Since arg_list is an argument to the function, its scope is inherited from the calling function. Even though flag is defined GLOBAL outside the function, within each function definition it needs to be declared the same way. All references to flag affect the same global value.

END FUNCTION END CLASS

ArraysDirectly Allocated Arrays Any variable, regardless of its data type, can be made into an array. Arrays can have any number of subscripts. Subscripts are contained in parentheses separated by commas appended to the variable identifier. Each subscript may have a lower and upper bound separated by a colon. If the subscript range

14 PCL and Customization

PCL Variables and Constants

is not specified with a lower and upper bound, the lower bound is assumed to be one (not zero as in the C programming language). Subscript bounds may be negative or zero. Arrays are stored in sequential order starting from the subscript to the right and moving to the left. This is opposite to the way FORTRAN stores array data, see Figure 2-1 LOCAL arrays are only allocated when the function is called and the memory is freed up when the function exits. Memory for arrays of other scopes remains allocated for the duration of the programs execution.

Examples:STATIC INTEGER entries(100) REAL table(-5:10, 20, 5:7) The subscript 100 creates a STATIC array of 100 integers referenced by 1 to 100. The first subscript of table, -5:10, allocates 16 rows which are referenced by the bounds of -5 to 10. The second subscript allocates 20 rows. The third subscript allocates three sets of data referenced by 5 to 7. The total array occupies 16*20*3 or 960 storage locations. The logical array flags occupies 8193 storage locations referenced by 0 to 8192. 100 strings of variable line, 80 characters each and 10 x 5 strings of variable ch, one character each. The integer array I occupies 15 storage locations arranged in order where the rightmost subscript varies most rapidly.

GLOBAL LOGICAL flags(0:8192) STRING line[80](100), ch[1](10,5) INTEGER I(3,5)

An array constant can be specified by enclosing a set of constant values in square brackets. The following examples will best illustrate the syntax.

Chapter 2: The PATRAN Command Language (PCL) Introduction 15PCL Variables and Constants

[1, 2, 3] [Ace, King, Queen,Jack] [1.1, 2.2], [17,5], [-8,0]]

A three element integer array. A string array constant. A real array constant dimensioned (3,2).

Figure 2-1

PCL Array Storage

When referencing arrays, a portion of the array may be specified by using a colon to separate the upper and lower bound. Examples: my_function( In this example, elements 10 through 30 of the node_list array are passed node_list(10:30) ) to my_function. Virtual Arrays Any variable can be defined as a virtual array instead of a directly allocated array. Virtual arrays do not have storage locations assigned to them at program initialization. The size and amount of storage is allocated as requested and can be reused for other virtual arrays. To declare a virtual array, use the keyword VIRTUAL in place of the subscripts for the declaration. For example:REAL mydata(VIRTUAL)

To allocate storage and specify lower and upper bounds, use the function SYS_ALLOCATE_ARRAY( array, lb1, hb1, lb2, hb2, lb3, hb3, lb4, hb4) passing 3, 5, 7, or 9 arguments depending on whether to allocate a virtual array to be one, two, three, or four dimensional. Once allocated, a virtual array can be used interchangeably with a non-virtual array. A different size array can be re-allocated with a subsequent SYS_ALLOCATE_ARRAY call, but the original contents of the array are lost. A different size array can be re-allocated to retain the old contents of the array with the SYS_REALLOCATE_ARRAY function. Storage can be freed with a SYS_FREE_ARRAY call. A virtual array with LOCAL scope is automatically freed when the function it is declared in exits. SYS_ALLOCATE_ARRAY returns a zero status on success and a non-zero if the allocation failed. err = SYS_ALLOCATE_ARRAY (mydata, 1, 1000 ) Allocate a one dimensional array. Or, to allocate a two dimensional array, enter:

16 PCL and Customization

PCL Variables and Constants

err = SYS_ALLOCATE_ARRAY (mydata, 1, 1000, 1, 20000)

Or, to re-allocate the two dimensional array, enter:err = SYS_REALLOCATE_ARRAY (mydata, 1, 30, 1, 20000)

SYS_FREE_ARRAY (mydata) err = SYS_ALLOCATE_ARRAY (moredata, -200, 200, 0, 20) SYS_FREE_ARRAY (moredata)

Free up the array storage space. Allocate a two dimensional array. Free up the array storage space.

To find out the dimension associated with any array, use the PCL command SYS_ARRAY_NBOUND( array ). The lower and upper bounds of an array are found by using the commands, SYS_ARRAY_LBOUND( array, bound ) and SYS_ARRAY_HBOUND( array, bound ). Virtual Strings A string can be defined as a virtual string instead of directly declaring the size of the string. Virtual strings do not have storage locations assigned to them at program initialization. The size and amount of storage is allocated as requested and can be reused for other virtual data. To declare a virtual string, use the keyword VIRTUAL in place of the string size for the declaration. For example:STRING line[VIRTUAL]

To allocate storage and specify the maximum size of the string, use the function SYS_ALLOCATE_STRING( string, maxsize). Currently, the string size must be between one and 32767. Once allocated, a virtual string can be used interchangeably with a non-virtual string. A different size string can be re-allocated with a subsequent SYS_ALLOCATE_STRING function, but the original contents of the string will be lost. A different size string can be re-allocated to retain the old contents of the string with a SYS_REALLOCATE_STRING function. Storage can be freed with the SYS_FREE_STRING function. A virtual string with LOCAL scope is automatically freed when the function it is declared in exits. SYS_ALLOCATE_STRING returns a zero status on success and a nonzero if the allocation failed. Virtual strings arrays are allowed, but currently a SYS_REALLOCATE_STRING may not be performed on one.

Chapter 2: The PATRAN Command Language (PCL) Introduction 17PCL Variables and Constants

err = SYS_ALLOCATE_STRING (line, 500) err = SYS_REALLOCATE_STRING(line, 800) SYS_FREE_STRING (line) STRING lines1[VIRTUAL](20), lines2[VIRTUAL](VIRTUAL) err = SYS_ALLOCATE_STRING(lines1,100)

Allocate a 500 character string. Now reallocated as a 800 character string. Free up the string storage space.

Allocate the array to have strings of 100 characters. err = SYS_ALLOCATE_STRING(lines2,80) err = SYS_ALLOCATE_ARRAY (lines2,1,20) Allocate a 20 element array of strings of 80 characters. SYS_FREE_STRING (lines1) SYS_FREE_STRING (lines2) SYS_FREE_ARRAY (lines2) To find out the maximum size of any string, use the PCL function STR_MAXLENGTH(string).

Variable InitializationVariables may be initialized with a value when they are declared. Initializations are specified by following the variable declaration with an equal sign (=) and then a constant of the correct type for the item being declared. If an array is being declared, there must be enough constants to initialize the entire array, separated by blanks or commas optionally enclosed in square brackets. GLOBAL variables defined within a FUNCTION definition cannot be initialized. CLASSWIDE variables also cannot be initialized currently. If a STATIC variable is initialized, the initialization takes place at compile time, and any modification to the value of the variable remains intact for the duration of the session. When GLOBAL or LOCAL variables are initialized, the initialization is identical to including the assignments following the declaration. This means that a LOCAL variable with initialization will be re-initialized on each entry into the FUNCTION in which it is defined. Important:Multi-dimension arrays are stored in row major order. This is opposite of FORTRAN's definition. Virtual arrays and virtual strings can not be initialized. Some example initializations are:REAL STRING INTEGER TABLE(2,3) = [ 10, 20, 30, 11, 21, 31 ] PROMPT[20] = This is a prompt I = 0, J = 17

18 PCL and Customization

PCL Variables and Constants

Argument DeclarationThe input and output parameters that are passed back and forth to a function are called arguments. Arguments to a function must be declared and must match the datatypes used within the function. Within a function, it is permissible and recommended that the values within an array or string definition be omitted. The function uses the dimension values of the arrays or strings specified in the calling argument in any case so it can be misleading to specify values for dimensions for the arguments. Some examples are:REAL ENTRY(5,20), ELEMTABLE(20,40) STRING ENTRYTITLE[40] = This is the title for the Entry Table STRING ELEMTITLE[15] = Type of Element INTEGER N, K . . . R = MY_FUNCTION (ENTRY, N, ENTRYTITLE ) . . . R = MY_FUNCTION (ELEMTABLE, K, ELEMTITLE ) . . . FUNCTION MY_FUNCTION (TABLE, POINTER, TITLE ) REAL TABLE() STRING TITLE[] INTEGER POINTER

Chapter 2: The PATRAN Command Language (PCL) Introduction 19PCL Operators and Expressions

PCL Operators and ExpressionsHierarchy of OperatorsPCL 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 + ** * + // < || += > && -= = = == != / Exponentiation Multiplication and Division Addition and Subtraction String Concatenation Relational Operators Logical Or, Logical And Increment, Decrement, Assignment Definitions Uniary Plus or Minus, Logical Not

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.

20 PCL and Customization

PCL Operators and Expressions

.

Table 2-2 Operators ** // < == = || Note: && > != = * / + += -= I,R S I,R,S I,R,S,L,W I,R,S,L,W L Operands I,R S L L I,R,S,L,W L Result

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 ) MYFUNC( ) >= (A+1)*2 && STR1 // STR2 == TESTING 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. 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

Chapter 2: The PATRAN Command Language (PCL) Introduction 21Control Statements

Control StatementsControl statements are used to transfer control to another section of the program. The following syntax conventions are observed in the following examples:REQUIRED KEYWORDSAll required keywords are identified in bold Courier font. entryItems in plain Courier font are descriptions of the expected entry. [label]Items enclosed in brackets are optional.

BranchingPCL is a block structured language. Language elements that control branching and skipping are the IF THEN ELSE, SWITCH CASE, BREAK and CONTINUE statements.

Break and ContinueThe BREAK and CONTINUE statements are only allowed within the body of FOR, WHILE, REPEAT, SWITCH and LIST statements. In addition, if the optional label field is given, the label must match one of the above block structures the statement is within. The CONTINUE statement causes transfer to the END statement processing for the block structure indicated by the label field or the most current block structure if no label is provided. This essentially causes the loop to repeat. The BREAK statement is similar except that it transfers control past the END statement, thereby terminating execution of the loop. The format of the two statements is as follows:BREAK [ label ] CONTINUE [ label ]

Examples:CONTINUE active_set_loop BREAK

Simple If ThenThe simple IF statement evaluates the logical expression in the clause. If the result is TRUE, the single statement immediately following the THEN keyword is executed. If the result is FALSE, then nothing happens. The IF statement structure is as follows: IF( logical_expression ) THEN statement

If Then ElseThe IF statement evaluates the expression in the clause. If the result is TRUE, the group of statements immediately following is executed and then control skips to the matching END IF clause. If the result is FALSE, then if there is an ELSE IF clause, it is evaluated and the preceding logic is repeated. If all results evaluate to FALSE, then the statements following the ELSE are executed. Multiple ELSE IF clauses are allowed. The IF statement structure is as follows:

22 PCL and CustomizationControl Statements

IF( logical_expression ) THEN statements... ELSE IF( logical_expression ) THEN statements ... ELSE statements ... END IF

The program statements within a conditional structure are normally indented to make it easier to read. PCL and Patran ignore all leading blanks in a line. Examples: In the following example of the IF THEN statement, a patch model is being adaptively meshed based on the previously evaluated strain energy density for the region defined by the patches in patch_list:IF ( strain_energy > max_threshold ) THEN el_length = el_length / 2.0 do_my_mesh( patch_list, QUAD, I,el_length ) ELSE IF ( strain_energy < min_threshold) THEN el_length = 2.0 * el_length do_my_mesh( patch_list, QUAD, I,el_length ) ELSE BREAK adapting /* Break out of loop called adapting */ END IF

Switch and CaseThe SWITCH statement starts by evaluating the expression in the clause. It then scans for each CASE statement in turn. Upon reaching the CASE statement, each expression in the CASE is evaluated. If there is an equality match of the CASE expression result and the SWITCH expression result, the statements up to the next CASE or DEFAULT are executed, and then control passes to the statement after the END SWITCH. If the DEFAULT is reached with no CASE expressions matching, then the statements following the DEFAULT will be executed. The DEFAULT clause is optional. See the Break and Continue, 21 statement for a description of the SWITCH label. The SWITCH statement structure is as follows:SWITCH(expression) [ label ] CASE(expression1,expression2,...) statements ... CASE(expression1,expression2,...) statements ... DEFAULT statements ... END SWITCH

As an example of using the SWITCH statement, a PCL function is used to interactively construct the element property cards based on the element configuration code. The function UI_READ_REAL prompts the user with the argument string and returns the real value input from the keyboard.SWITCH (el_config) CASE (2)

Chapter 2: The PATRAN Command Language (PCL) Introduction 23Control Statements

midm = UI_READ_REAL(ENTER MEMBRANE MATERIAL ID:) CASE (3) mids = UI_READ_REAL(ENTER SHELL MATERIAL ID:) CASE (mconfig) mass = UI_READ_REAL(ENTER TOTAL MASS:) CASE (sconfig) spring = UI_READ_REAL(ENTER SPRING CONSTANT:) DEFAULT WRITE_LINE(WARNING: ELEMENT CONFIG, el_config,UNDEFINED) END SWITCH

LoopingA loop is a repeated execution of a particular segment or group of statements. Loops include initialization, incrementation, execution and test. Loops may be nested within one another. Block structures used for looping in PCL are WHILE, REPEAT, LIST and FOR statements.

ForThe FOR statement begins by evaluating the first numeric expression and assigning it to the variable. Next, the second expression is evaluated and saved as the TO result. The third expression is evaluated and saved as the BY result. If the BY result is zero, an error occurs. If the BY result is positive and the variable value is greater than the TO result, control passes to the statement following the matching END FOR. If the BY result is negative and the variable value is less than the TO result, control also passes to the statement following the matching END FOR. Otherwise the statements in the body are executed. When the END FOR is reached, the variable is incremented by the BY result. The preceding logic is then repeated starting at the point after the expressions were evaluated. Also see the description of the Break and Continue, 21 statements. The FOR statement structure is as follows:FOR(variable=numeric_expr.TO numeric_expr. [ BY numeric_expr. ]) [ label ] statements... END FOR

WhileThe WHILE statement evaluates the expression in the clause. If the result is FALSE, control passes to the point after the matching END WHILE. Otherwise, the statements are executed and the preceding logic is repeated. Also see the description of the Break and Continue (p. 2-21) statements. The WHILE statement structure is as follows:WHILE( logical_expression ) [ label ] statements... END WHILE

The program statements within a loop structure are normally indented to make it easier to read. The following is an example of the use of WHILE and FOR statements. A text file containing node displacements in FORTRAN format 6E16.9 is read and stored in array node_disp with library utility function TEXT_READ. The file fid has previously been opened with a call to the library function TEXT_OPEN. The integer function TEXT_READ returns the value 0 for a successful read and non-zero otherwise.

24 PCL and CustomizationControl Statements

count = 0 WHILE ( TEXT_READ ( fid, %OF%%6E16.9%, O, node_dis ( count +1, 1:6)) == 0) count += 1 IF ( count > 10000) THEN WRITE_LINE(* DISCONTINUED READING FILE AT // @ 10,000 RECORDS) BREAK END IF END WHILE

RepeatThe REPEAT statement starts by executing the statements up to the matching UNTIL clause. Then the expression in the clause is evaluated. If the result is FALSE, the preceding logic is repeated. Otherwise, execution continues with the statement after the UNTIL. Also see the description of the Break and Continue, 21 statements. The REPEAT statement structure is as follows:REPEAT [ label ] statements ... UNTIL( logical_expression )

As an example of the REPEAT structure, the user is requested to input a grid ID. If an invalid ID is entered, the user is prompted until a valid ID is entered.REPEAT grid_id = UI_READ_INTEGER( INPUT GRID ID ) UNTIL ( VALID_GID(grid_id) )

ListThe LIST statement executes the statements in the body for each expression in the expression list. Each expression is evaluated in turn and assigned to the variable. For each assignment done, the statements in the body are executed. Also see the description of the Break and Continue, 21 statements. The LIST statement structure is as follows:LIST( variable=expression1 [,expression2, ...] ) [ label ] statements ... END LIST

In the following example of a LIST statement, the variable diameter is used to create both the inside and outside surface of a sphere. The variables x0, y0 and z0 are the global coordinates of the spheres origin.LIST ( diameter = inside_diameter, inside_diameter + thickness ) !GR,#,,`x0`,`y0 - diameter`,`z0` !LIN,2#,ARC,`x0`/`y0`/`z0`/`x0`/`y0`/`z0 + 1`/180,# !PA,8#,ARC,`x0`/`y0`/`z0`/`x0`/`y0 + 1`/`z0`/360,2# END LIST !HP,8#,2P,,`maxpid + 1`T`maxpid + 8`,`maxpid + 9`T`maxpid + 16`

Chapter 2: The PATRAN Command Language (PCL) Introduction 25PCL Functions

PCL FunctionsA PCL function is a self-contained program unit consisting of PCL statements. It can perform as a subroutine, breaking programs into logical modules and passing arguments back and forth to other PCL functions or to the main program. Or, it can return a calculated output quantity for the function. In addition, a PCL function can be used to perform both tasks. PCL functions are defined in files which can be created and modified with system level text editors. PCL functions are then compiled during a Patran session. A PCL function can call other functions. PCL functions can be called recursively. PCL provides the ability to group functions into named libraries using the LIBRARY command with options to ADD, REMOVE CREATE, DELETE and LIST. An extensive Patran library of functions is also available. The library contains the following categories of functions:

Patran Function Type Mathematical String System Utility Block I/O File I/O Record I/O Stream I/O String I/O Text I/O Virtual I/O Miscellaneous Session File MTH_ STR_

Function Prefix

SYS_, UTL_ BLOCK_ FILE_ RECORD_ STREAM_ STRING_ TEXT_ VIRTUAL_ XF_, UI_, IO_, MSG_, EM_ SF_

Structure of a PCL ClassPCL functions may optionally be grouped into PCL classes. A PCL class is simply a group of functions that may share a common set of variables. PCL classes are used primarily for working with the user interface routines. The first statement in a PCL class must contain the word CLASS and the name of the class. The last statement in a PCL class must be an END CLASS statement.

26 PCL and CustomizationPCL Functions

A PCL class may have a set of classwide variables. These variables are declared the same as other variables but must specify the scope CLASSWIDE and must appear between the CLASS statement and the first function definition. The syntax of a PCL class definition is:CLASS classname CLASSWIDE declarations... functions (see Structure of a PCL Function, 26)... END CLASS

Where classname is the name given to the class. To refer to a function that resides in a class, specify the classname, a period, and then the function name, i.e., classname.functionname.

Structure of a PCL FunctionThe first statement in a PCL function must start with the word FUNCTION. The last statement in a PCL function must be an END FUNCTION statement. A PCL function may have an argument list and may also calculate an output quantity for the function. If an argument list is present, it may contain input parameters from the calling program and/or output parameters which pass values back to the calling program or function. The RETURN [value] statement is used to return a calculated output quantity for the function. Since a FUNCTION may have more than one logical ending, the RETURN [value] statement can appear more than once. The optional value associated with the RETURN statement is the calculated output quantity of the function. The syntax of a PCL function definition is:FUNCTION fname( arglist ) declarations... statements... (and/or) NOODL commands END FUNCTION

Where fname is the function identifier. arglist is the argument list passed by the function. For the function to return a value, the following statement must be contained in the function:RETURN value

Whenever the statement RETURN is encountered in a PCL function, processing of the current function terminates and control is passed to the calling function. The return value is optional. Important:Variable names and function names conflict in PCL. PCL uses a flat name space for both. The WHILE loop discussed in a previous example is shown in the context of a complete function. The array node_disp is a GLOBAL variable which will hold the node displacement data for use later on

Chapter 2: The PATRAN Command Language (PCL) Introduction 27PCL Functions

during the Patran session. The function TEXT_OPEN opens a file and returns the integer value -1 when it is finished reading a file. The following listing is the complete PCL function:FUNCTION DISP_READ( file_name) /* ABSTRACT: Read a file containing node displacements * * INPUT: * file_nameOS level name of file containing *formatted records * SIDE EFFECTS: * GLOBALnode_dispNode displacements read and stored here */ GLOBAL REAL node_disp(10000,6) INTEGER count, i, fid STRING file_name[80] REAL nodes (6) /* Open file containing node displacements*/ IF ( TEXT_OPEN( file_name, or, 0, 0, fid) == 0 ) THEN count = 0 /* Read and store the data in the global variable node_disp*/ WHILE(TEXT_READ ( fid, %OF%%6E16.7%, O, nodes, ) == 0 ) count += 1 /* File is too large */ IF ( COUNT > 10000 ) THEN WRITE_LINE(* DISCONTINUED READING, file_name, @ AT 10,000 RECORDS ) BREAK END IF /* Each record contains six entries, three displacements * and three rotations. file is formatted FORTRAN 6E16.7 */ node_disp (count, 1:6) = nodes END WHILE /* Close the file */ TEXT_CLOSE(fid, ) ELSE WRITE_LINE(* CANNOT FIND FILE, file_name) END IF END FUNCTION

To use the DISP_READ function during a Patran session, the following command is entered in the command line.DISP_READ(displacements.dat)

If, for example, the file displacements.dat contains the desired data, DISP_READ accesses the file to read the displacement data into variable node_disp. To access the array node_disp, it must be defined as GLOBAL in the session by entering:GLOBAL REAL node_disp(10000,6)

28 PCL and CustomizationPCL Functions

Accessing PCL FunctionsOnce a text file has been created which defines the function, the file must be read into Patran so that it is accessible. There are two directives for achieving this:!!INPUT file !!COMPILE file [INTO] library_file

A directive is recognized by the two !! exclamation marks at the start of the line. Unlike a PCL statement, which is first compiled making it available for execution, PCL directives are executed immediately. The INPUT directive allows selection of an input file for further PCL or Patran commands. After receipt of an INPUT directive, commands will now be read from the specified operating system text file. When the end of that file is reached, input will return to the previous file or to the user. Input files can be nested several layers deep. This allows INPUT directives to be used similarly to the concept of including files found in other programming languages. PCL functions are always compiled into a binary format before being executed. If a function is simply entered or !!INPUT, the compile takes place on the fly. The COMPILE directive allows the function to be compiled into the binary format in advance and save the compiled form in a library file with other compiled PCL functions. Using this method the user avoids having to compile the function each time Patran is used. For the previous two function examples, the directives:!!INPUT nx !!INPUT disp_read

read the files nx.pcl and disp_read.pcl and allow access to the functions during the session in which the directives are issued. If the file type is not specified .pcl is assumed. To put the same two functions into the library my_library.plb, issue the directives:!!COMPILE nx my_library !!COMPILE disp_read my_library

If the library my_library does not exist in the current directory, executing the COMPILE directive will create it with maximum entries set to 256, otherwise, the files will be placed in the existing my_library. If a function by the same name exists in the library, it will be replaced and a message will be issued to the history window.

LibrariesA LIBRARY is a binary file containing any number of compiled PCL functions. A library provides a convenient mechanism for accessing and organizing compiled PCL functions. Whenever PCL is requested to execute a PCL function, it will search the set of libraries that have been specified in LIBRARY directives. The format of the LIBRARY directive is:!!LIBRARY [ ADD ] file [ file ....] !!LIBRARY REMOVE file [ file ....] !!LIBRARY NONE

Chapter 2: The PATRAN Command Language (PCL) Introduction 29PCL Functions

!!LIBRARY !!LIBRARY !!LIBRARY !!LIBRARY !!LIBRARY !!LIBRARY !!LIBRARY !!LIBRARY

CREATE file [ max_entries ] MERGE sourcefile destfile SORT file REHASH KEEPOPEN file [ file ....] DELETE file function [ function ...] LIST file [ function ... ]

Where file is the operating system name of a library to include in future searches. LIBRARY ADD directives are cumulative. Each one adds an additional library for which to search. The libraries are searched in the reverse order from when specified. The REMOVE option removes a library from the search. The NONE option clears the library search list. A null library command displays the current library search list. The CREATE option creates a new library which can contain up to the number of functions specified by max_entries, or if max_entries is zero, a growable library is created. (If max_entries is not specified it defaults to 256.) The MERGE option allows the entries to be merged or added from one library into another library. This operation can also be used to compress a library by creating a new library, merging the old library into the new library, and then replacing the original library with the new library. The SORT option allows the entries in the library to be sorted alphabetically to obtain a nicer listing. The REHASH option is rarely used but, it can recognize that the contents of the libraries in the library list may have been changed by another user or process and causes Patran to rebuild its optimization tables for all libraries. The KEEPOPEN option can be used for any library that is already in the library list and attempts to increase performance of accessing frequently used PCL libraries by keeping the operating system library file open all the time. The DELETE option is used to delete functions from a library. The LIST option lists the contents of a library providing date and size for each function. To access the library, my_library, issue the directive:!!LIBRARY my_library

The functions NX and DISP_READ may now be used at any time during the session. To eliminate the need for compiling functions each time they are used, try creating and saving libraries. Use the start-up files to issue the LIBRARY directive. The sys_library (option, data) function also allows access to the library functions and can be compiled into PCL functions or used within IF statements in PCL start-up scripts. Generally, the option is a string containing the operation such as ADD and the data is a string with the file or function names.

Path DirectiveTo exercise more control over the use of PCL files, the PATH directive defines the order in which a set of directories is searched to find files needed by PCL. These include the files referenced by the other directives as well as files used by many of the PCL intrinsic functions. Examples of files are libraries,

30 PCL and CustomizationPCL Functions

INPUT files, start-up files, and files opened by the file I/O utilities. The current directory is always searched first. The default PATH is often configured by the init.pcl file but normally contains the users home directory followed by any needed Patran system directories. The format of the PATH directive is:!! !! !! !! PATH [ ADD ] directory [directory ...] PATH REMOVE directory [directory ...] PATH NONE PATH

where directory is the operating system name of a directory to search. The directories are searched in order. The latest ADD is used first. Within an ADD, the directories are searched first to last. REMOVE will remove entries from the PATH. NONE will clear the PATH. A null PATH command will list the current PATH setting. The sys_path (option, data) function also allows access to the path and can be compiled into PCL functions or used within IF statements in PCL start-up scripts. Generally, the option is a string such as ADD and the data is a string with the directory name(s).

Chapter 2: The PATRAN Command Language (PCL) Introduction 31The C Preprocessor

The C PreprocessorDuring the development of Patran, the C preprocessor is used with C, FORTRAN and PCL source code. In other words, our source files are automatically sent through the C preprocessor prior to being sent to the specific compiler. Use of the C preprocessor has many advantages. It allows for substitutions which make the source much more readable. For example, with the C preprocessor a section of code could be written like this:#define NODE 1 #define ELEMENT 2 IF ( entity == NODE ) THEN xxx ELSE IF ( entity == ELEMENT ) THEN xxx END IF

instead of like this:IF ( entity == 1 ) THEN xxx ELSE IF ( entity == 2 ) THEN xxx END IF

Furthermore, these substitutions can be placed into an include file which would allow for centralization of the #define statements. Centralization of definitions into include files allows for cleaner and simpler code, ensures consistency and allows for changes throughout the code to be made very simply. If the two #define statements mentioned above were put into an include file called entity_codes.p then the above piece of code would be as follows:#include entity_code.p IF ( entity == NODE ) THEN xxx ELSE IF ( entity == ELEMENT ) THEN xxx END IF

If the entity_codes.p include file were used consistently through out all source then the element entity code could change from 2 to 3 by simply changing one line in the entity_code.p file. The same idea applies to character strings. If all character strings used in code are placed into include files then changing the text strings is a simple task. If the name of an application changed from in-house-code 5.3 to inhouse-code 5.4 it would only require one change in one file. The naming convention for include files in Patran is that PCL include files are suffixed with a .p, FORTRAN include files are suffixed with a .i and C include files are suffixed with a .h. An include file is only used for one language, so if the same type of file is to be used in FORTRAN, C and PCL there would be three files. In such a case there is always one master include file and then slave files which merely #include the master file. Continuing with our entity_code.p example, if this file were to be used in PCL, FORTRAN and C then there would be three include files (entity_codes.p, entity_codes.i and entity_codes.h) whose contents would be:-------Contents of entity_codes.p -------------/* Include file containing entity codes */ #define NODE 1 #define ELEMENT 2

32 PCL and CustomizationThe C Preprocessor

-------Contents of entity_codes.i -------------/* Include file containing entity codes */ #include entity_codes.p -------Contents of entity_codes.h -------------/* Include file containing entity codes */ #include entity_codes.p

Such exclusiveness of include files allows the developer to easily accommodate for the different requirements of different computer languages. Standard C compilers automatically send source files through the C preprocessor, so C source files do not need to be preprocessed prior to compilation. But, whenever C preprocessor commands are imbedded in FORTRAN or PCL source the source file must first be sent through the C preprocessor and the resulting file sent to the appropriate compiler. A typical C preprocessor command would be:cpp -P -I$P3_HOME/customization

See any C language manual for more on the C preprocessor. There are many PCL include files which are delivered with Patran in the $P3_HOME/customization directory: appforms.p, appstrings.p, uistrings.p, etc. Two of these include files, appforms.p and uiforms.p, are heavily used in the PCL functions which create Patran forms. The contents of these files are discussed in User Interface and List Processor Functions (Ch. 5).

Chapter 2: The PATRAN Command Language (PCL) Introduction 33Finding Programming Errors with PCL

Finding Programming Errors with PCLThere are two features in PCL that track the PCL program as it is processed: TRACE and DEBUG. These Debugging tools can be very useful when finding and correcting errors in the program logic. The first of these tools is the TRACE directive.

Trace DirectiveThe TRACE directive allows specification of tracing options during execution of PCL functions. The TRACE should normally be set to NONE. There are three options that can be enabled in TRACE; they are CALLS, EXITS, and LINES. When CALLS is set, each time a PCL function is called, a message is output. When EXITS is set, messages are output when PCL functions return control to their calling functions. When LINES is set, the current statement numbers are displayed as a function executes. In addition, if DEBUG was ON when the function was compiled, the source statements themselves will be displayed when LINES is set. The format of the TRACE directive is:!! !! !! !! !! !! !! . . . TRACE TRACE TRACE TRACE TRACE TRACE TRACE NONE(disable tracing) CALLS(enable tracing of NOCALLS(disable tracing EXITS(enable tracing of NOEXITS(disable tracing LINES(enable tracing of NOLINES(disable tracing function calls) of function calls) function exits) of function exits) function statements) of function statements)

!! TRACE CALLS LINES !! TRACE level mask is CALLS NOEXITS LINES . . .

Debug DirectiveThe second directive that is useful for debugging PCL programs is the DEBUG directive. The DEBUG directive allows specification of a debugging flag which affects future compilations. With DEBUG ON, the original source lines of the file are compiled into the function. This allows the TRACE command to display the source during execution. The DEBUG option should only be used during development as it creates much larger and slower code. The format of the DEBUG directive is:!!DEBUG ON(enable DEBUG lines during compile) !!DEBUG OFF(disable DEBUG lines during compile)

Don't forget to set TRACE to LINES when using the debug mode or compiling the function with DEBUG set to ON. Another feature provided by PCL is the DUMP command. The format of the DUMP command is:DUMP variable

Where variable is any currently declared variable.

34 PCL and Customization

Finding Programming Errors with PCL

When the DUMP statement is encountered during execution of any PCL function, the contents of the variable is displayed in the alpha buffer. For an example, we examine the variable xyz by putting the following statement in function NX.DUMP xyz

When the function NX is executed with a node located at the x=1,y=0,z=0 location, the following is displayed in the alpha buffer:Array: ( 3 ) Data: 1.0, 0.0, 0.0

Chapter 2: The PATRAN Command Language (PCL) Introduction 35Initializing the Session

Initializing the SessionPCL Start-Up FilePCL provides a means to control the session environment by reading the init.pcl file in the current directory when beginning a Patran session. The init.pcl file does not usually have to be modified. Instead, the init.pcl as delivered will execute the additional start-up files p3prolog.pcl and p3epilog.pcl. These files, if they exist, are executed at the start(p3prolog) and end (p3eiplog) of the init.pcl processing and are a good place to place user or site specific commands. Typical commands in the start-up files are custom !!PATH and !!LIBRARY settings. In addition, !!INPUT statements can be added to the start-up files to provide additional user or site start-up file capabilities.

Session Files Support in PCLThe purpose of adding session file support to PCL code is to allow a Patran session to be recreated when the session file is played. The sections below describe how an application developer may indicate the PCL commands that need to be recorded and played to duplicate a session. These PCL commands are known as events of interest. Controlling recording file contents There are tools available to the application developer to control the contents of a session file. They are described in the following sections. In general, it is desired that a session file only contains PCL function calls that affect the database (e.g., open/new/close database, create/modify/delete geometry, etc.). The following sections describe the tools which allow the application developer to control which function calls are recorded and how their parameters should be written to a session file (evaluated or symbolically). Additionally, the issue of recording user rotation events is addressed. PCL recording directive (>) The > directive is used to indicate that the function call on a line of PCL is an event of interest. When these events are executed, they are usually written to the session file. They are also sent to the history window at execution time. In situations where nested events of interest occur, only the first/top level event will be written to the session file. This prevents the recording of nested events, which would cause undesirable results. This directive should be placed in column one of a PCL statement. The intent of this directive is to allow an application that is not invoked from the command line (e.g., forms) to record only those PCL commands that affect the database. In this way, playback can suppress all application dependent user interfacing. Consider the following simple example of PCL code that operates the form to build a grid.asm_const_grid_xyz( 1,[0 0 0], CF 0,create_grid_xyz_created_ids))

36 PCL and CustomizationInitializing the Session

the > directive is placed on the line containing the call to be recorded as shown:> asm_const_grid_xyz( 1, [0 0 0], CF 0,create_grid_xyz_created_ids))

If the function is called from the command line or a session file, all the ">" in the function will be ignored. For example,FUNCTION simpoint() > STRING asm_create_grid_xyz_created_ids[VIRTUAL] > asm_const_grid_xyz( "#", "[1 0 0]", "Coord 0", asm_create_grid_xyz_created_ids ) END FUNCTION

Then execute at the command prompt (or via a session file)simpoint()

The asm command will not be written to the session file. The reason is that "simpoint( )" is already being written to the session file. If the asm line were written, it would be run twice; once by the simpoint function being called again, and once by the session file itself. The ">" directive only works if the function is called by a GUI. That is, if an "Apply" button, callback etc. is used in a custom form, then "simpoint()" is not written to the session file, so asm_... is. Variables in session files Occasionally, it is desirable to use more than one PCL function call with variables being passed from one function to another. There are two methods to allow this mechanism to work within the confines of a session file. Combining separate functions The first method requires the application developer to create a parent function which handles the variable passing from one function to another. This new parent function would be marked as the event of interest in the PCL code. For example, assume two functions PCLF1 and PCLF2 are being used. The parameter returned from PCLF1 is passed to PCLF2. This is handled as follows:FUNCTION PCLF1AND2 REAL arg1to2 PCLF1 (arg1to2, 45.5, 60, TRUE) PCLF2 (arg1to2) END FUNCTION /* PCLF1AND2 */

Variable substitution by name An alternate method causes Patran to automatically substitute the name of the variable rather than the value of the variable. This is accomplished with the $ directive. By placing the $ before any variable, the variable declaration is automatically written to the session file and the reference is symbolic (the name is used as opposed to its value). The variable declaration is automatically output to the session file. The following example illustrates another technique to handle the previous example.

Chapter 2: The PATRAN Command Language (PCL) Introduction 37Initializing the Session

> PCLF1 ($arg1to2, 45.5, 60, TRUE) > PCLF2 ($arg1to2)

Note:

Do not start a line with a $ before a variable. Patran recognizes lines that begin with $ as comment lines.

Direct writes to the Session File There are two PCL functions which allow the PCL applications developer to write directly to the session file. They are:sf_write( string ) sf_force_write( string )

The first function writes the string into the session file if session file recording. The second function forces the string into the current session file, assuming one is open and not paused, even if recording would not normally occur, i.e., nested function calls. This second function is probably most useful for either debugging PCL functions or adding comments to session files. Conditional recording of rotation function calls Sometimes it is not desirable to record every PCL function call. Some workstations that have hardware graphic accelerators may actually generate hundreds or thousands of function calls for a single user action (e.g., geometry scaling or rotations using a dial). For situations such as these, it is desirable to avoid recording these function calls, as they expand the session file without adding particularly interesting information. There are, however, situations where recording these function calls is desirable. The following PCL function allows the user to optionally record these rotation function calls:sf_rotation( )

This function call must be executed immediately before the call which performs the rotation. For example:IF( doit ) THEN sf_rotation() >gm_rot_x( .5 ) ENDIF

If the record rotations toggle on the Session File Record form is set, then the call to gm_rot_x is recorded. If the toggle is not set, the function call is not recorded. See Session File Functions, 163 for the location of this toggle. User controlled conditional recording There is also a PCL function to allow the user to control recording of the session file. This function allows the user to prevent the next function call from being recorded, based upon the value of its logical argument. The function is:sf_write_disable ( donext )

If the value of donext is TRUE, then the next function call to be recorded is executed normally, but is not recorded. For example:sf_write_disable ( not_completed )

38 PCL and CustomizationInitializing the Session

> asm_create_patch_xyz ( arg1, arg2 )

In this example, if the value of not_completed is TRUE, then the call to asm_create_patch_xyz is not recorded. Function calls used as arguments Although it is sometimes convenient to use the return value from a function as an argument to another function, when using the > directive this should generally be avoided. For example, consider:> funcx( funcy( x, y, z) )

If session file recording has not been disabled, both funcx and funcy are output. If one level is suppressed, then only funcx is recorded, (funcy recording is suppressed). Note also, that normally funcy gets recorded first, followed by funcx. Undo support In order to support the undo feature, applications should insure that all commands that can be written to a session file do not perform any database commits (uil_db_commit) either directly or indirectly (as a consequence of any command). The corresponding PCL code that handles the user interface is expected to perform the commit, passing a string that describes the operation that is about to take place. Sample PCL Functions with > directive

The following PCL file contains three functions which demonstrate all of the available session file recording controls:1 FUNCTION sftest 2 STRING string1[256], string2[256], string3[256] 3 4 string1 = FIRST string 5 string2 = The 2nd string 6 string3 = This is string 3 7 8/* Write a line to the session file */ 9sf_write(/* Written by sf_write */) 10 11/* Next function call records in session file */ 12> sub1 ( string1, string2 ) 13 14/* Record Arg 1 of next func as variable NAME, not VALUE 15> sub1( $string3, string1 ) 16 17/* Record Arg 2 of next func as variable NAME, not VALUE 18> sub2( string2, $string3 ) 19 20/* Demonstrate how nested >s act */ 21string3 = String 3 assigned by sftest 22 sub2 (string2, string3) 23 24 /* Disable session file recording for the next line */ 25 sf_write_disable(TRUE) 26> sub1 ($string3, string1) 27 sf_force_write(/* Written no matter what!) 28 29/* test record rotation functionality */ 30 sf_rotation() 31> ui_writec(!Recorded only if record rotations is ON)

Chapter 2: The PATRAN Command Language (PCL) Introduction 39Initializing the Session

32 END FUNCTION /* sftest */ 33 34 FUNCTION sub1 (c, d) 35 STRING c[256], d[256] 36> UI_WRITEC (SUB1: Arg1:%s - Arg2:%s\n, c, d) 37 END FUNCTION /* sub1 */ 38 39 FUNCTION sub2 (e, f) 40 STRING e[256], f[256] 41> sub3 (e, f) 42 f = SUB2 set this string! 43 END FUNCTION /* sub2 */ 44 45 FUNCTION sub3 (g, h) 46 STRING g[256], h[256] 47 sub3 (g, h) 48> UI_WRITEC (SUB3: Arg1:%s - Arg2:%s\n, g, h) 49 END FUNCTION /* sub3 */

Notes 1. Line 25 prevents line 26 from being recorded in the session file. Line 26 executes normally. 2. Line 30 prevents line 31 from being recorded in the session file if record rotations is off. The default condition is record rotations off. Line 31 always executes normally. 3. Line 36 never appears in the session file because function sub1() is always called from a line which contain the > directive. 4. Line 41 is recorded when function sub2() is called from line 22, but it is not recorded when function sub2 is called from line 18. The following text is the session file created by the execution of the PCL function sftest() documented above.1/# Session file recording started: 01/01/1991 00:00:00 2/* Written by sf_write */ 3sub1( FIRST string, The 2nd string ) 4STRING string3[256] 5sub1( string3, FIRST string ) 6sub2( The 2nd string, string3 ) 7sub3( The 2nd string, String 3 assigned by sftest ) 8/* Written no matter what! ** 9/# Session file recording stopped: 05/01/1991 12:05:39

Lines 1 and 9 are created by the Session File init and exit functions. They are not passed from one session file to another when playing and recording at the same time. Line 2 is recorded at execution of SFTEST line 9. Line 3 is recorded at execution of SFTEST line 12. Line 4 is recorded at execution of SFTEST line 15. Because this is the first use of argument string3 it is declared before it is used as an argument to the call. Line 5 is also recorded at execution of SFTEST line 15. Note that the first arg is recorded as string3 rather than the value of string3 -- this is activated by the $ directive immediately preceding string3 on line 15.

40 PCL and CustomizationInitializing the Session

Line 6 is recorded at execution of SFTEST line 18. Note that the second argument is recorded as string3 rather than the value of string3. Line 7 is recorded at execution of line 41 in function sub2. Since sub2 was executed without a > directive, > directives within sub2 are recorded. Line 8 is recorded at execution of SFTEST line 27. The following text is the output created by the execution of the PCL function sftest() documented above. Output from the PCL function to the startup window: 1. SUB1: Arg1:FIRST string - Arg2:The 2nd string 2. SUB1: Arg1:This is string3 - Arg2:FIRST string 3. SUB3: Arg1:The 2nd string - Arg2:This is string 3 4. SUB3: Arg1:The 2nd string - Arg2:String 3 set by sftest 5. SUB1: Arg1:SUB2 set this string! - Arg2:FIRST string 6. /* Recorded only if record rotations is ON Line 1 is printed from SUB1 when called from SFTEST line 12. Line 2 is printed from SUB1 when called from SFTEST line 15. Line 3 is printed from SUB3 when called from SUB2 line 41, which is called from SFTEST line 18. Line 4 is printed from SUB3 when called from SUB2 line 41, which is called from SFTEST line 22. Line 5 is printed from SUB1 when called from SFTEST line 26. Note that SUB1 is called, even though it is not recorded. Line 6 is printed from SFTEST line 31, but the ui_write call is not recorded in the session file, because the default condition is NOT to record rotations, and the sf_rotation() call on line 30 indicates that line 31 is a rotation function. The PCL Command Line Interpreter P3PCLCOMP The executable p3pclcomp provides an interface to a PCL interpreter that can be executed from the command line of a UNIX shell or a Windows NT command processor. The p3pclcomp executable functions exactly as the command line for Patran with two main differences. There is no graphics capability, and there is no access to databases. The runtime paths and libraries for p3pclcomp are also different, but this is simply because at start time, $P3_HOME/init.pcl is read by Patran and not by p3pclcomp. Commands that are supported by p3pclcomp include:!!input !!compile !!library !!path [all known options] [all known options] [all known options] [all known options]

and most PCL functions that do not deal with graphics or the database.

Chapter 2: The PATRAN Command Language (PCL) Introduction 41Initializing the Session

Possible uses of p3pclcomp include: Test compiles of PCL function code to check for syntax errors. Text execution of PCL functions that work without database or graphics, for example, file input and output functions. The creation and manipulation of PCL function libraries or .plb files. The p3pclcomp provides a good way to make libraries. A library named make_library.plb can be created using the following commands. !!compile test.pcl into my_library.plb The p3pclcomp executable can then be used with input from make_library.plb file. $P3_HOME/bin/p3pclcomp < make_library.plb The p3pclcomp executable can also be used to execute PCL commands provided through standard input, listing the results through standard output, allowing p3pclcomp to be used in script and batch files: echo "!!LIBRARY LIST "make_library.plb | $P3_HOME/bin/p3pclcomp > make_library.lst This command line will pass the PCL command "!!LIBRARY LIST make_library.plb" through the p3pclcomp executable. The p3pclcomp will create a list of all of the PCL functions included in the make_library.plb file to standard output. Standard output will then be redirected to the file "make_library.lst"

42 PCL and CustomizationInitializing the Session

Chapter 3: Basic Functions PCL and Customization

3

Basic Functions

Intrinsic Functions Graphics Functions

6 130

44 PCL and CustomizationIntrinsic Functions

Intrinsic FunctionsPCL has an extensive library of intrinsic functions accessible at any time. Each function name is prefixed with a several letter mnemonic which specifies the category. Most--but not all--PCL functions return a value. In the descriptions below, the definition of the return value is shown under the output parameters by using the name of the function as the variable name to be returned. PCL intrinsic functions are more flexible than normal PCL functions when it comes to passing simple integers and reals. If an intrinsic function calls for a non-array input only integer or real value, pass either an integer or a real for that argument and PCL will convert automatically to the needed type. Many PCL intrinsic functions are specific to the Patran environment and allow sophisticated control of the database and user interface. These PCL functions are documented elsewhere. The PCL functions documented here represent a core set of routines to perform many general operations such as math, string manipulation, and file input/output. The following documentation breaks down the intrinsic functions by categories.

Math FunctionsPCL contains a large number of intrinsic mathematical functions. Since the math functions are used so often, the prefix MTH_ is optional when referring to the Math Functions (unless otherwise specified in the documentation).

Chapter 3: Basic Functions 45Intrinsic Functions

.

mth_sindDescription:

( angle )

Return trigonometric sine value of the argument specified in degrees. Input: REAL Output: REAL The sine value. angle The angle in degrees for which to compute the sine

Error Conditions: None.

mth_asindDescription:

( value )

Return angle in degrees which corresponds to the trigonometric sine contained in the argument. Input: REAL Output: REAL None. The angle in degrees for the sine. Error Conditions: value The sine value for which to find the angle.

mth_cosdDescription:

( angle )

Return trigonometric cosine value of the argument specified in degrees. Input: REAL Output: REAL None. The cosine value. Error Conditions: angle The angle in degrees for which to compute the cosine.

46 PCL and CustomizationIntrinsic Functions

mth_acosdDescription:

( value )

Return angle in degrees which corresponds to the trigonometric cosine contained in the argument. Input: REAL Output: REAL The angle in degrees for the cosine. value The cosine value for which to find the angle.

Error Conditions: None.

mth_tandDescription:

( angle )

Return trigonometric tangent value of the argument specified in degrees. Input: REAL Output: REAL None. The tangent value. Error Conditions: angle The angle in degrees for which to compute the tangent.

mth_atandDescription:

( value )

Return angle in degrees which corresponds to the trigonometric tangent contained in the argument. Input: REAL Output: REAL None. The angle in degrees for the tangent. Error Conditions: value The tangent value for which to find the angle.

Chapter 3: Basic Functions 47Intrinsic Functions

mth_atan2dDescription:

( y, x )

Return angle in degrees which corresponds to the trigonometric tangent represented by the specified x and y components. Input: REAL REAL Output: REAL None. The angle in degrees for the tangent. Error Conditions: y x The y component of the tangent. The x component of the tangent.

mth_sinrDescription:

( angle )

Return trigonometric sine value of the argument specified in radians. Input: REAL Output: REAL None. The sine value. Error Conditions: angle The angle in radians for which to compute the sine.

mth_asinrDescription:

( value )

Return angle in radians which corresponds to the trigonometric sine contained in the argument. Input: REAL Output: REAL The angle in radians for the sine. value The sine value for which to find the angle.

48 PCL and CustomizationIntrinsic Functions

Error Conditions: None.

Chapter 3: Basic Functions 49Intrinsic Functions

mth_cosrDescription:

( angle )

Return trigonometric cosine value of the argument specified in radians. Input: REAL Output: REAL The cosine value. angle The angle in radians for which to compute the cosine.

Error Conditions: None.

mth_acosrDescription:

( value )

Return angle in radians which corresponds to the trigonometric cosine contained in the argument. Input: REAL Output: REAL None. The angle in radians for the cosine. Error Conditions: value The cosine value for which to find the angle.

mth_tanrDescription:

( angle )

Return trigonometric tangent value of the argument specified in radians. Input: REAL Output: REAL None. The tangent value. Error Conditions: angle The angle in radians for which to compute the tangent.

50 PCL and CustomizationIntrinsic Functions

mth_atanrDescription:

( value )

Return angle in radians which corresponds to the trigonometric tangent contained in the argument. Input: REAL Output: REAL The angle in radians for the tangent. value The tangent value for which to find the angle.

Error Conditions: None.

mth_atan2rDescription:

( y, x )

Return angle in degrees which corresponds to the trigonometric tangent represented by the specified x and y components. Input: REAL REAL Output: REAL The angle in radians for the tangent. y x The y component of the tangent. The x component of the tangent.

Error Conditions: None.

mth_sqrtDescription:

( value )

Return square root of the argument. Input: REAL Output: value The value for which to obtain the square root.

Chapter 3: Basic Functions 51Intrinsic Functions

REAL

The square root.

Error Conditions: None.

52 PCL and CustomizationIntrinsic Functions

mth_lnDescription:

( value )

Return natural logarithm of the argument. Input: REAL Output: REAL The natural logarithm. value The value for which to obtain the natural logarithm.

Error Conditions: None.

mth_logDescription:

( value )

Return common logarithm of the argument. Input: REAL Output: REAL The common logarithm. value The value for which to obtain the common logarithm.

Error Conditions: None.

mth_expDescription:

( value )

Return power function of natural logarithm base, e to the x power. Input: REAL Output: REAL The result of the power of the input argument. value The raising power

Chapter 3: Basic Functions 53Intrinsic Functions

Error Conditions: None.

mth_absDescription:

( value )

Return the absolute value of the input argument. Input: NUMERIC Output: NUMERIC The absolute value of the input argument. The datatype will match that of the input argument. value The value to get the absolute value of, integer or real.

Error Conditions: None.

54 PCL and CustomizationIntrinsic Functions

mth_signDescription:

( value )

Return a sign, -1, 0, or 1 for the input argument. Input: REAL Output: INTEGER The sign value of the input argument, -1 for a negative argument, 0 for zero, and 1 for a positive argument. value The value of which to get the sign.

Error Conditions: None.

mth_nintDescription:

( value )

Return the nearest integer value for the input argument. Input: REAL Output: INTEGER None. The nearest integer value, rounding off the input argument. Error Conditions: value The value for which to obtain the nearest integer.

Chapter 3: Basic Functions 55Intrinsic Functions

mth_maxDescription:

( val1, val2, ... )

Return the largest value of a set of input values. Input: NUMERIC Output: NUMERIC The largest value of the input arguments. If all input arguments are INTEGER, then this result is also INTEGER. Otherwise, this result is REAL. valnnn Input values to check, INTEGER or REAL. There may be one or more input values specified.

Error Conditions: None.

mth_minDescription:

( val1, val2, ... )

Return the smallest value of a set of input values. Input: NUMERIC Output: NUMERIC The smallest value of the input arguments. If all input arguments are INTEGER, then this result is also INTEGER. Otherwise, this result is REAL. valnnn Input values to check, INTEGER or REAL. There may be one or more input values specified.

Error Conditions: None.

mth_modDescription:

( value, divisor )

Return remainder of a number after dividing by a divisor. Input: NUMERIC value The value to be divided by the divisor.

56 PCL and CustomizationIntrinsic Functions

NUMERIC Output: NUMERIC

divisor

The divisor value.

The remainder after dividing value b