'{$STAMP BS2pe} '{$PBASIC 2.5} ' (c) 2003 Tracy Allen, http://www.emesystems.com ' explores the PBASIC 2.5 commands ' DO - LOOP ' and variations DO - WHILE, DO - UNTIL, LOOP - WHILE, LOOP - UNTIL ' and EXIT as part of a DO loop, ' also EXIT as part of a FOR NEXT loop ' ' 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=0 ' 0 DO - LOOP in new PBASIC ' 1 same tokens as 10, but using GOTO in old PBASIC ' 10 DO WHILE - LOOP in new PBASIC ' 11 same exact tokens as 20 using IF, GOTOs and labels in old PBASIC ' 20 DO - LOOP WHILE in new PBASIC ' 21 same exact tokens as 20 using IF, GOTOs and labels in old PBASIC ' 30 DO UNTIL - LOOP in new PBASIC ' 31 same exact tokens as 30 using IF, GOTOs and labels in old PBASIC ' 40 DO - LOOP UNTIL in new PBASIC ' 41 same exact tokens as 40 using IF, GOTOs and labels in old PBASIC ' see separate file for EXIT #SELECT EXAMPLE ' ------ DO-LOOP #CASE 0 DO ' statements in loop LOOP END #CASE 1 lab1: ' statements in loop GOTO lab1 END ' ------ DO WHILE - LOOP #CASE 10 DO WHILE IN1=1 ' statements A in loop, may not execute if condition met to start LOOP ' statements B after loop END #CASE 11 ' same as case 10 lab1: IF IN1=1 THEN lab1a GOTO lab1b lab1a: ' statements A in loop, may not execute if condition met to start GOTO lab1 lab1b: ' statements B after loop END ' ------ DO - LOOP WHILE #CASE 20 DO ' statements A in loop, execute at least once LOOP WHILE IN1=1 ' statements B after loop END #CASE 21 ' same tokens as case 20 lab1a: ' statements A in loop, execute at least once IF IN1=1 THEN lab1a ' statements B after loop END ' ------ DO UNTIL - LOOP #CASE 30 DO UNTIL IN1=1 ' statements A in loop, may not execute condition is met at start LOOP ' statements B aftter loop END #CASE 31 ' same tokens as case 30 lab1a: ' statements A in loop IF IN1=1 THEN lab1b GOTO lab1a lab1b: ' statements B after loop END ' ------ DO - LOOP UNTIL #CASE 40 DO ' statements A in loop, execute at least once LOOP UNTIL IN1=1 ' statements B after loop END #CASE 41 ' same as case 40 lab1a: ' statements A in loop, execute at least once IF IN1=1 THEN lab1b GOTO lab1a lab1b: ' statements B after loop END