Structure-In-BASIC -*-org-*- A technique for writing structured programs in Minimal BASIC. Structure-In-BASIC (SIB) is intended for beginning programmers who have been introduced to Minimal BASIC and wish to create more complex programs (programs too long to display on a single screen without paging/scrolling) before learning another language with better support for structured programming, or for advanced programmers who wish to create structured programs in BASIC. SIB is composed of a set of source code patterns for implementing standard program structures in BASIC. The patterns should be simple to insert into program source, easily recognizable and distinctive, and undamageable by line renumbering. They should also assume no knowledge of other programming languages on the part of the programmer. * Sequence A sequence block is simply a series of consecutively-numberes program statements. REM statements (no standard format) should be used to describe the entire block or subsections as needed. Statements that are the target of branch commands (GOTO, etc.) must be descriptive REMs. * Selection ** Conditional
01000 REM /// BEGIN CONDITIONAL \\\_________________________ 01010 IF skip-condition THEN 1030 01020 REM conditional sequence ... 01030 REM \\\ END CONDITIONAL ///---------------------------** Alternative
01000 REM /// BEGIN A* Repetition ** FOR-NEXT Loop (Use standard BASIC syntax.) ** LEAVE-OR-LOOP Loop
01000 REM /// BEGIN TEST-EXIT \\\___________________________ 01010 IF exit-test THEN 1040 01020 REM loop sequence ... 01030 GOTO 1000 01040 REM \\\ END TEST-EXIT-LOOP ///----------------------** LOOP-AND-REPEAT Loop * Compound conditionals DEC BASIC-10 doesn't include logical operators AND, OR, or NOT. Although equivalent functions can be defined (see UTILFUN.BAS), the following patterns can also be used. ** AND Execute sequence Sp if all predicates p1 ... pn are true. 100 IF !p1 THEN 130 110 IF !p2 THEN 130 ... 120 IF !pn THEN 120 REM sequence Sp ... 130 REM end structure ... ** OR 100 IF p THEN 120 110 IF !q THEN 130 120 REM p OR q processing ... 130 REM end structure ... ** Negation In the AND and OR structures, boolean negation is achieved with the opposite relational operator: |---+----| | = | <> | | < | >= | | > | <= | |---+----|