Variables and Loops

A Variable in the ACS-SASSI User Interface has a list of strings that the user can access elements at a later time and an integer counter. A variable is declared using the VAR Command, the first argument is the variable name the rest of the arguments are the element in the variable list. All characters in the variable name are processed by the code and transformed to upper case, so don't use the same spelling of a variable only differing by case. A simple example of the Var command usage is VAR,X,1.23,2.83,3 (Note: it will be assumed that this command was declared when describing how the user can access this variable later in this section). The user can access the variable in any command but one (FOREACH command) by putting a prefix @ in front of the variable name and by using the postfix operators that will be described.

If the user only uses the prefix and declares @X a command argument the ACS-SASSI User Interface will replace the instance of @X with the variable counter which is set to 0 by default. The + and – post-fix operators will add or subtract an integer from the counter and replace the variable with the updated counter @X+5 will add 5 to the X counter and that value will replace the entire statement. ++ and - - are the same as if the user added or subtracted 1 ( @X++ and @X+1 are equivalent statements). The = post-fix operator will set the counter equal to the integer following the number and that number will be substituted for the variable @X=-15 will set the counter to -15 and -15 will be substituted into the argument. To access the variable list the [] operator must be used. Inside of the brackets the user enters an integer position in the variable list that is desired. The list numbering starts at 1 so using the example variable 1.23 will replace the @X[1] statement, while @X[2] will be replaced by 2.83.

A variable list cannot be modified once declared the user can only change what is in a variable list by overwriting the Variable using the VAR command. The Variable counter get set/reset to 0 every time the VAR command redefines a variable. The counter can only be modified while being referenced in a valid command, so the SETVAR command has been introduced. This command is a placeholder to allow the user to set or check variable counters without affecting the model.

Once a variable has been declared the user can execute a single command loop by using the FOREACH command. The FOREACH command take a variable name without the @ prefix and the command the user wishes to loop through. The number of time the loop will execute is dependent on the number of elements in the variable list (FOREACH,X,… would execute 3 times). While in the loop a separate loop counter can be accessed by using the pound sign operator (#) with the post-fix operators. Loops can be nested but nested loops cannot use the same variable, this situation will cause an infinite loop (this situation should cause an error and loop execution will not occur). The loop can only take one command but the user can pair FOREACH with a macro to get a multiple command loop.

Example(s)

*Loop.pre A simple nested loop example
* Declare a 5X5X5 block of nodes
Var,N* node counter
Var,X,1,2,3,4,5*X coords
Var,Y,1,2,3,4,5*Y coords
Var,Z,1,2,3,4,5*Z coords
ForEach,Z,ForEach,Y,ForEach,X,N,@N++,@X[#],@Y[#],@Z[#]