Programming Reference / Math / Set Variable
Item | Name | Description |
---|---|---|
A | Variable | The Variable you wish to perform the operation upon. |
B | Operation | User selectable operation, some of which require the 2nd Operand and some that do not. Details on available operations below. |
C | 2nd Operand | Used selected operations that require a 2nd value or variable. Note that 2nd Operand position automatically appears or disappears depending on the Operation selected. |
Available Operations
Selection | Operation | Description |
---|---|---|
= | A = C | Instruction copies the value of 2nd Operand and stores the result in Variable |
+1 | A = A + 1 | Add 1 to the initial value of Variable and store the result in Variable |
-1 | A = A – 1 | Subtract 1 from the initial value of Variable and store the result in Variable |
+= | A = A + C | Add the value of the 2nd Operand to the initial value of Variable and store the result in Variable |
-= | A = A – C | Subtract the value of the 2nd Operand from the initial value of Variable and store the result in Variable |
Examples
In this example we are setting the value of “My_DINT” to the value 3000. | |
In this example we are incrementing the value of “My_DINT” by 1. Similarly we could have selected the -1 operation and then decremented the value of “My_DINT by 1. Please note that the 2nd Operand is not needed for this operation . | |
In this example we are adding 5 to the initial value of “My_DINT” and placing the result in “My_DINT” |