×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Problem with variables in pcl-script

Problem with variables in pcl-script

Problem with variables in pcl-script

(OP)
Hello everyone,

once again pcl is kicking my butt ;).

I try to build a pcl-script and use global variables. In the main script I try to access a variable ("elsize_") in an if-statement:

CODE

GLOBAL REAL elsize_ = 20.0
GLOBAL LOGICAL test_ = TRUE

IF (test == true_) THEN

  mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
  $? YESFORALL 2001017

END IF

Unfortunately this doesn't seem to work. Patran reports the error:

CODE

mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
$# (PCL) Missing operand to expression
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Character is "`"
$# (PCL) Missing right parenthesis
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Extra information:  mesh_seed_create

But, if I use the command to create the mesh seed on the specified curves outside the if-statement the whole thing works.

What is the problem there? What do I have to change? I don't thick pcl doesn't allow the usage of variable inside of if-statements.

Best regards
Martin

RE: Problem with variables in pcl-script

(OP)
of course, in the code-example it has to be

CODE

GLOBAL REAL elsize_ = 20.0
GLOBAL LOGICAL test_ = TRUE

IF (test_ == TRUE) THEN

  mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
  $? YESFORALL 2001017

END IF

RE: Problem with variables in pcl-script

Are you still workig on this?  If so, how are you executing in Patran?
Is this code snippet part of a Function/Class?
Or, are you running as session file or with !!INPUT?

Looping and control structures don't work in a session file (or read with !!INPUT).  They need to be in a FUNCTION.

Here's a way to solve the problem. Note: Globals can't be declared inside functions. Also, the back-quotes are NOT used with variables inside a function.

CODE

FUNCTION eng_tips_test()
 REAL elsize_ = 20.0
 LOGICAL test_ = TRUE

IF (test_ == TRUE ) THEN
  ui_write ("Test is True")
  mesh_seed_create( "Curve 1:4", 2, 0, 0., elsize_, 0. )
  $? YESFORALL 2001017

END IF
END FUNCTION /* eng_tips_test */

Save this snippet as eng_tips_test.pcl
You run this by entering this on Patran's command line:
!! INPUT eng_tips_test.pcl
eng_tips_test()


If you really want GLOBAL variables, you need a slightly different method.

CODE

FUNCTION eng_tips_test2()
/* declare, but don't initialize variables */
 REAL elsize_
 LOGICAL test_

IF (test_ == TRUE ) THEN
  ui_write ("Test is True")
  mesh_seed_create( "Curve 1:4", 2, 0, 0., elsize_, 0. )
  $? YESFORALL 2001017

END IF
END FUNCTION /* eng_tips_test2 */

Save this snippet as eng_tips_test2.pcl
You run this by entering this on Patran's command line:
!! INPUT eng_tips_test2.pcl
GLOBAL REAL elsize_ = 20.0
GLOBAL LOGICAL test_ = TRUE
eng_tips_test2()

Ta-da! Done!  :)
 

RE: Problem with variables in pcl-script

(OP)
thx a lot. i'll try.

as you thought, I tried to access my snipplet in a session file.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources