|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Sep 29, 2007 6:08 am
[2.04] $local #loop |
#LOOP 25 {#ADD $test 1;#SAY $test}
The value of $test is always 1.
Shouldn't it increment itself since it is completely within the loop? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Sat Sep 29, 2007 8:30 am |
I think this is the way it's supposed to be. Since $test is defined with the scope of the loop ( and only withing that scope ) it is essentially reset with every iteration. It is the same as declaring a variable with a 'while' in C/C++/Java, it's redefined at the start of each loop iteration and destroyed at the end of each loop iteration. You need a variable outside of the loop to do what you want.
|
|
_________________ Asati di tempari! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Sep 29, 2007 1:27 pm |
Tech is correct.
#local $test
#loop 25 {#add $test 1;#say $test}
gives you the result you're looking for. |
|
|
|
|
|