CALC The Clipper (tm) Calculator by Touchstone Business Creations Version 1.3 June 1991 Copyright (c) Touchstone Business Creations 1991 All Rights Reserved 1 INTRODUCTION .....................................1-1 1.1 Purpose ......................................1-1 1.2 Disclaimer ...................................1-1 1.3 Trademarks ...................................1-1 1.4 Technical Support ............................1-1 1.5 License Agreement ............................1-1 1.6 Royalty Agreement ............................1-2 1.7 Coming Attractions ...........................1-3 2 THE CALC PROGRAM .................................2-1 2.1 Usage ........................................2-1 2.2 Running the CalcEasy demo ....................2-1 2.3 Functions ....................................2-1 Calculator() .................................2-2 CalcReg() ....................................2-5 CalcInit() ...................................2-6 1 INTRODUCTION 1.1 Purpose CALC has been developed for the programmer, to add a natural, yet powerful calculator to his application. CALC works with the Clipper 5.01 development system on IBM compatible computers. 1.2 Disclaimer. THE AUTHOR (Touchstone Business Creations) CLAIMS NO RESPONSIBILITY FOR ANY DAMAGES CAUSED BY THE USE OR MISUSE OF CALC. THIS PRODUCT IS DISTRIBUTED "AS IS," WITH ONLY A LIMITED 30 DAY WARRANTY WHICH REPLACES THE MEDIA ON WHICH CALC WAS ORIGINALLY SOLD, IF (1) PURCHASED WITH A DISK FROM Touchstone Business Creations, AND (2) WAS DAMAGED. 1.3 Trademarks. Clipper is a registered trademark of Nantucket Corporation. IBM is a registered trademark of International Business Machines. 1.4 Technical Support. As a registered user, you retain the right to technical support regarding this file's use for a period of 45 days from purchase. After this, your support is at the discretion of the technical supervisor at Touchstone Business Creations. To receive technical support: call Touchstone Business Creations at (818) 330-8383 x115 or write TBC at 1313 N. Grand Ave. Suite 315 Walnut, CA 91789 USA Be sure to have your registration number at hand (or if writing, include it, please). 1.5 License Agreement. Touchstone Business Creations retains the ownership of this copy of CALC. You may not transfer, sell, copy (or reproduce in any form), disassemble, reverse engineer, or alter CALC in any way. You are licensed to use this file to develop Clipper executables. You may not transfer, rent, give, or lease this license. Violators will be prosecuted. As a registered user, you retain the right to use CALC in one of the two methods following: Page 1-1 (1) As a private developer, you may take CALC with you, on any computer, at any time, provided that you are the only user of CALC. (2) As a corporate developer, you may use CALC on one computer, and allow your co-workers (up to ten) that work in the same area (and generally on the same projects) as you do, to use it on one computer each. Please choose one of the above methods of use and adhere to it. Of course, this license (like other software's) has the ability to be abused. Considering how people truly use software, the above methods were devised. They are viewed as fair, and more realistic than the standard "one user, one machine, one time" rule. Please abide by the agreement. Also, if you have ideas regarding new licensing agreements, please let us know. Since there is no standard for these agreements (yet), we really wish to work with the reality of how people use software, without jeopardizing future sales of this product. 1.6 Royalty Agreement. This program, CALC is distributed "Royalty Free," meaning that, if produced IN ACCORDANCE WITH THE LICENSE AGREEMENT, any and all executables that use CALC are free of any financial holds to Touchstone Business Creations. 1.7 Coming Attractions! ** COMING SOON ** Other products to be released soon are: SciCalc() -full-featured scientific calculator with trig and full trig functions you may call in your programs. Calendar() -pop-up full-featured calendar, scroll through days, months, years, see and set holidays, calculate no. of work days, and upon pressing Ctrl-Enter transfers date back to date field. MUCH MORE! Register to receive all notices & updates! ** REGISTERED USERS OF CALC WILL RECEIVE DISCOUNTS TOWARDS ** ** ANY OTHER TOUCHSTONE BUSINESS CREATIONS PRODUCT ** Page 1-2 2.1 Usage Assuming that you have written a program, such as a sample program included in this package, CalcEasy, you must compile and link as follows (included in calceasy.rmk) rmake calceasy 2.2 Running CalcEasy The program begins with three variables, two numeric and one character. To begin a calculation, press Alt-O. The value of 5 is transferred into the calculator. To receive calculator help, press H. When finished with your calculation, either press Esc to exit, or Ctrl-Enter to paste the result back to the field. Detailed information is available in the following reference pages. 2.3 Functions The following calculator functions are formatted in the standard form as set by the Clipper manual. This allows you to print these pages and place them with your manual. The following pages are a reference to the functions available in CALC. Page 2-1 Name CALCULATOR() Purpose On-screen Full-Function Calculator Syntax CALCULATOR( [,] [] ) -> nResult Arguments is a numeric value which becomes the initial value to display in the calculator. Defaults to zero, unless called from a READMODAL numeric variable. is a logical value; if set to true, will attempt to grab from a numeric variable (if called from one) and will paste if exited by pressing Ctrl-Enter. If, however, you have reason to prevent the numeric grabbing and the paste-back, set it to false. Defaults to whether (1) called from a numeric variable or (2) a numeric value was passed in . Returns A numeric result of the calculations. If the user presses Ctrl-Enter to exit the Calculator, the keyboard will also be stuffed with the result. Description At its most basic use (SET KEY ... TO CALCULATOR) the calculator will pop up on screen (with a numeric if called from a get) allowing calculations, percentages, parenthesized calculations, memory (static), printing, fixed decimals, and a help screen. When pressing Ctrl-Enter to exit, it will paste the result to your variable. In its more advanced use, you may set keys to do your own special functions and calculations (SET KEY K_F9 TO FINANCIAL), or train the calculator to search for and change to a separate color scheme, or call a special procedure before entering the calculator, or call the calculator as a function and return the result. Requirements You must call CalcReg( ) to bypass the copyright screen. SEE CALCREG() Page 2-2 Examples * Example 1 #include "inkey.ch" CalcReg(12345) // example registration number Set Key K_ALT_O to Calculator n1:=5 c1:=Space(8) @ 5,5 Get n1 @ 6,5 Get c1 READ // press ALT_O for calculator *------------------------* * Example 2 #include "inkey.ch" CalcReg(12345) // F5 will multiply n by 2 and return it (from calculator) SetKey(K_F5,{|p,l,v,n| If( p="CALCULATOR", n*2, NIL ) }) // F6 will automatically keyboard any character returns, // in this case, setting fixed decimals to 2 SetKey(K_F6,{|p| If( p="CALCULATOR", "F2", NIL) }) // F1 will call the calculator's help SetKey(K_F1,{|p| If( p="CALCULATOR", "H", NIL) }) nResult := Calculator(5) // pops up with a 5, returns a result Notes (FOR ADVANCED USE) SETKEY PROCEDURES When it calls your set key procedure, it will pass five parameters: þ Procedure name (always CALCULATOR) þ Version number (always 13 in version 1.3) þ The variable name when the Calculator hotkey was pressed or NIL þ Numeric representation of the current display þ Character representation of the current display Page 2-3 When you return a result, it may be numeric, character, or other: þ If you return a numeric, it will become the current display þ If you return a character, it will be "keyboarded" as if the user typed it himself (be aware of your current SET TYPEAHEAD) þ If you return any other value, it will be ignored Keys Available: KEY OPERATION þ 0-9 (standard numeric keys) þ +,-,/,* (standard arithmetic keys) þ % Perform percentage calculation þ ( Begin a sub-calculation (may be nested) þ ) End a sub-calculation þ = End a calculation (and all sub-calculations) þ[Enter] End a calculation (and all sub-calculations) þ[Bksp] backup, erase last keystroke þ AC Clear all (except memory) þ C Clear Entry þ H Display calculator help. þ P Toggle printing; if printing is used, upon exit of the calculator, a form feed will occur. þ F n Set fixed decimals to (n). 0-9 to fix, other key for floating point. þ M+ Add to memory (static - will keep throughout program) þ M- Subtract from memory þ M* Multiply to memory þ M/ Divide into memory þ MR Recall memory þ MC Clear memory þ [Ctrl-Left / Ctrl-Right] Move Calculator þ [Esc] Exit calculator (do not paste) þ [Ctrl-Enter] Exit calculator (PASTE RESULT TO FIELD) (applicable when called from a variable, or when first parameter is numeric and second parameter is true) Files: CALC.OBJ See Also: CALCREG() CALCINIT() Author: Touchstone Business Creations CompuServe ID: 73670,2561 1313 N. Grand Ave. Ste 315 Walnut, CA 91789 USA (818) 330-8383 extn 115 Owner : (c) Copyright, 1991, Touchstone Business Creations. Page 2-4 Name CALCREG() Purpose To Register the On-screen Full-Function Calculator Syntax CALCREG( ) -> NIL Arguments is a numeric value representing your registration number. This function will bypass the copyright screen on initial use of the calculator. Returns CALCREG() always returns NIL Description Use CALCREG() to register your calculator and prevent the copyright message from appearing on the initial call to the calculator. Requirements You must have a valid registration number. You may obtain one from Touchstone Business Creations, 1313 N. Grand Ave. Ste 315, Walnut California 91789 USA. The phone number is (818) 330-8383 extn 115. Examples CalcReg(12345) Files: CALC.OBJ See Also: CALCULATOR() CALCINIT() Author: Touchstone Business Creations CompuServe ID: 73670,2561 1313 N. Grand Ave. Ste 315 Walnut, CA 91789 USA (818) 330-8383 extn 115 Owner : (c) Copyright, 1991, Touchstone Business Creations Page 2-5 Name CALCINIT() Purpose To set the calculator colors, a set of colors, or a codeblock to execute, upon each call to the calculator and each exit. Syntax CALCINIT( [ ) -> NIL Arguments may be a character color value, an array of colors, a code block, or other data type. Defaults to NIL (automatically setting the colors to "N/W") Returns CALCINIT() always returns NIL Description You may use CALCINIT() to set the calculator colors, to search and replace set of colors, to execute a code block, or to default to current colors. Regarding the parameter : þ If it is a character color value, it must be in the standard color format (i.e. "W+/B") (SEE EXAMPLE 1) þ If it is an array, it must be two dimensional, the first to search and match the current colorset (it must contain one comma); the second to set the color upon finding a match (SEE EXAMPLE 2) þ If it is a code block, it will be called upon each entry to and each exit from the calculator with seven parameters (SEE EXAMPLE 3) þ If it is NIL (the default), it will set the calculator colors to "N/W" (SEE EXAMPLE 4) þ If it is any other data type (such as logical), it will keep the colors that it was called with (SEE EXAMPLE 5) Page 2-6 Examples ** Example 1 - character parameter CALCINIT( "W+/B" ) // calculator will now operate as white on blue Calculator() ** Example 2 - array aColors := { {"W+/N," , "N/W" } ,; //color must include comma {"R+/B," , "B+/R"} ,; {"" , "W/N" } } //all non-matched colors // will match with "" CalcInit( aColors ) * The above example will (upon calling the calculator), check the * current color against "W+/N," and, if found, set the color to "N/W". * If not, will compare against "R+/B," and, if found set the color to * "B+/R". If neither is found, the "" will be matched and the color * set to "W/N". ** Example 3 - code block #include "inkey.ch" CalcInit( {||SetColor("B/N"),; SetKey(K_F5,{|p,l,v,n| If(p="CALCULATOR", n*2, NIL)}) } ) * The above example will (upon calling the calculator), evaluate the * code block and set the color to "B/N" and set the F5 key to multiply * by 2. ** The best use of this feature is to call a function, pop up your * personalized help screen and replace it upon exit * (SEE CALCHARD.PRG) * PARAMETERS: The seven parameters passed to the code block are * þ Procedure (always "CALCULATOR") * þ Version (always 13 in version 1.3) * þ The variable name when the Calculator hotkey was pressed * þ Numeric representation of the initial display * þ Character representation of the initial display * þ Character designator "INIT" when beginning the calculator, or "END" when exiting the calculator. * þ Color string when entering calculator * NOTE: if the code block returns a TRUE (.T.), it will abandon the * calculator (before displaying anything) * * If you return a character, it will be "keyboarded" as if the * user typed it himself (be aware of your current SET TYPEAHEAD) Page 2-7 ** Example 4 - NIL (default) CalcInit(NIL) // or never issuing a CalcInit() SetColor("W/B") Calculator() // this will operate the calculator in the default // color of N/W ** Example 5 - other, (logical) CalcInit(.T.) SetColor("W/B") Calculator() // this will operate the calculator in W/B Files: CALC.OBJ See Also: CALCULATOR() CALCREG() Author: Touchstone Business Creations CompuServe ID: 73670,2561 1313 N. Grand Ave. Ste 315 Walnut, CA 91789 USA (818) 330-8383 extn 115 Owner : (c) Copyright, 1991, Touchstone Business Creations Page 2-8 ORDER FORM Make and send CHECK or MONEY ORDER payable to: TO: Touchstone Business Creations 1313 N. Grand Ave. Ste 315 Walnut, CA 91789 U.S.A. (818) 330-8383 ( Sales: extn 116 ) CompuServe #: 73670,2561 From: Full Name: ____________________________________ Company Name (if any): ____________________________________ Street Address: ____________________________________ City, State, Zip: ____________________________________ Country: ____________________________________ VOICE Phone: ____________________________________ FAX Phone: ____________________________________ CompuServe #: ____________________________________ Desired Registration & Disk: CALC ver 1.3 Registration only: $39.95 x Qty____ = $_____ CALC next version automatic UPGRADE: $29.95 x Qty____ = $_____ (adding this amount will guarantee your receiving the next version immediately when available) (INCLUDES DISK AND SHIPPING) OFFER ONLY VALID WITH CALC VER 1.x REGISTRATION CALC Disk (if necessary) (SPECIFY TYPE) $10 $_____ circle one: 3 1/2" 5 1/4" California residents, add sales tax $_____ (currently 7.0%) --------------------------- TOTAL Enclosed: $_____ When you register, we will send you your registration number to use in your program to inhibit the copyright notice. This will be a simple one sheet letter. If you require the disks sent to you, there is an additional $10 charge for postage, handling and material (listed above).