(Comp.sys.handhelds) Item: 2005 by billw at hpcvra.cv.hp.com. Author: [William C Wickes] Subj: Modified HP48 IFERR Date: Fri Feb 08 1991 16:58 A New IFERR for HP 48 "Bulletproofing" Several HP 48 programmers have expressed a concern that the current error trapping mechanism via IFERR is vulnerable to repeated ATTN key presses, which can prevent a program from cleaning up when it is interrupted by the user. This problem arises because IFERR and all other branching constructs built into the HP 48 check to see if ATTN key has been pressed so that users cannot (easily) lock themselves into an uninterruptible loop. The object listed below in ASC-> form is an HP 48 library titled "IF ERROR", which provides an alternate version of IFERR/THEN which can be uniformly substituted for the built-in versions. The difference between this version and that built into the HP 48 is in the handling of ATTN. The ATTN key check is disabled for the THEN clause of the version provided in this library, allowing for an "unbreakable" recursive error recovery. An example of this use is given in the program below. In the "main" program, a loop display a counter running from 1 to 1000. If you press ATTN while it is running, the error trap starts another counting loop, this time from 1 to 50, to show you that an error termination sequence of some length is running. If you interrupt it, it just restarts itself. In the first line, the temporary variable 'et' is allocated. This variable will hold the error termination procedure after it is created in the next part of the program. The error termination procedure is simply a cleanup procedure protected by an IFERR which branches back to itself recursively if an error occurs in its execution. It is created in a list to avoid the inclusion of the opening and closing program quotes, which themselves have attention key checks. The remainder of the program is protected by IFERR...THEN et EVAL END. Notes: * You must access the error termination procedure via a temporary variable because global variable execution itself contains an attention key check. ["temporary variable" = local variable. -jkh-] * If your cleanup procedure has an unavoidable error, the only way to stop infinite execution is by [ON]-[C]. * The library (which has ID 1793) is auto-attaching: to use it, all you need to do is store it in a port (port 0, say) by putting it on the stack and executing 0 STO, and then turning the HP 48 off and on. * To convert old programs containing IFERR to the new version, you need only to EDIT (VISIT), then ENTER when the library is attached. Downloading a program in ASCII form via kermit will also automatically use the new IFERR. Sample error trap program: [saved on disk as ERRTRAP. -jkh-] ----------------- cut here ---------------------------------------------- %%HP:T(3); \<< 0 \-> et \<< { IFERR 1 50 FOR j "YOUR CLEANUP PROC." 1 DISP "#" j \->STR + " HERE" + 2 DISP NEXT THEN et EVAL ELSE DONE END } OBJ\-> DROP 'et' STO IFERR 1 1000 FOR j "YOUR MAIN PROC." 1 DISP "#" j \->STR " NOW" + + 2 DISP NEXT THEN et EVAL END \>> \>> ----------------- cut here ---------------------------------------------- (Comp.sys.handhelds) Item: 2012 by _macrokid at hpcvbbs.UUCP Author: [Kevin Vashi] Subj: IFERR bug. Date: Mon Feb 11 1991 14:48 Hello, I belive there is an bug in the IFERR library that was posted by Mr. Wickes few days ago. If you put the sample program on level 1 and execute X_TIME (Timing routine from Mr. Donnely's Toolkit) and if you press ENTER while it's running and then wait until it's done then the calculator performs a system halt. If anybody has any insights about this then please post it. Thank You, Kevin Vashi.