When programming on th BBC it is sometimes useful to be able to insert commands such as LIST and DELETE. But this results in a syntax error message.
There is a way of inserting the commands using a *FX call: *FX 138,0,X.
As an example the following program will list itself:
10 *FX 138,0,76
20 *FX 138,0,46
30 *FX 138,0,13
It works by inserting 'L' and '.' into the keyboard buffer followed by a carriage return.
I have used this to develop an error-trapping procedure. Place it at the end of the program and include the line ON ERROR PROCERROR near the start of the program. If the procedure is called, it explains what has happened and lists the offending line.
It works by taking the line number, converting it into a string and then one by one inserting each character into the keyboard buffer. It was written for the Electron, but will work on the BBC. However, due to the use of OSCLI, it will only work with Basic II machines.
5 ON ERROR PROCERROR
10 PRINT ME
20 END
3000 DEF PROCERROR
3010 REPORT
3020 PRINT" at line ";ERL
3030 REM FLUSH
3040 *FX 21
3060 *FX 138,0,76
3070 *FX 138,0,46
3090 E$=STR$(ERL)
3100 FOR X=1 TO LEN(E$)
3110 PART$=MID$(E$,X,1)
3120 E=ASC(PART$)
3130 OSCLI"FX"+STR$138+","+STR$0+","+STR$E
3140 NEXT
3150 *FX138,0,13
3160 END