Custom Errors.txt
Warning: if you clip this code into your program, look out for possible html code slipping in.
REM Example to demonstrate generating an ON ERROR condition on the SBC2000-074 REM and SBC2000-062. REM REM Author: Steven R. Wheeler REM REM Copyright 1998 Vesta Technology, Inc. REM All rights reserved. REM It is possible for an application to generate an ON ERROR condition. This REM allows you to have an error handling routine which handles not only the REM errors which are generated by the runtime engine, but also any errors you REM can make your application detect. There are two things which are required. REM First, you must assign unique error codes to the conditions you generate, REM and place those error codes where the error handler can find them. Second, REM you must realize that as soon as you set the bit indicating that an error REM condition has occurred, the runtime engine will want to vector to the REM error handler BEFORE THE START OF THE NEXT PCODE INSTRUCTION. The only way REM you can postpone the jump to the handler at all is to perform the setting REM of the bit within a VITAL subroutine. In this case, the runtime engine will REM not vector to the error handler until you exit the subroutine. REM Error codes can be in the range from 1 to 255. The following values have REM already been defined in the runtime engine: REM REM 0 = no error REM 20 = divide by zero REM 21 = invalid input to math routine REM 22 = arithmetic overflow REM 70 = No memory available (stack overflow) REM 81 = No acknowledge from VAST IIC device REM 88 = Serial port/other timeout REM 99 = Basic internal error (stack underflow) REM The following two declarations are the key ones. They are made (with other REM names) in the monitor. If you always compile with debug, you could remove REM these declarations and use the names declared in the monitor. Keeping these REM declarations will allow your code to run when compiled with or without debug REM enabled. CONSTANT Error_Code AS INTEGER = 0x3B GLOBAL Error_Flag AS BIT = 0x39,2 REM This routine will set an error. If you provide an error handler in your REM application, it will obtain control when the return from the subroutine REM is executed. Call this subroutine with the error code you have assigned. REM Any code you add to this routine will be executed before the error is REM handled. VITAL SUBROUTINE Set_Error(type AS INTEGER) POKE(Error_Code, type) Error_Flag = 1 END
© 2002 Vesta Technology