Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with variables in pcl-script

Status
Not open for further replies.

martinwcg

New member
Jan 5, 2011
4
0
0
DE
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
 
Replies continue below

Recommended for you

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
 
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! :)
 
Status
Not open for further replies.
Back
Top