Defining variables

From ConsteelSoftware Wiki
Jump to: navigation, search

Go back to: FUNCTION list

What is a variable?

Variables in a computer program are analogous to "Buckets" or "Envelopes" where information can be maintained and referenced. On the outside of the bucket is a name. When referring to the bucket, we use the name of the bucket, not the data stored in the bucket.

How to define variables in csPI

When creating or modifying objects with different kind of commands, they will require different input parameters (such as start-end coordinates of a member, combination factors, ID's etc…). These parameters can be defined locally as numerical values, or as a variable.

In csPI definition of a variable starts with a "$" sign, followed by the name of the variable, and after an equal sign, the value assignment:
$x=1000

Value of a variable can be:

  • numerical
  • text variable (string of characters)

How to use defined variables in csPI

If variables are defined, they are free to use them in the following lines of the code. They can either used as command attributes, and object attributes too.

Copy & Paste sample code

//Thickness
$th=15

//Finite element size
$fe=50

//coordinate definition
$x1=0
$y1=0
$z1=0
$x2=3000
$y2=0
$z2=0
$x3=3000
$y3=3000
$z3=0
$x4=0
$y4=3000
$z4=0

//Executing the create-structural plate command
CREATE "SPID1" Structural_Plate "S 235 EN 10025-2" $th $fe
Name "PlateName"
$x1 $y1 $z1
$x2 $y2 $z2
$x3 $y3 $z3
$x4 $y4 $z4

Go back to: FUNCTION list