Code:
ROTARY:
'
PAUSE 15                                             ' Needed for smooth rotary encoder operation 
OLDR = PORTB & $30                           ' Mask other and get only Ports B4 and B5
GOSUB ROTARY1
RETURN
if you need a pause then you are not doing it right


Code:
;IF BUT = 0 THEN GOTO MENU2               ' This is the wrong way to get out, overflow error !!!
' I need to get out of this loop when the button is pressed !!!


IF BUT = 0 THEN 
buttonState=1


IF NEWR = $30 THEN ROTARY1 ' Same value - no movement (need to eliminate this) ??

assuming last state was $20 or $10 or 0 how can you tell direction ?
you need to save the last state and compare that with the newstate



this thread has re/switch code and is worth a study


http://www.picbasic.co.uk/forum/showthread.php?t=23840