Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

238 GOTO go to a line number Purpose This statement makes the computer jump to a specified line number instead of continuing to the next one in the program. It changes the order in which the computer executes a program. Although GOTO is simple to use, do so with caution! It is all too easy to make a program difficult to follow by using too many GOTO s. Following a program full of GOTO s is like trying to disentangle a plateful of spaghetti and arrange it in a straight line! Adherents of ‘structured programming’ encourage program writers to use structures like REPEAT...UNTIL and FOR...NEXT and to avoid most (but not all) GOTO statements.

It is possible in this version of BASIC to GOTO a variable. In the following example the destination variable is called ‘somewhere’: 10 somewhere=1005 20 GOTO somewhere but this feature must be used with great care since the program cannot be renumbered using the RENUMBER command. Note that if the destination line number is to be calculated using a mathematical expression then that expression must be in parentheses. GOTO can be used as a command to start a program without destroying the values assigned to the variables. GOTO 330 Examples 100 IF X>5 THEN GOTO 2000 100GOTO (starts*55+14) Description A statement used to transfer control to a specified or calculated line number unconditionally.