home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Vectronix 2
/
VECTRONIX2.iso
/
FILES_01
/
HSPASCAL.LZH
/
HSPASCAL
/
MYCALC
/
MYCALC.DOC
< prev
next >
Wrap
Text File
|
1992-05-01
|
6KB
|
159 lines
MyCalc - a HighSpeed accessory example
1. Introduction
---------------
This document contains the information required in order to operate the
MyCalc accessory, but does not give any information concerning its
programming - consult the source code files MYCALC.PAS and RPN.PAS.
2. What is MyCalc?
------------------
MyCalc is an accessory/application (can run as both; .ACC = accessory
operation, .PRG = application operation) operating as a Reverse Polish
Notation (RPN) calculator.
3. Files
--------
The MyCalc program set contains the following files :
MYCALC.PAS - main program
RPN.PAS - the RPN evaluator unit
MYCALC.I - resource file constants from RCS 2.1
MYCALC.DFN - resource file definitions for RCS 2.1
MYCALC.RSC - resource file from RCS 2.1
4. Installing MyCalc
--------------------
MyCalc will always look for its resource file in the current directory,
which means that if MyCalc is installed as an accessory (named
MYCALC.ACC), it will look for the RSC file in the root directory of the
boot disk. If the RSC file can't be found, the user is informed, and
MyCalc will install itself and wait for activation. Upon activation,
MyCalc will again try to locate the RSC file in the current folder, and if
it fails to do so, then deny further operation. If, however, the file
could be found, then it's loaded and stays resident together with MyCalc.
If MyCalc is run as an application (named MYCALC.PRG), then the RSC file
must be contained within the current directory; otherwise the program will
abort.
5. Executing MyCalc
-------------------
When MyCalc is installed as accessory, you activate it from the "Desk"
menu. If MyCalc can't open a window, you will be told so, asked to close
one and then reactivate MyCalc. This condition should never occur when run
as application.
6. Using MyCalc
---------------
MyCalc can be used with the mouse and the keyboard. Its functions are all
implemented with use of the numeric keypad in mind - this implies that the
[ ( ] and [ ) ] keys don't behave as expected (see below).
The MyCalc window can be moved and topped as any other GEM window, but of
course not sized.
6.1. Mouse usage
----------------
When the mouse is moved to one of the buttons, it will highlight, and
reverse when the mouse is moved away again. You select a number/operation
by highlighting a button and then pressing the left mouse button.
When through using MyCalc, you click the "Close" box on the upper left of
the window.
6.2. Keyboard usage
-------------------
The following keys have an operation with MyCalc :
0..9 : digits
. : radix point
+ : add
- : subtract
* : multiply
/ : divide
( : sign inversion
) : swap top elements (see below)
Enter : push number onto stack
Backspace : delete last digit/clear top of stack
Esc : close MyCalc window
Both keypads (alphanumeric and numeric) can be used.
7. How to calculate
-------------------
As mentioned above, MyCalc utilizes Reverse Polish Notation. This involves
a new way of thinking when evaluation expressions, as the following
examples show :
normal RPN
------------------
1+2 1 ENTER 2 +
(1+2)*3 1 ENTER 2 + 3 *
(1+2)*(3+4) 1 ENTER 2 + 3 ENTER 4 + *
8. MyCalc's implementation of RPN
---------------------------------
MyCalc implements a Hewlett-Packard like system of RPN, that is, with a
four element stack made up of the registers x, y, z and t. The philosophy
behind RPN is to enter the operands on the stack and the execute an
operation (e.g. addition). The stack layout can be visualized like this :
t - bottom of stack
z
y
x - top of stack, the element shown in the display
Most people would probably say, the layout is upside down, but that's the
way Hewlett Packard shows it...
Now, when an expression like 1+2 is evaluated, the following happens :
First, the value 1 is pushed onto the stack (into x). Then 2 is pushed
into x, thereby forcing the old value into y. The addition then pops both
values off the stack, adds them and pushes the result back onto the stack.
The below table should clarify this :
reg. operation
---------------------------------
1 ENTER 2 +
---------------------------------
x 1 1 2 3
y 1 1
z
t
As you can see, the ENTER operation pushes the value 1 into y, but at the
same time enables x to be overwritten by the value 2. This is termed
"disabling stack-lift". Backspace does the same, when a value is cleared
(made 0.00000), i.e. allows the x-register value to be overwritten.
Let's look at (1+2) * (4-5) :
reg. operation
---------------------------------------------------------------
1 ENTER 2 + 4 ENTER 5 - *
---------------------------------------------------------------
x 1 1 2 3 4 4 5 -1 -3
y 1 1 3 4 4 3
z 3 3
t
Finally, one special property of the t register should be mentioned : Its
value can only be changed by pushing numbers onto the stack, and not by
popping. Let's illustrate :
reg operation
---------------------------------------------------------------
1 ENT 2 ENT 3 ENT 4 + + + +
---------------------------------------------------------------
x 1 1 2 2 3 3 4 7 9 10 11
y 1 1 2 2 3 3 2 1 1 1
z 1 1 2 2 1 1 1 1
t 1 1 1 1 1 1
In the above illustrations, we haven't shown the register contents
unaffected by our operations. ENT is an abbreviation for ENTER.
Finally, we wish you best of luck with experimenting with the HighSpeed
Pascal MyCalc accessory.