DOCUMENT:Q183522 16-JUN-1999 [foxpro] TITLE :FIX: Divide by Zero Creates Err with Third-Party Print Drivers PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:5.0,5.0a,6.0 OPER/SYS: KEYWORDS:kbservicepack kbvfp600 kbvfp600fix kbVS600sp2 kbVS600SP1 kbVS600sp3fix ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a, 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== If certain third-party printer or fax drivers are loaded when one of several commands, which invoke printer driver routines are used, and followed by division by zero, Visual FoxPro 5.0 or 5.0a terminates with the following error: This program has performed and illegal operation and will be shut down. If the problem persists, contact the program vendor. When you click the Details button, the following information displays: VFP caused an exception 10H in module VFP.EXE at
. Under similar circumstances, Visual FoxPro 6.0 may hang or cause Windows 95 or Windows 98 to display a blue screen error similar to the following: A fatal exception 0D has occurred at 0028:c0038f07 in VXD VMCPD(01) + 00002DB. The current application will be terminated. * Press any key to terminate the current application. * Press CTRL+ALT+DEL again to restart your computer. You will lose any unsaved information in all applications. These errors can occur during report printing, report preview, or issuing one of several other commands followed by a BROWSE with the KEY clause. This error may also occur randomly. Please see the RESOLUTION section for more scenarios that can cause the errors. CAUSE ===== Visual FoxPro sets the numeric coprocessor to handle exceptions in hardware. The printer driver routines change this numeric coprocessor setting so that coprocessor exception handling takes place in software, but fails to restore the original setting when the printer driver routines have completed. When a subsequent numeric coprocessor exception occurs in Visual FoxPro (division by zero, for instance), the numeric coprocessor expects the exception to be handled in software. Visual FoxPro is not able to do this, and an exception error, crash or hang occurs. RESOLUTION ========== Here are three ways you can work around this error: - Use a printer driver supplied with Windows 95. -or- - Disable the numeric coprocessor through Control Panel. Open Control Panel and double-click the System icon. In the System Properties dialog box, select the Device Manager tab. Scroll down the list and expand the System Devices listing. Double-click Numeric Data Processor and select the Settings tab. Make sure the option button "Never use the numeric data processor" is selected. NOTE: This change may result in the following error messages on reboot: A fatal exception 0D has occurred at 0028:c0038f07 in VXD VMCPD(01) + 00002DB. The current application will be terminated. * Press any key to terminate the current application. * Press CTRL+ALT+DEL again to restart your computer. You will lose any unsaved information in all applications. If this happens, restart in safe mode. Enable the numeric coprocessor through the Control Panel. Open Control Panel and double-click the System icon. In the System Properties dialog box, select the Device Manager tab. Scroll down the list and expand the System Devices listing. Double-click Numeric Data Processor and select the Settings tab. Make sure the option button "Always use the numeric data processor" is selected. After restarting the computer, the preceding error is gone; however, either item 1 or item 3 is required to resolve the 10h error. -or- - Use the _fpreset function in the Microsoft Visual C++ run-time DLL to reset the numeric coprocessor. This is demonstrated in the following code: *-- Code begins here DECLARE _fpreset IN msvcrt20.dll =_fpreset() *-- Code ends here This can be implemented within an application by adding this to the beginning of your main program: DECLARE _fpreset IN msvcrt20.dll The DECLARE statement only needs to be made once. You should use the call to _fpreset() immediately after using any of the following functions or commands: GETPRINTER() REPORT FORM ... TO PRINTER REPORT FORM ... PREVIEW SET( "Printer", 2) SET( "Printer", 3) SET PRINTER TO NAME