Module ; TRAP.ACT ;Use this routine to trap errors like ;Basic. Where ever you want the program ;to return to in your program just ;call Trap. In your error checking ;call Trap_Return and it will return ;to where Trap is located. ;Written by Joe Lesko Byte S_P,Jmp_L,Jmp_H Byte End Byte Counter=[0] Define STA="$8D", LDA="$AD", STX="$8E", LDX="$AE", TXS="$9A", TSX="$BA", PHA="$48", PLA="$68", RTS="$60" Proc Trap_Return() [ LDX S_P TXS LDA Jmp_L PHA LDA Jmp_H PHA RTS] Proc Trap() [ PLA STA Jmp_H PLA STA Jmp_L TSX STX S_P PHA LDA Jmp_H PHA RTS] Module Proc MyError(Byte Err) End=0 If Err=128 and Counter>=5 Then End=1 Else Trap_return() Fi Return Proc Example() End=0 Counter=0 Error=MyError Trap() Counter==+1 Position(2,5) PrintBE(Counter) Do Position(2,2) PrintE("Hit the [BREAK] and the Counter") PrintF("Value will be incremented and printed%E") If End=1 Then Exit Fi od Return