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.

MS Access technical tips

Visual FoxPro technical tips

General Tips

 

More tips from Alvechurch Data

Alvechurch Data - Microsoft FoxPro and Access Database Development and Training

Alvechurch Data are based close to Birmingham and provide Microsoft Access and Visual FoxPro training, development and support.

Read More

Autocomplete in Visual Fox Pro

Autocomplete in Visual Fox Pro

The textbox class in Visual FoxPro 9 has a new Autocomplete property which shows the user the previous values that have been entered in that textbox.

Read More

FoxPro Functions

FoxPro has always had functions like FREAD and FWRITE to read and write files at a low level. They can handle files which defeat the STRTOFILE and FILETOSTR functions.

Read More

Development Services

Alvechurch Data specialise in Microsoft Access and Visual FoxPro databases and have fifteen years experience developing databases for small business use.

Read More

Access and Visual FoxPro Training

Microsoft Access and Visual FoxPro training courses and workshops offered by Alvechurch Data in Birmingham.

Read More