Rice Code -*- mode: org; -*- Structured programming for portable BASIC. rice <> spaghetti Since support for conditional and iterative blocks other then FOR/NEXT varies among BASIC implementations, code blocks using standard subroutines and IF-THEN statements. Minimize line number dependence. Subroutines have the virtue that their length can change without impacting other code (as long as enough line space is reserved between code segments). * Conditional blocks IF THEN GOSUB IF THEN GOSUB ELSE GOSUB All conditionally executed statements in subroutines , . ** First Generation BASIC IF NOT THEN +2 +1 GOSUB +2 ... IF NOT THEN +3 +1 GOSUB +2 GOTO +4 +3 GOSUB +4 ... -1 LET E9=3*+ IF NOT THEN +3 +1 GOSUB +2 GOTO E9 +3 IF NOT THEN +6 +4 GOSUB +5 GOTO E9 +6 ... ... +3*(-1) IF NOT THEN <... (... avoid CASE structures) * Conditional iteration (test before) IF THEN GOSUB : GOTO (test after) -10 GOSUB IF THEN GOSUB : GOTO ** First Generation BASIC IF THEN +3 +1 GOSUB +2 GOTO +3 ... GOSUB +1 IF THEN +2 ... * Program layout !bwbasic maximum line number is 32766! - 10- 990: Program identification, documentation - 1000- 5990: Initialization, main program - 6000- 6099: Functions - 6100- 7090: Subroutine 6100 - 7100- 8090: Subroutine 7100 - ... - 29100-30090: Subroutine 29100 - 31000-32766: Data