xcalc(1X) xcalc(1X)
NAME
xcalc - displays a scientific calculator
SYNOPSIS
xcalc [-stipple] [-rpn] [toolkit-option]...
DESCRIPTION
xcalc is a scientific calculator desk accessory that can
emulate a TI-30 or an HP-10C calculator.
Options
The xcalc client accepts all of the standard X Toolkit
command-line options, as described in X(1X), as well as
these options:
-rpn Causes xcalc to use reverse Polish notation (RPN).
In this mode, the calculator looks and behaves like
an HP-10C calculator. In the absence of -rpn, xcalc
emulates a TI-30 calculator.
-stipple
Causes xcalc to draw the background of the calcula-
tor by using a stipple of the foreground and back-
ground colors. On monochrome displays, -stipple im-
proves the appearance.
Using Xcalc
To operate the calculator, you usually click a calculator
key by positioning the pointer on the key and pressing and
releasing the mouse button. Many common calculator opera-
tions have keyboard accelerators (see ``Accelerators'' later
in the ``Description'' section). To quit when using TI-30
emulation, position the pointer on the AC key and press the
RIGHT ARROW key (the right button on a three-button mouse).
To quit when using HP-10C emulation, position the pointer on
the ON key and press the RIGHT ARROW key.
Calculator key usage in TI-30 mode
The number keys, the +/- key, and the +, -, *, /, and = keys
all perform their normal calculation functions. The opera-
tors obey the standard rules of precedence. Thus, entering
3+4*5= results in 23, not 35. Parentheses can be used to
override so that (1+2+3)*(4+5+6)= results in 6*15=90.
The entire number in the calculator display can be selected
in order to paste the result of a calculation into text.
The action procedures associated with each function are
given as follows. These are useful if you are interested in
defining a custom calculator. The action procedure for all
digit keys is digit(n), where n is the corresponding digit,
0 through 9.
November, 1990 1
xcalc(1X) xcalc(1X)
( Generates a left parenthesis. The corresponding ac-
tion procedure for TI-30 mode is leftParen().
) Generates a right parenthesis. The corresponding
action procedure for TI-30 mode is rightParen().
* Multiplies. The corresponding action procedure is
multiply().
+ Adds. The corresponding action procedure is add().
+/- Negates; changes sign. The corresponding action
procedure is negate().
- Subtracts. The corresponding action procedure is
subtract().
. Generates a decimal point. The corresponding action
procedure is decimal().
/ Divides. The corresponding action procedure is
divide().
= Performs calculation. The corresponding action pro-
cedure for TI-30 mode is equal().
1/x Replaces the number in the display with its recipro-
cal. The corresponding action procedure is
reciprocal().
AC Clears everything (the display, the state, and the
memory). Positioning the pointer on the AC key and
pressing the RIGHT ARROW key (the right button on a
three-button mouse) exits the program and ``turns
off'' the calculator. To clear the state, the
corresponding action procedure is off(); to quit,
the action procedure is quit().
CE/C Allows you to reenter a number if you make a mis-
take. Pressing once clears the number in the
display without clearing the state of the machine.
Pressing twice clears the state as well as the
number. The corresponding action procedure for the
TI-30 mode is clear().
cos Computes the cosine. If inverted, it computes the
arc cosine. The corresponding action procedure is
cosine().
DRG Changes the DRG mode, as indicated by DEG, RAD, or
GRAD at the bottom of the display. When in DEG
mode, numbers in the display are taken as being de-
2 November, 1990
xcalc(1X) xcalc(1X)
grees. In RAD mode, numbers are in radians, and in
GRAD mode, numbers are in gradians. When inverted,
the DRG key converts degrees to radians to gradians
and vice versa. For example, typing 45 INV DRG with
the calculator in DEG mode results in .785398, which
is 45 degrees converted to radians. The correspond-
ing action procedure is degree().
e Generates the constant e (2.7182818...). The
corresponding action procedure is e().
EE Used for entering exponential numbers. For example,
to enter -2.3E-4, type 2 . 3 +/- EE 4 +/-. The
corresponding action procedure is scientific().
EXC Swaps the number in the display with the number in
the memory location. The corresponding action pro-
cedure for TI-30 mode is exchange().
INV Inverts the meaning of the function keys. See the
individual function keys for details. The
corresponding action procedure is inverse().
ln Calculates the log (base e) of the number in the
display. When inverted, it raises e to the number
in the display. For example, typing e ln results in
1. The corresponding action procedure is natural-
Log().
log Calculates the log (base 10) of the number in the
display. When inverted, it raises 10.0 to the
number in the display. For example, typing 3 INV
log results in 1000. The corresponding action pro-
cedure is
logarithm().
PI Generates the constant pi (3.1415927...). The
corresponding action procedure is pi().
RCL Copies the number from the memory location to the
display. The corresponding action procedure is
recall().
sin Computes the sine of the number in the display, as
interpreted by the current DRG mode. See DRG in this
section). If inverted, it computes the arc sine.
The corresponding action procedure is sine().
SQRT Computes the square root of the number in the
display. The corresponding action procedure is
squareRoot().
November, 1990 3
xcalc(1X) xcalc(1X)
STO Copies the number in the display to the memory loca-
tion. The corresponding action procedure is store().
SUM Adds the number in the display to the number in the
memory location. The corresponding action procedure
is sum().
tan Computes the tangent. If inverted, it computes the
arc tangent. The corresponding action procedure is
tangent().
x! Computes the factorial of the number in the display.
The number in the display must be an integer in the
range 0-500. However, depending on your math li-
brary, the result might overflow long before that.
The corresponding action procedure is factorial().
x^2 Squares the number in the display. The corresponding
action procedure is square().
y^x Raises the number on the left to the power of the
number on the right. For example, 2 y^x 3 = results
in 8, which is 2^3. For a further example, (1+2+3)
y^x (1+2) = equals 6 y^x 3, which equals 216. The
corresponding action procedure is power().
Calculator key usage in HP10-C mode (RPN mode)
The number keys, the CHS (change sign) key, and the +, -, *,
/, and ENTR keys do exactly what you would expect them to
do. Most of the remaining HP10-C keys that are also found on
the TI-30 perform the same functions as described in ``Cal-
culator Key Usage in TI-30 Mode.''
blank These keys were used for programming functions on
the HP-10C. Their functionality has not been dupli-
cated in xcalc.
10^x Raises 10.0 to the number in the top of the stack.
When inverted, it calculates the log (base 10) of
the number in the display. The corresponding action
procedure is tenpower().
<- Erases digits from the display to correct a mistake
made while entering a number. See ``Limitations''
later in this manual page. When inverted, <- clears
the X register. The corresponding action procedure
is back().
e^x Raises e to the number in the top of the stack. When
inverted, it calculates the log (base e) of the
number in the display. The action procedure is
epower().
4 November, 1990
xcalc(1X) xcalc(1X)
ENTR Performs calculation. The action procedure for the
ENTR key is enter().
INV Inverts the meaning of the function keys. This
would be the f key on an actual HP10-C calculator,
but xcalc does not display multiple legends on each
key. See the individual function keys for details.
ON Clears the display, the state, and the memory. Po-
sitioning the pointer on the ON key and pressing the
RIGHT ARROW key (the right button on a three-button
mouse) exits the program and ``turns off'' the cal-
culator. To clear the state, the corresponding ac-
tion procedure is off; to quit, the action procedure
is quit().
R v Rolls the stack downward. When inverted, it rolls
the stack upward. The corresponding action pro-
cedure is roll().
RCL Pushes the number from the specified memory location
onto the stack.
STO Copies the number in the top of the stack to a
memory location. There are 10 memory locations.
The desired memory is specified by following this
key with a digit key.
SUM Adds the number on top of the stack to the number in
the specified memory location.
x:y Exchanges the numbers in the top two stack posi-
tions, the X and Y registers. The corresponding ac-
tion procedure is XexchangeY().
Finally, there are two additional action procedures: bell()
rings the bell, and selection() performs a cut on the entire
number in the calculator's ``liquid crystal'' display.
Accelerators
Keyboard accelerators are keyboard equivalents for entering
commands. The xcalc client application provides some sample
keyboard accelerators; you can customize accelerators. The
numeric keypad accelerators provided by xcalc should be in-
tuitively correct. The accelerators defined by xcalc on the
main keyboard are given below:
TI key HP key Accelerator TI function HP function
SQRT SQRT r squareRoot() squareRoot()
AC ON SPACE BAR clear() clear()
AC <- DELETE clear() back()
AC <- BACKSPACE clear() back()
November, 1990 5
xcalc(1X) xcalc(1X)
AC <- CONTROL-H clear() back()
AC CLEAR clear()
AC ON q quit() quit()
AC ON CONTROL-C quit() quit()
INV i i inverse() inverse()
sin s s sine() sine()
cos c c cosine() cosine()
tan t t tangent() tangent()
DRG DRG d degree() degree()
e e e()
ln ln l naturalLog() naturalLog()
y^x y^x ^ power() power()
PI PI p pi() pi()
x! x! ! factorial() factorial()
( ( leftParen()
) ) rightParen()
/ / / divide() divide()
* * * multiply() multiply()
- - - subtract() subtract()
+ + + add() add()
= = equal()
0..9 0..9 0..9 digit() digit()
. . . decimal() decimal()
+/- CHS n negate() negate()
6 November, 1990
xcalc(1X) xcalc(1X)
TI key HP key Accelerator TI function HP function
x:y x XexchangeY()
ENTR RETURN enter()
ENTR LINEFEED enter()
Customizing xcalc
The application class name is XCalc.
The xcalc client application has an enormous defaults file
that specifies the position, label, and function of each key
on the calculator. The defaults file also specifies trans-
lations for keyboard accelerators. Because these resources
are not specified in the source code, you can create a cus-
tomized calculator by writing a private application defaults
file, using the Athena Command and Form widget resources to
specify the size and position of keys (buttons), the label
for each key, and the function of each button. Your defaults
file should be named Xcalc and should be located in the
directory specified by your $XAPPLRESDIR environment vari-
able.
You can specify the foreground and background colors of each
calculator key. For the TI-30 calculator, a typical color
resource specification is:
XCalc.ti.Command.background: gray50
XCalc.ti.Command.foreground: white
For each of keys whose corresponding buttons are 20, 25, 30,
35, and 40, specify
XCalc.ti.buttonXX.background: black
XCalc.ti.buttonXX.foreground: white
where XX is the button number.
For each of the keys whose corresponding buttons are 22, 23,
24, 27, 28, 29, 32, 33, 34, 37, 38, and 39, specify
XCalc.ti.buttonXX.background: white
XCalc.ti.buttonXX.foreground: black
where XX is the button number.
Resources
rpn (class Rpn)
Specifies that RPN mode should be used. The default
is TI-30 mode.
stipple (class Stipple)
Indicates that the background should be stippled.
The default is on for monochrome displays and off
November, 1990 7
xcalc(1X) xcalc(1X)
for color displays.
cursor (class Cursor)
Specifies the name of the symbol used to represent
the pointer. The default is hand2.
Widget hierarchy
To specify resources, you should know the hierarchy of the
widgets that compose xcalc. In the following notation, in-
dentation indicates hierarchical structure. The widget
class name is given first, followed by the widget instance
name.
XCalc xcalc
Form ti or hp (the name depends on the mode)
Form bevel
Form screen
Label M
Toggle LCD
Label INV
Label DEG
Label RAD
Label GRAD
Label P
Command button1
Command button2
Command button3
.
.
.
Command button38
Command button39
Command button40
LIMITATIONS
The sequence of keys
5 ENTR <-
should clear the display in HP-10C mode, but it doesn't.
NOTES
Copyright 1988, Massachusetts Institute of Technology.
See X(1X) for a full statement of rights and permissions.
Authors: John Bradley, University of Pennsylvania; Mark
Rosenstein, MIT Project Athena; and Donna Converse, MIT X
Consortium
SEE ALSO
X(1X), xrdb(1X)
8 November, 1990
Athena Widget Set - C Language Interface
November, 1990 9