Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Grumpfish Library 3.2 - <b>popcalc()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
POPCALC()

    Here is a useful calculator that includes all the basic operators:
    addition (+), subtraction (-), multiplication (*), and division (/).
    But it also has some other goodies, including exponentation (),
    percentages (%), configurable decimal display and rounding, a paste
    function and a full-featured memory.  Plus, whenever you press an
    operator ('+', '-', '*', '/', or ''), the previous number is shown
    above the display window.  This is handy for when you are processing
    a list of numbers and forget where you were.  Finally, if the
    calculator is blocking some important information on the screen, you
    can move it out of the way with the navigation keys!

    The maximum value that can be stored in the calculator is
    99,999,999,999.9999.

    Active Keys

    '+' - addition
    '-' - subtraction
    '*' - multiplication
    '/' - division
    '' - exponentation
    '%' - percentage

    Other Active Keys

    'C' - clear current number
    'E' - clear entry
    'D' - change number of decimals displayed
    'R' - round to specified number of decimals
    'P' - print (adding machine mode)
    'M' - Memory operations
    '=' or Enter - process operation
    Backspace - erase last digit entered
    Esc - exit Calculator

    Memory Functions

    To access memory functions, press "M    then one of the flashing
    function keys.  The function keys are:

    'R' - recall number stored in memory
    'C' - clear memory (reset to zero)
    '+' - add current number to memory
    '-' - subtract current number from memory
    '*' - multiply memory by current number
    '/' - divide memory by current number

    Paste function

    The paste function enables you to paste the current calculator value
    into a pending READ by pressing a designated hot key (Ctrl-P is
    suggested).  PASTE CAVEAT: erratic results may occur if the number
    of decimal places in the number to be pasted is larger than the
    number of decimals in the memory variable or field.  For example,
    suppose that you have just used the calculator to derive the result
    75.2877.  You wish to paste this number into a memory variable
    mTOTAL, which you are GETting with a picture template of '###.##'.
    The probability is strong that this number will be stored on-screen
    as 75.29 (although internally it will remain 75.2877).

    Print - Adding machine mode

    By pushing "P" for Print, the calculator emulates an adding machine.
    This will be noted by a small "P" to the right of the number window.
    Each calculation will be sent to the printer (if it is on-line).
    After all, if you have invested several thousand dollars in PC
    hardware (and software), why spend more money on a ten-key adding
    machine?  Press "P" again to toggle adding machine mode off.

    User-Defined Color/Position

    The color and screen position of the calculator window may be
    changed "on-the-fly".  The following keys may be used;

    UpArrow - move calculator up one row
    DnArrow - move calculator down one row
    LtArrow - move calculator left one column
    RtArrow - move calculator right one column
    Ctrl-LtArrow - move calculator to far left
    Ctrl-RtArrow - move calculator to far right
    Home - move calculator to top left corner
    End - move calculator to bottom right corner
    PgUp - move calculator to top row
    PgDn - move calculator to bottom row
    Alt-F10 - change color of calculator window

    Pressing Alt-F10 will display the interactive color palette. You may
    change the color by using the arrow keys to navigate through the
    palette.  Press Enter to select the desired color.  If you press
    Esc, the color will be unchanged. (Please refer to the discussion on
    COLORPAL() elsewhere in this manual for further specifics).

    If you change either the screen position or the color, upon exit
    you will be asked if you wish to save the new settings.  If so,
    the following three PUBLIC variables will be created:

    GFCALCLEFT    Stores leftmost column for calculator window
    GFCALCTOP     Stores top row for calculator window
    GFCALCCOL     Stores color to use for calculator window

    POPCALC() checks for the presence of these variables upon entry, and
    if they are detected, it will use their values in place of the
    defaults, which are 5, 28, and white on magenta, respectively.
    If you wish to save these settings in a more permanent fashion,
    you could easily modify the source code to write these variables
    to a memory (.mem) file, then restore them at the top of your
    program.

    Using the Calculator in your programs

    There are two ways that you can make use of the calculator.  The
    first method is to use the SET KEY command to establish a "hot-key"
    so that you can pop up the calculator anywhere within the program.
    The following lines added at the top of your program configures the
    F6 key to serve as the hot key for the pop-up calculator and Ctrl-P
    as the hot key for the paste function:

    *** Summer '87 syntax                         
    EXTERNAL popcalc     && make symbol for linker
    PUBLIC paste_no      && for pasting           
    calckey = -5         && hot key: F6           
    SET KEY calckey TO popcalc                    
    SET KEY 16 to paste  && Ctrl-P (optional)     

    // Clipper 5.0 syntax    
    #include "inkey.ch"      
    SET KEY K_F6 TO popcalc  
    SET KEY K_CTRL_P to paste

    If you want to use different keys as hot keys, please refer to your
    Clipper manual for a list of INKEY() values.

    The second method is to call the calculator directly.  The following
    is a sample menu including the calculator as a menu option:

    PUBLIC paste_no                          
    SET KEY 16 TO paste                      
    @ 05,05 PROMPT "Data Entry"              
    @ 06,05 PROMPT "Calculator"              
    @ 07,05 PROMPT "Exit to Operating System"
    MENU TO selection                        
    DO CASE                                  
       CASE selection = 1                    
          dataentry()                        
       CASE selection = 2                    
          popcalc()                          
       CASE selection = 3                    
          QUIT                               
    ENDCASE                                  

    Clipper 5.0 Notes

    - All PUBLIC variables have been eliminated.
    - Changes to position and/or color are handled with STATIC variables.
    - You may use the paste feature without having to declare PASTE_NO as
      PUBLIC in your calling routine.
    - It is no longer necessary to declare the variable CALCKEY when
      assigning a hot key.
    - It is no longer necessary to declare POPCALC as EXTERNAL, because
      SET KEY will automatically establish a symbol for the function.

See Also: COLORPAL() GINKEY() GRUMPCALC()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson