Problem using local variables in sxb2
T'Saavik
Posts: 60
I was having trouble with this code
No matter what I passed to this subroutine (0,1,2) the IF always returned true (input was read as 0)
Changing counter from a WORD to a BYTE fixed it.
I have a feeling this may have something to do with what i set the local stack size to?
Am i correct in assuming that a stack of 16 is equivalent to a word, and therefor i overflowed my stack?
I am still working on this code, but if you want to view it in its current entirety it is available at: www.hellspark.com/dm/ebench/sx/dave/cdavenger.sxb
UPDATE:
It would appear that my Local_Drive variable is incrementing itself even after the above 'fix' ?!?! I'm still trying to figure it out
UPDATE2: The for loop on another local variable is causing it somehow!
UPDATE3:
I created a global counter variable and it fixes the problem!
Post Edited (T'Saavik) : 4/30/2010 8:14:17 PM GMT
SUB LIFT Local_Drive VAR BYTE Local_Drive = __PARAM1 Local_Counter VAR WORD WATCH Local_Drive BREAK if Local_Drive = 0 THEN
No matter what I passed to this subroutine (0,1,2) the IF always returned true (input was read as 0)
Changing counter from a WORD to a BYTE fixed it.
I have a feeling this may have something to do with what i set the local stack size to?
STACK 16
Am i correct in assuming that a stack of 16 is equivalent to a word, and therefor i overflowed my stack?
I am still working on this code, but if you want to view it in its current entirety it is available at: www.hellspark.com/dm/ebench/sx/dave/cdavenger.sxb
UPDATE:
It would appear that my Local_Drive variable is incrementing itself even after the above 'fix' ?!?! I'm still trying to figure it out
UPDATE2: The for loop on another local variable is causing it somehow!
Lift_Delay CON 120 'This is at the top of the program, thought it might be handy to know it was over 255. For Local_Counter=0 to Lift_Delay PULSOUT White_CD_Lift, Lift_Right PAUSE 20 'I had delay_ms sub but replaced to simplify NEXT
UPDATE3:
I created a global counter variable and it fixes the problem!
Post Edited (T'Saavik) : 4/30/2010 8:14:17 PM GMT
Comments
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]