|
Derar Novice
Joined: 09 Sep 2006 Posts: 44
|
Posted: Mon Aug 30, 2010 3:12 pm
[3.23a] Datatypes behaving weirdly - %push example |
When using %push to add an item to the front of a list, if the destination list is a single-value variable, %push will expand the variable and create a new variable as a list named after that variable.
Example:
Code: |
TestVar = 5
#SHOW %push(4, @TestVar)
#SHOW %push(4, @TestVar)
#SHOW %push(4, @TestVar)
#SHOW %push(4, @TestVar)
#SHOW %push(4, TestVar)
#SHOW %push(4, @TestVar)
#SHOW @{@TestVar}
|
Outputs:
Code: |
4
4|4
4|4|4
4|4|4|4
4|5
4|4|5
4|4|5
|
Additionally, the package editor will now show a variable named 5 with {4|4|4|4} as its value.
Now, the non-@ call (#SHOW %push(4, TestVar)) works properly, and explicitly forces TestVar to be data type String(List) in the Package Editor. However, if I then enter TestVar = 6, and check again, TestVar has reverted to AutoType and continues the above problems, now building on to a var named 6 as it had been with 5. For more fun, if I force TestVar to be a String(List) in the package editor, it works fine with either syntax, however, if I then "reset" TestVar with TestVar = 5 again, it reverts to AutoType once more.
Also, though I couldn't tell you if this used to happen or not before, if I set TestVar to Integer in the package editor, then run the push, it displays the same as orginal problem, except that this time the growing list is stored in a var named 0.
Previously, I never had issues resetting lists to initial values (List = 1), and continuing to work with it with additem or push. |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon Aug 30, 2010 3:52 pm |
I believe the issue is related to the by-reference passing of the list discussed in this post. However the behavior you described still sounds erroneous.
|
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 30, 2010 4:14 pm |
Confirmed and added to bug list. Looks like %push is modifying the string list even when using @TestVar, which is shouldn't.
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|