The user can operate the calculator like any other. To select the value resulting from the calculations, the user hits either the [OK] button on the calculator, or presses [F2]-Do_It!.
If the user selects a value from the calculator, then the Calculator.Dialog() returns true, otherwise it returns false. If Calculator.Dialog() returns true, then the selected value can be picked up from the property Calculator.Value.
The default bahavior will place a selected value in a numeric or dollar field or in a memo if the workspace is in "Edit" or "CoEdit" mode.
Alternatively, you can load procedures from the Popcalc.sc script at the beginning of your application like this:
Librarian.HasControl = True
Play "Popcalc"
Release Vars Librarian.HasControl
You can then call Calculator.Constructor() , Calculator.Dialog(), and Calculator.Constructor() according to the documentation below. Or you can just call Calculator.Show() to get the default behavior described in the first option.
As a third alternative, you can write all the procedures in Calculator.sc to a library, and handle them accordingly.
Reverse sign Function [Alt-R] "Rev" {Reverse sign}
Square root Function [Alt-Q] {Square root}
Round,2 Function [Alt-N] {Round,2}
SaveMem Function [>] {SaveMem}
GetMem Function [<] {GetMem}
Subtotal Postfix [Alt-S] "Sub" {Subtotal}
Total Terminator [=] or [Enter] "=" {Total}
Clear Terminator [Alt-L] "Clr" {Clear}
In addition it has a numeric keypad that contains the numerals 0 - 9 and the
decimal point.
Postfix operations operate on a number or numbers that have preceded the operator.
Infix operations apply to the numbers immediately preceding and following the operator. Infix operations are nested, ie. they are resolved before their postfix cousins are resolved.
Functions apply only to the number currently in the input cell.
As a simple example, to add 3 - 6 = -3, enter 3 + 6 - [Enter].
For a more complex example, to calculate a bill with tax for five items: 1 coke at $1.00, three burgers at $2.00 each, and one out of a case of three apple crisps, when the case is worth $6.00, with tax altogether of 7%: enter the following keystrokes:
1 + 2 * 3 + 6 / 3 [Alt-S] * 7 % [Enter]
When [Enter], [=], or [Alt-S] are entered without a preceding + or - operator, the + operator is assumed.
So, the above keystroke sequence is equivalent to:
The calculator will use the previously calculated figure of the input cell if an operator is hit without entering a new number in the input cell. The input cell shows the running total of the calculation. This running total is automatically replaced by a number that you input in the input cell.
Thus 3 + + + [Enter] will give 9.00, while showing 3,6,9 after each plus, and 9 after the [Enter].
The paper tape is available for viewing and editing from the Menu, and this help text is available for viewing from the Menu.
Usage: Issue Calculator.Constructor() at the beginning of the session with Calculator, or at the beginning of your application. If Calculator.Constructor() is called once at the beginning of your application, then each time the user views the Calculator, he or she will see the value that was selected the last time the Calculator was used.
------
Calculator.Destructor()
Syntax: Calculator.Destructor()
Returns: Nothing.
Description: Destroys Calculator in memory.
Usage: Call Calculator.Destructor() at the end of the Calculator session if Calculator.Constructor() was called at the beginning of the Calculator session, or call Calculator.Destructor() at the end of your application if Calculator.Constuctor() was called at the beginning of your application.
------
Calculator.Dialog()
Syntax: Calculator.Dialog()
Returns: True if the user selected a value, otherwise returns false. If it returns true, then as a side effect Calculator.Value is set to the value the user selected.
Description: Displays the Calculator and waits for user input.
Usage: Issue Calculator.Dialog() when you want to display the Calculator to the user, after issuing Calculator.Constructor() and before issuing Calculator.Destructor().
Example:
Calculator.Constructor() ; create the Calculator
If Calculator.Dialog() Then ; user has selected a value
[] = Calculator.Value ; place value in numeric field
Endif
Calculator.Destructor() ; destroy the Calculator
Properties:
-----------
Calculator.Value
Data type: Numeric
Description: The value in the input cell at the time of exit from the Calculator.
------
Calculator.ExplainFile
Data type: Alpha, default "Popcalc.hlp"
Description: If you run Calculator from a directory other than the directory containing the help file (Popcalc.hlp) then change Calculator.ExplainFile to "<path>\\popcalc.hlp" right after issuing Calculator.Construcor().
------
Calculator.IsActive
Data type: Logical
Description: (readonly) indicates if Calculator.Constructor() has been run. Use IsAssigned(Calculator.IsActive) to test existence of the Calculator.