Hi Guys,
When simulating a SELECT...CASE structure:
<code><pre><font size=2 face='Courier'>
'Get state of input pins
PINSTATE = PINS
SELECT CASE PINSTATE
CASE UPL 'Up slack on left
SIDE = LEFT
GOSUB upslack
CASE UPR 'Up slack on right
SIDE = RIGHT
GOSUB upslack
CASE OUTL 'All out on left
SIDE = LEFT
GOSUB allout
CASE OUTR 'All out on right
SIDE = RIGHT
GOSUB allout
ELSE
'All outputs low
PINS = 0
END SELECT
</font></pre></code>
I found that after executing one of the GOSUBs (e.g. GOSUB upslack) and returning, the code in the ELSE section (PINS = 0) would then also run. Should it not go directly to the END SELECT?
The fix is simple enough, but I wondered if the PICAXE itself would do this or whether it's a problem with the simulator?
When simulating a SELECT...CASE structure:
<code><pre><font size=2 face='Courier'>
'Get state of input pins
PINSTATE = PINS
SELECT CASE PINSTATE
CASE UPL 'Up slack on left
SIDE = LEFT
GOSUB upslack
CASE UPR 'Up slack on right
SIDE = RIGHT
GOSUB upslack
CASE OUTL 'All out on left
SIDE = LEFT
GOSUB allout
CASE OUTR 'All out on right
SIDE = RIGHT
GOSUB allout
ELSE
'All outputs low
PINS = 0
END SELECT
</font></pre></code>
I found that after executing one of the GOSUBs (e.g. GOSUB upslack) and returning, the code in the ELSE section (PINS = 0) would then also run. Should it not go directly to the END SELECT?
The fix is simple enough, but I wondered if the PICAXE itself would do this or whether it's a problem with the simulator?