Msc. Patran pcl handbook In a Nutshell 7



Download 1.08 Mb.
Page9/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   5   6   7   8   9   10   11   12   ...   25

Exercise 6: p3epilog.pcl


Compile all of the previous 3 PCL functions:

  1. Exercise 2: Hello World

  2. Exercise 4: Writing Files

  3. Exercise 5: Reading Files

into a PCL library called pat304.plb. Create a p3epilog.pcl or p3patran.pcl file in you home directory to automatically “link” this PCL library with the MSC.Patran session.

    1. The p3epilog.pcl (or p3patran.pcl) file should be in either your home directory/folder or the current directory/folder.

    2. The pat304.plb file can be in any directory/folder. If it is not in your current or home directory/folder, you will need to include the path in your p3epilog.pcl/p3patran.pcl file as either:

  1. !!lib /some/other/location/pat304.plb

  2. !!path /some/other/location
    !!lib pat304.plb

3) Be sure to compile all subsequent PCL functions into this library as well.

Debugging

Debugging Compile Errors


  • Adequate information is given to fix common errors such as typos and undeclared variables. The cause of the error, file/line number, and offending line will normally be called out.

C
Location of ERROR

Type of ERROR

Offending line
ompiling: msc_explore_xyplot_tic_mark.display

Compiled: msc_explore_xyplot_tic_mark.display
Compiling: msc_explore_xyplot_tic_mark.refresh
***Error: (PCL) Undeclared variable: SVALUE
*** File: msc_explore_xyplot_tic_mark.pcl, Line: 204
*** Line is " svalue = FALSE"
***Error: Compilation aborted
Compiling: msc_explore_xyplot_tic_mark.refresh_ps
Compiled: msc_explore_xyplot_tic_mark.refresh_ps
===(PCL) Variable is declared but is not used: REALTICS
Compiling: msc_explore_xyplot_tic_mark.colorbox_select

  • Some errors can be harder to debug due to more ambiguous error messages. Some examples are: incomplete comment syntax (/* */), missing THEN in an IF () THEN condition, or an extra comma at the end of a declaration line. These can show up as any of the following errors.

    ***Error: (PCL) Invalid/unknown statement.

    ***Error: (PCL) Not currently defining a function.

    ***Error: (PCL) Extra characters after statement end.

Note: For these types of errors, the actual problem may be well above the called out line number.

Debugging


Debugging Runtime Errors


  • The best debugging tool is the dump function. This function “dumps” variable name, variable type, and variable value to the MSC.Patran session file

FUNCTION my_function()

INTEGER i, j

INTEGER a(3)

FOR (i = 1 to 3)

a(i) = i

END FOR

j = 9

dump j, a

END FUNCTION
Sample to the history window (session file)

$# INTEGER j = 9

$# INTEGER a(3) = [1, 2, 3]

Debugging



  • A common type of run time error is a call traceback. It shows up in your message window and looks like this:

$# Call traceback...

$# Function UI_ITEM_DELETEALL

$# Function MSC_EXPLORE.REFRESH, Line Number 294

$# Function MSC_EXPLORE.DISPLAY, Line Number 269

$# Function UI_EXEC_FUNCTION

$# Function MSC_EXPLORE_XYPLOT_DISP_GRAPH.LEGEND_CB, Line Number 694

This can be used to find the line where the error occurred, but there is no information about what the error is. In this example, the error occurred with the built in function UI_ITEM_DELETEALL on line 294 in function MSC_EXPLORE.REFRESH().



  • If the PCL function failure causes a MSC.Patran crash, then the only debugging tools that can be used are ones that write to the background window or STDOUT. These are !!DEBUG and !!TRACE as mentioned before and another write statement that outputs to STDOUT.

!I am about to call my_function and i = `i`

The line starts with a single “!” and any variable between the “`” marks are evaluated.


Accessing PCL Functions


When a PCL function is called, MSC.Patran searches through the PCL library list starting with the last library added. If it is found it executes it, if not it returns the error:

$# (PCL) Function does not exist: function_name()
$# Execution aborted

PCL functions can be called in may different ways.


From The Command Line


A

ny built-in function or user defined can be called from the command line:

Accessing PCL Functions


From Any MSC.Patran Form


Any built-in function or user created can be called from a standard or user created form as long as it is surrounded by back ticks “`”.


Use back ticks “`”


Accessing PCL Functions


PCL Functions with Field Variables


I

FUNCTION max_pressure(x,y,z,t)

REAL x,y,z,t

REAL pressure


Pressure = x – y*2 + z**3 - .1783

Pressure = t * pressure


RETURN pressure
END FUNCTION
n this case the function does not get surrounded with back ticks, but the field variables are each prefixed with a forward tick “ ’ ”.


Download 1.08 Mb.

Share with your friends:
1   ...   5   6   7   8   9   10   11   12   ...   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page