plyrathrt
- 13th February 2011, 20:18
Ran in to some issues with code space on my mico and am trying to get more room. The question I have is can you use AND OR in combination together?
For instance, I have a subroutine which repeats until a couple different actions become true. Right now I have a second subroutine, exactly the same but waiting for different conditions to become true. I would like to combine these two subroutines to one single subroutine to conserve space.
Here is an example.
firstroutine:
repeat
output led1
led1 = ledon
pause 1000
until (button1 = buttonpress) or (button2 = buttonpress)
second routine:
repeat
output led1
led1 = ledon
pause 1000
until (button3 = buttonpress)
So, I could assign a variable for the two modes using the two different subroutines but could I write it like this?
combinedroutine:
repeat
output led1
led1 = ledon
pause 1000
until (mode = 1) and (button1 = buttonpress) or (mode = 1) and (button2 = buttonpress) or (mode = 2) and (button3 = buttonpress)
Do you have to doube (( )) each combination for picbasic to combine the operators together?
For instance, I have a subroutine which repeats until a couple different actions become true. Right now I have a second subroutine, exactly the same but waiting for different conditions to become true. I would like to combine these two subroutines to one single subroutine to conserve space.
Here is an example.
firstroutine:
repeat
output led1
led1 = ledon
pause 1000
until (button1 = buttonpress) or (button2 = buttonpress)
second routine:
repeat
output led1
led1 = ledon
pause 1000
until (button3 = buttonpress)
So, I could assign a variable for the two modes using the two different subroutines but could I write it like this?
combinedroutine:
repeat
output led1
led1 = ledon
pause 1000
until (mode = 1) and (button1 = buttonpress) or (mode = 1) and (button2 = buttonpress) or (mode = 2) and (button3 = buttonpress)
Do you have to doube (( )) each combination for picbasic to combine the operators together?