This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
example:variables_and_loops [2013/12/20 11:27] phil |
example:variables_and_loops [2024/07/17 11:06] (current) dan [Example(s)] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Variables and Loops ====== | ====== Variables and Loops ====== | ||
- | A Variable in the ACS-SASSI [[SASSI:Submodeler]] 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 [[com: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 ([[com:FOREACH]] command) by putting a prefix @ in front of the variable name and by using the postfix operators that will be described. | + | A Variable in the [[SASSI: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 [[com: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 ([[com: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 Submodeler 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 0 so using the example variable 1.23 will replace the @X[0] statement, while @X[1] will be replaced by 2.83. | + | 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 [[com:SETVAR]] command has been introduced. This command is a placeholder to allow the user to set or check variable counters without affecting the model. | 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 [[com:SETVAR]] command has been introduced. This command is a placeholder to allow the user to set or check variable counters without affecting the model. | ||
Line 14: | Line 14: | ||
* Declare a 5X5X5 block of nodes | * Declare a 5X5X5 block of nodes | ||
Var,N* node counter | Var,N* node counter | ||
- | VarX,1,2,3,4,5*X coords | + | Var,X,1,2,3,4,5*X coords |
- | VarY,1,2,3,4,5*Y coords | + | Var,Y,1,2,3,4,5*Y coords |
- | VarZ,1,2,3,4,5*Z coords | + | Var,Z,1,2,3,4,5*Z coords |
ForEach,Z,ForEach,Y,ForEach,X,N,@N++,@X[#],@Y[#],@Z[#] | ForEach,Z,ForEach,Y,ForEach,X,N,@N++,@X[#],@Y[#],@Z[#] | ||
</code> | </code> |