=, Store
This operator and command let you assign a value to a memory variable. The results are the same, but STORE lets you save the same value to multiple variables. Both let you save a single value to all elements of an existing array.
Usage |
Variable = uExpression STORE uExpression TO Variable1 [, Variable2 [...] ] |
STORE 0 to nOne, nTwo, nThree, nFour, nFiveis faster than:
nOne = 0 nTwo = 0 nThree = 0 nFour = 0 nFive = 0STORE is also handy when you're writing generic code because it lets you use a name expression rather than a macro, typically a faster and less resource-intensive operation. That is, if cVarName contains the name of a variable, you can write:
STORE 0 TO (cVarName)rather than:
&cVarName = 0If the variable is an existing array and SET COMPATIBLE is OFF, the value of uExpression is stored in every element of the array. This is a quick way to initialize an array. With SET COMPATIBLE ON, the array is overwritten by a single memvar that gets the value of uExpression.Objects change the game with = and STORE. You can use them with objects. What you get is a new reference to the same object, not a copy of the object. There isn't any easy way to create an exact copy of an object. We can think of some brute-force ways, but they're not pretty.
Example |
dToday=DATE() STORE 0 TO nTotal,nCount DIMENSION aTotals[5] aTotals=5 oObj1.SomeProperty="Old Value" oObj2=oObj1 oObj1.SomeProperty="New Value" ? oObj2.SomeProperty && Returns "New Value" |
See Also |