Calculator, _CalcMem, _CalcValue
One of FoxPro's built-in tools plus two system memory variables that track the numbers stored in the calculator—the first stored in the calculator's memory and the second displayed.The calculator is a desk-accessory-like utility included with Visual FoxPro, similar to the Calendar/Diary. Microsoft is discouraging its use by removing it from the visual interface of Visual FoxPro and making no effort to improve its awkward appearance, interface or features. The calculator can be invoked by issuing the command ACTIVATE WINDOW CALCULATOR. You can make it available on an as-needed basis by adding the menu pad _MST_CALCU to your custom menu.The calculator can be operated completely from the keyboard. For those trivia buffs in the audience, here are the keystrokes that perform the equivalent button functions when the calculator has the focus:
Keystroke |
Button Label |
Effect |
A |
M+ |
Adds the current value to that stored in memory. |
C |
C |
Press once to erase (clear) the current value displayed, twice to erase the calculation in process. |
N |
� |
Reverses the sign of the current value. |
Q |
� |
Returns the square root of the current calculator value. |
R |
MR |
Recalls the value stored in memory. |
Z |
MC |
Clears (zeroes) the value in memory. |
S |
M- |
Subtracts the current value from that in memory. |
Usage |
nValue = _CALCMEM nValue = _CALCVALUE _CALCMEM = nValue _CALCVALUE = nValue |
If you assign values to _CALCVALUE and _CALCMEM, they appear to take. When you activate the Calculator, however, you may find the values displayed as rounded integers—no decimal places are displayed. You can read a value with decimal places just fine from the Calculator, but you can't place one there, unless there was already a decimal place displayed before. This bug appears to be in all versions of Visual FoxPro. _calcvalue = 123.456 ? _calcvalue && 123.46, rounded to your decimal setting ACTIVATE WINDOW calculator && You may see "123" If you clear the Calculator and enter ".0" as a value, and repeat the above lines of code, you should see 123.46 (or more decimals, depending on your setting). What's really interesting is that once you do this, the "setting" is stored in the FoxUser table, so that once it's stored in the FoxUser table, decimals are then always displayed. If you're going to use this feature in your apps, you might want to consider shipping a FoxUser table with your app. You'll need to "fix" your FoxUser first, then copy the record (ID = 'CALCULATOR') into the user's FoxUser table, because the Data field stores its settings in a binary format. |
Example |
SET DECIMALS TO 4 STORE PI() TO _CALCMEM _CALCVALUE = 2.123 ACTIVATE WINDOW CALCULATOR * If you've "fixed" your FoxUser table, you'll see "2.1230" * displayed, and pressing MR displays "3.1416". * If you haven't "fixed" your FoxUser table, you'll see "2" * and pressing MR displays "3". |
See Also |
Calendar/Diary, Desk Accessories, Filer, Puzzle, Set Decimals |