FoxPro Calculator

[Calculator accessory in Visual FoxPro] Visual FoxPro includes a simple four-function calculator which might be useful in some situations. This calculator is nowhere near as sophisticated as the tool in Windows Accessories, it is just a simple four-function calculator with memory. Despite that, it will be adequate for many everyday uses and can very easily be integrated with your FoxPro application. It can be distributed as part of your application with no licensing problems.

The calculator does not appear as an option on any of the the standard FoxPro menus. The only way to make it appear is through FoxPro program commands - either from the Command Window or from within a program. The calculator's displayed value and stored memory value are both available as FoxPro system memory values.

Controlling the Calculator

You can write code to call the calculator from a command button or from a menu option. Displaying the calculator is a simple matter of making its window visible:

Activate Window 'calculator'

You can hide the calculator programatically with the commands Hide Window or Release Window. Alternatively you can allow the user to close it in the normal way.

The calculator values are stored as FoxPro system variables:

_CALCVALUE      && Value displayed
_CALCMEM        && Value in memory

Both these system memory variables are Read/Write so you can put default values into the calculator display or memory before it appears and you can read them back to use in further calculations.

Because the Calculator is a window within FoxPro, you can use the standard functions to inspect its status. For example:

?WVISIBLE ('calculator')

will return .T. if the Calculator window is visible.

Like the Calendar, the Calculator tool has been available since version 2.00 of FoxPro for DOS. Both tools look rather dated now but both can still be very useful.