'{$STAMP BS2pe} '{$PBASIC 2.5} ' (c) 2003 Tracy Allen, http://www.emesystems.com ' explores the PBASIC 2.5 commands ' SELECT - CASE - CASE ELSE - ENDSELECT ' ' to use this program as a study guide, ' Enter alternative program cases after #DEFINE below ' then look at tokens using CTRL-M memory map window ' Scroll to the bottom of the window to the red area. #DEFINE example=10 ' 10 SELECT - CASE - CASE - CASE ELSE - ENDSELECT ' 11 same tokens as 10, but using IF - GOTOs in old PBASIC #SELECT example #CASE 10 ' SELECT CASE construct x VAR Byte SELECT x CASE 1 HIGH 0: LOW 1 CASE 2 HIGH 1:LOW 0 CASE ELSE LOW 1:LOW 0 ENDSELECT END #CASE 11 ' same tokens as 10, very efficient x VAR Byte IF x=1 THEN lab1 ' test for case 1 GOTO lab2 ' case 1 false, try case 2 lab1: ' case 1 true, do this... HIGH 0:LOW 1 GOTO lab5 ' done with case 1, exit lab2: IF x=2 THEN lab3 ' test for case 2 GOTO lab4 ' case 2 false, try next case lab3: ' case 2 true, do this... HIGH 1: LOW 0 GOTO lab5 ' done with case 2, exit lab4: ' this is case else LOW 1: LOW 0 ' do this... lab5: ' point of exit END #ENDSELECT