How can I avoid the Abort, Retry, Fail messages? Ans. When DOS encounters a critical error, it issues a call to interrupt 24, the critical error handler. Your C compiler library contains a function named harderr() that takes over the handling of calls to interrupt 24. The harderr() function takes one argument, a pointer to a function that is called if there is a hardware error. Your user-defined hardware error-handling function is passed information regarding the specifics of the hardware error that occurred. In your function, you can display a user-defined message to avoid the ugly Abort, Retry, Fail message. This way, your program can elegantly handle such simple user errors as your not inserting the disk when prompted to do so. When a hardware error is encountered and your function is called, you can either call the C library function hardretn() to return control to your application or call the C library function hardresume() to return control to DOS. Typically, disk errors can be trapped and your program can continue by using the hardresume() function. Other device errors, such as a bat FAT (file allocation table) error, are somewhat fatal, and your application should handle them by using the hardretn() function. Consider the following example, which uses the harderr() function to trap for critical errors and notifies the user when such an error occurs: #include #include #include #include void main(void); void far error_handler(unsigned, unsigned, unsigned far*); void main(void) { int file_handle, ret_code; /* Install the custom error-handling routine. */ _harderr(error_handler); printf('\nEnsure that the A: drive is empty, \n'); printf('then press any key.\n\n'); getch(); printf('Trying to write to the A: drive...\n\n'); /* Attempt to access an empty A: drive... */ ret_code = _dos_open('A:FILE.TMP', O_RDONLY, &file_handle); /* If the A: drive was empty, the error_handler() function was called. Notify the user of the result of that function. */ switch (ret_code) { case 100: printf('Unknown device error!\n'); break; case 2: printf('FILE.TMP was not found on drive A!\n'); break; case 0: printf('FILE.TMP was found on drive A!\n'); break; default: printf('Unknown error occurred!\n'); break; } } void far error_handler(unsigned device_error, unsigned error_val, unsigned far* device_header) { long x; /* This condition will be true only if a nondisk error occurred. */ if (device_error & 0x8000) _hardretn(100); /* Pause one second. */ for (x=0; x - Study24x7
Social learning Network
13 Apr 2023 01:04 PM study24x7 study24x7

How can I avoid the Abort, Retry, Fail messages? Ans. When DOS encounters a critical error, it issues a call to interrupt 24, the critical error handler. Your C compiler library contains a function named harderr() that takes over the handling of calls to interrupt 24. The harder...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles