[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
CALCUDF()
To get/set the calculator key handler block.
------------------------------------------------------------------------------
Syntax
CALCUDF( [<bCalcUDF>], [<lAllKeys>] ) -> bOldCalcUDF
Arguments
<bCalcUDF> is an optional block parameter containing a code block
to evaluate upon (0) initialization, (1) operational keys,
(2) keyboard exceptions, and (3) termination. DEFAULTS TO NIL.
<lAllKeys> is an optional logical parameter denoting whether to
call the code block upon operational keys (i.e. not only keyboard
exceptions). DEFAULTS TO FALSE.
Returns
CALCUDF() returns the current CALCUDF() code block.
Description
You may use CALCUDF() to get/set the calculator key handler block.
Regarding the code block <bCalcUDF> (If it is not NIL):
. Will be evaluated with 7 parameters:
. Procedure name (always CALCULATOR)
. Version number (always 16 in version 1.6)
. The variable name when the Calculator hotkey was pressed or NIL
. Numeric representation of the current display
. Character representation of the current display
. Numeric mode (0=initialization call, 1=a key was pressed,
2=key exception, 3=termination)
. Character representation of the current calculator color
. Numeric representation of the last key pressed
(valid for mode #1 and 2 only) (same as LastKey())
. Will send as the 6th parameter the numeric mode:
0 = called upon entering the calculator
(best time to set up your own help screen for your keys)
2 = called upon a key exception (a key not recognized by
the calculator operation and no setkey exists)
3 = called upon exiting the calculator
(best time to take down your help)
(If <lAllKeys> is true, then mode 1 will be called,
else if will not be called):
1 = called upon any keypress in the calulator,
prior to executing any operation that the key represents
. Return Values of the code block
(The following applies to mode 0, 1, and 2 only - not 3):
. If your code block returns a TRUE, the calcuator will immediately
return without further processing.
. If your code block returns a NUMERIC, the calculator will
display the numeric as the last result of the calculator.
. If your code block returns a CHARACTER, it will be "keyboarded"
into the calculator as if the user had typed it him/herself
(Be aware of the current SET TYPEAHEAD).
. Any other data type will be ignored and processing will
continue normally.
Examples
** Example
Function Test()
//Sets the UDF to call during the calculator
// but (.F.) do not call with ALL keys
bOldUDF := CALCUDF( {|x1,x2,x3,x4,x5,x6,x7,x8| ;
MyCalcUDF(x1,x2,x3,x4,x5,x6,x7,x8) } , .F. )
Calculator()
RETURN NIL
Function MyCalcUDF(cProc,nVer,cVar,nValue,cValue,nMode,cColor,nKey)
Local xRetCode := .F. //continue normally
Do Case
Case nMode = 0 //Initialization call
//put up extra help menu for *MY* keys & save screen
Case nMode = 3 //Termination call
//take down my help screen
Case nMode = 2 //Key Exception call
Do Case
Case nKey == K_ALT_F2 //my Square Root
xRetCode := SQRT(nValue)
Case nKey == K_ALT_T //my add tax key!
xRetCode := nValue * 1.0775
Case nKey == "~" //my sign reverse key!
xRetCode := -nValue
Case nKey == K_ALT_M //my memory counter key!
CalcMemory( CalcMemory()+1 )
Endcase
Endcase
Return xRetCode
-----------------------------------------------------------------------
. NOTE
(When initially entering the calculator, or during keyboard calls):
. If your code block returns a TRUE, it will immediately
abandon the calculator without further processing.
. If your code block returns a NUMERIC, the calculator will
display the numeric as the last result of the calculator.
. If your code block returns a CHARACTER, it will be "keyboarded"
into the calculator as if the user had typed it him/herself
(Be aware of the current SET TYPEAHEAD).
. Any other data type will be ignored and processing will
continue normally.
This NOTE does not apply to the call when exiting the calculator.
-----------------------------------------------------------------------
Files: CALC.LIB
Author: Touchstone Business Creations CompuServe ID: 73670,2561
28613 River Glen Ct. #1
Menifee, CA 92584-8987 USA
(909) 679-3364
Owner : (c) Copyright, 1991,92,93 Touchstone Business Creations
See Also:
CALCPOS
CALCINIT()
CALCULATOR()
CALCREG()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson