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>grumpcalc()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
GRUMPCALC()

    This function pops up a simple spreadsheet.  It is perfect for
    situations where the user needs to perform calculations to determine
    what value should be entered into a numeric GET. GRUMPCALC() allows
    you to make references to other cells, to sum a rectangular group of
    cells, to print all or part of the spreadsheet.  Negative numbers
    are shown in red (although you can change this behavior as discussed
    below).

    Other features include the ability to use Lotus-style justification
    formulae and change column widths. Recalculation is automatic and
    fully recursive.

    Syntax

    GRUMPCALC( [ <calc> ] )

    Optional Parameter

    <cfile> is the name of a presaved spreadsheet file to load
    immediately.  If <cfile> is not used, GrumpCalc will start you out
    with a blank spreadsheet.  If you have already visited GrumpCalc,
    your previous spreadsheet will be restored exactly as you left it.

    Hot-key

    You will probably want to configure GrumpCalc() to be called by a
    hot key with the command:

        SET KEY <nKeypress> TO grumpcalc

    If you do this, GrumpCalc() will detect the presence of the three
    default Clipper parameters (proc, line, var) and will therefore
    neither attempt to load a pre-saved spreadsheet file NOR prompt you
    to save it. The reasoning here is that such use would be to paste
    the result of a calculation into a pending GET.

    If you have configure GrumpCalc() as a hot-key and pop it up while
    you are GETting a numeric, the contents of the current cell will be
    pasted into the GET upon exit.

    Return Value

    GRUMPCALC() does not return a value.  However, if a numeric GET is
    active, it will paste the contents of the last cell into the GET
    just prior to exit.

    Active Keys

    Up Arrow       Move up a row unless already at top
    Down Arrow     Move down a row unless already at bottom
    Left Arrow     Move left a column
    Right Arrow    Move right a column
    PgUp           Move to top row of spreadsheet
    PgDn           Move to bottom row of spreadsheet
    Home           Move to top left cell of spreadsheet
    End            Move to bottom right cell of spreadsheet
    Ctrl-Left      Move to leftmost column
    Ctrl-Right     Move to rightmost column
    Tab            Pan right one screen
    Shift-Tab      Pan left one screen
    Enter          Edit current cell (see below)
    F2             Edit current cell (see below)
    Letter keys    Edit current cell (see below)
    Number keys    Edit current cell (see below)

    Editing a Cell

    You can edit a cell by pressing Enter, F2, or any letter or numeric
    key (actually, any key that has an ASCII scan code greater than 31).
    Enter and F2 are equivalent with one important exception: Enter will
    cause the left and right arrows to be redefined to end editing and
    move you to the left or right adjacent cell, respectively.

    Negative Numbers

    By default, GRUMPCALC() will show negative numbers in red.  If you
    do not wish this behavior, please remove the line that defines the
    manifest constant NEGATIVES_IN_RED (which appears near the very top
    of the file GRUMCALC.PRG).  Then recompile and either link in the
    resultant GRUMCALC.OBJ file, or put it into GRUMP.LIB with a library
    manager.

    Justification Formulae

    If you are familiar with Lotus (TM), you know that you can precede
    character-type entry with one of the following three special
    characters:

    Character      Action
        "          Left-justifies the text
        '          Right-justifies the text
                  Centers the text in the column

    For example, if you want to center the text "Heading", you would
    enter "Heading".

    Cell References

    A cell can refer to two or more other cells.  To do so, simply
    enter the addresses of the cells, being certain to precede the
    first cell address by a plus sign ("+").  Here are some examples:

    +A1+A2                // hold sum of cells A1 and A2
    +A1+A2-A3             // hold sum of cells A1 and A2 less A3
    +A1*A2                // hold product of cells A1 and A2

    Highlighting a Group of Cells

    You may highlight a group of cells by locating the beginning of the
    region and pressing F10.  Then use the arrow keys to move the cursor
    to the end of the region and press F10 again.  You may then either
    print that highlighted region or paste the sum of all its cells into
    a different cell.

    To paste the sum of the region into a different cell, move to the
    target cell and press F10 for a third time.

    Printing

    You may print either the entire spreadsheet, or the highlighted
    region (if there is one), by pressing Alt-P.

    Column Width

    You may change the width of the current column by pressing Alt-W.

    Sample Usage

    #include "inkey.ch"       
                              
    function test             
    local x := 0              
    set key K_F10 to grumpcalc
    @ 20, 20 get x            
    read                      
    return nil                

See Also: POPCALC()

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