simulating_20resume_20and_20resume_20next
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
simulating_20resume_20and_20resume_20next [2018/03/31 13:19] – external edit 127.0.0.1 | simulating_20resume_20and_20resume_20next [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Richard Russell, September 2007//\\ \\ BBC BASIC doesn' | //by Richard Russell, September 2007//\\ \\ BBC BASIC doesn' | ||
+ | <code qbasic> | ||
PRINT " | PRINT " | ||
ON ERROR GOTO 1000 | ON ERROR GOTO 1000 | ||
Line 13: | Line 14: | ||
Divisor = 3 | Divisor = 3 | ||
RESUME | RESUME | ||
+ | </ | ||
When run the program generates the following output:\\ \\ | When run the program generates the following output:\\ \\ | ||
Program starting | Program starting | ||
Line 20: | Line 22: | ||
Program finished | Program finished | ||
Note that an error occurs (division by zero) because **Divisor** is initially zero, but in the error handler **Divisor** is changed to 3 and the division is repeated, this time successfully.\\ \\ Here is the same program in //BBC BASIC for Windows// using some sneaky code to reproduce the effect of **RESUME**: | Note that an error occurs (division by zero) because **Divisor** is initially zero, but in the error handler **Divisor** is changed to 3 and the division is repeated, this time successfully.\\ \\ Here is the same program in //BBC BASIC for Windows// using some sneaky code to reproduce the effect of **RESUME**: | ||
+ | <code bb4w> | ||
PRINT " | PRINT " | ||
ON ERROR GOTO 1000 | ON ERROR GOTO 1000 | ||
Line 34: | Line 37: | ||
WHILE ?P% AND P% + ?P% < !408 P% += ?P% : ENDWHILE | WHILE ?P% AND P% + ?P% < !408 P% += ?P% : ENDWHILE | ||
GOTO (P%) | GOTO (P%) | ||
+ | </ | ||
This code produces the following output:\\ \\ | This code produces the following output:\\ \\ | ||
Program starting | Program starting | ||
Line 46: | Line 50: | ||
Program finished | Program finished | ||
Here the division isn't repeated, and the RESUME NEXT transfers control to the "PRINT " | Here the division isn't repeated, and the RESUME NEXT transfers control to the "PRINT " | ||
+ | <code bb4w> | ||
PRINT " | PRINT " | ||
ON ERROR GOTO 1000 | ON ERROR GOTO 1000 | ||
Line 60: | Line 65: | ||
REPEAT P% += ?P% : UNTIL ?P% = 0 OR P% > !408 | REPEAT P% += ?P% : UNTIL ?P% = 0 OR P% > !408 | ||
GOTO (P%) | GOTO (P%) | ||
+ | </ | ||
And here is the output:\\ \\ | And here is the output:\\ \\ | ||
Program starting | Program starting |
simulating_20resume_20and_20resume_20next.1522502383.txt.gz · Last modified: 2024/01/05 00:16 (external edit)