SB BBC @ GBR Oldie hints/tips #063-066 Hints and tips from the archives of Wakefield BBC Micro User Group... 64. Error reporting ~~~~~~~~~~~~~~~ This is a little routine which not only reports errors in your programs, but also lists the offending line ready for you to edit. The first listing given only works on Basic version 2 and later, including BAS128, so if you aren't sure which you've got, press , and then type REPORT . Version 1 is copyright 1981, and version 2 is copyright 1982, etc.. If you have version 1, or you want the program to be compatible with versions 1 as well as later ones, then alter the two lines shown underneath, (10025 is an extra one), and it will then work OK on them all, though not on BAS128. All you have to do is add the routine before debugging your program, and make the very first line ON ERROR GOTO 10000. Of course, there is nothing magic about line 10000, so you can renumber the routine higher if you wish. In the example below, you should get the error "No such variable at line 100", as A$ hasn't been defined. Be very careful not to make mistakes when typing the routine; the listing should be copied exactly as shown, even if it looks rather odd, but you may omit all spaces if you wish. If you are debugging a listing from a magazine, miss out any other ON ERROR statements until you have finished. If you get into trouble, then press , type OLD , and you should get your program back. If you don't want to exit from the program when is pressed, then alter the number 10050 in line 10000 to the line where you do want the program to got to. You will find that this routine can save you a great deal of time in the long run. 10 ON ERROR GOTO 10000 100 PRINT A$:END:REM (Spot the deliberate mistake!) 10000 IF ERR=17 THEN 10050:REM (or other line number) 10010 MODE7:REPORT:PRINT" at line ";ERL':*FX15,0 10020 err$="L."+STR$(ERL)+CHR$(11)+CHR$(13) 10030 FOR bit%=1 TO LEN(err$) 10040 OSCLI("FX138,0,"+STR$(ASC(MID$(err$,bit%,1)))):NEXT 10050 END Make the following changes only if compatibility with Basic-I is important. 10025 DIM X% 12:Y%=X% DIV 256:REM For Basic-1 10040 $X%="FX138,0,"+STR$(ASC(MID$(err$,bit%,1))):CALL &FFF7:NEXT 65. Error calls ~~~~~~~~~~~ Here is a selection of interesting calls into ROM, suggested by Dave Woodhead. Most of them differ between Basic-1 and Basic-2, so Basic-1 addresses are given first, then Basic-2 addresses are in brackets. You can use them to deliberately generate errors inside a program, and they can be trapped in the usual way with ON ERROR GOTO, except for "fatal" ones such as 'Break', and 'Silly'. Note that the calls for 'Break' and 'Locked' are into the OS ROM, and apply to version 1.20 only. There must be all sorts of devious uses for these calls, especially the ones for 'Escape', 'Break' and 'Locked'. The syntax is simply CALL &D9CD, CALL &F1F9, and so on. D9CD=Soft Break D9DA=Hard Break F1F9=Locked 9839(982A)=Syntax error, 9848(9838)=Escape 97F0(9821)=Mistake A677(A66C)=Too big AA45(AA38)=Accuracy lost AE72(AE43)=No such variable B1B9(B18A)=Bad call, 8F2F(8FDF)=Silly 99A6(99A7)=Division by zero 98DD(9C03)=String too long AED9(AEAA)=Bad HEX. 66. Storing mode 7 screen ~~~~~~~~~~~~~~~~~~~~~ It can sometimes be useful to be able to store a screenful of information within a program, and to be able to recall it at will, without having to store all the appropriate variables. This is especially easy and quick with Mode 7 screens, although it can be done on others. The example below stores just one screenful at a time, but you could DIM extra space to save several screens at once, eg. DIM screen1% 1000,screen2% 1000,...... If you only want to save part of the screen, then reduce the upper and lower limits of the FOR-NEXT loop. The cursor is also returned to its original position on the screen. To prevent corruptions, it is a good idea to disable the Escape key while the screen is being loaded or saved, using the appropriate *FX command*. This will only correctly save a screen which hasn't been scrolled since the last MODE or CLS command. For this reason, it may also be necessary to use CLS before reloading a screen. Note that unlike true variables such as mem%, it is essential for HIMEM to be in brackets, due to a Basic interpreter quirk. PAGE and TOP, which are similar pseudo-variables, do not suffer from this problem. NB: *FX229,1 inhibits the Escape action *FX229 enables the Escape action 10 DIM screen% 1000:REM have this early in program 1000 DEF PROCsavescreen:LOCAL mem% 1010 FOR mem%=0 TO 996 STEP 4:mem%!screen%=mem%!(HIMEM) 1020 NEXT:vpos%=VPOS:pos%=POS:ENDPROC 2000 DEF PROCloadscreen:LOCAL mem% 2010 FOR mem%=0 TO 996 STEP 4:mem%!(HIMEM)=mem%!screen% 2020 NEXT:VDU31,pos%,vpos%:ENDPROC 73 Rick G4BLT @ GB7WRG