1XCALC(1) General Commands Manual XCALC(1)
2
3
4
6 xcalc - scientific calculator for X
7
9 xcalc [-stipple] [-rpn] [-toolkitoption...]
10
12 xcalc is a scientific calculator desktop accessory that can emulate a
13 TI-30 or an HP-10C.
14
16 xcalc accepts all of the standard toolkit command line options along
17 with two additional options:
18
19 -stipple
20 This option indicates that the background of the calculator
21 should be drawn using a stipple of the foreground and back‐
22 ground colors. On monochrome displays improves the appearance.
23
24 -rpn This option indicates that Reverse Polish Notation should be
25 used. In this mode the calculator will look and behave like an
26 HP-10C. Without this flag, it will emulate a TI-30.
27
29 Pointer Usage: Operations may be performed with pointer button 1, or in
30 some cases, with the keyboard. Many common calculator operations have
31 keyboard accelerators. To quit, press pointer button 3 on the AC key
32 of the TI calculator, or the ON key of the HP calculator.
33
34 Calculator Key Usage (TI mode): The numbered keys, the +/- key, and the
35 +, -, *, /, and = keys all do exactly what you would expect them to.
36 It should be noted that the operators obey the standard rules of prece‐
37 dence. Thus, entering "3+4*5=" results in "23", not "35". The paren‐
38 theses can be used to override this. For example, "(1+2+3)*(4+5+6)="
39 results in "6*15=90".
40
41 The entire number in the calculator display can be selected, in order
42 to paste the result of a calculation into text.
43
44 The action procedures associated with each function are given below.
45 These are useful if you are interested in defining a custom calculator.
46 The action used for all digit keys is digit(n), where n is the corre‐
47 sponding digit, 0..9.
48
49 1/x Replaces the number in the display with its reciprocal. The
50 corresponding action procedure is reciprocal().
51
52 x^2 Squares the number in the display. The corresponding action
53 procedure is square().
54
55 SQRT Takes the square root of the number in the display. The cor‐
56 responding action procedure is squareRoot().
57
58 CE/C When pressed once, clears the number in the display without
59 clearing the state of the machine. Allows you to re-enter a
60 number if you make a mistake. Pressing it twice clears the
61 state, also. The corresponding action procedure for TI mode
62 is clear().
63
64 AC Clears the display, the state, and the memory. Pressing it
65 with the third pointer button turns off the calculator, in
66 that it exits the program. The action procedure to clear the
67 state is off(); to quit, quit().
68
69 INV Invert function. See the individual function keys for
70 details. The corresponding action procedure is inverse().
71
72 sin Computes the sine of the number in the display, as inter‐
73 preted by the current DRG mode (see DRG, below). If
74 inverted, it computes the arcsine. The corresponding action
75 procedure is sine().
76
77 cos Computes the cosine, or arccosine when inverted. The corre‐
78 sponding action procedure is cosine().
79
80 tan Computes the tangent, or arctangent when inverted. The cor‐
81 responding action procedure is tangent().
82
83 DRG Changes the DRG mode, as indicated by 'DEG', 'RAD', or 'GRAD'
84 at the bottom of of the calculator ``liquid crystal'' dis‐
85 play. When in 'DEG' mode, numbers in the display are taken
86 as being degrees. In 'RAD' mode, numbers are in radians, and
87 in 'GRAD' mode, numbers are in grads. When inverted, the DRG
88 key has a feature of converting degrees to radians to grads
89 and vice-versa. Example: put the calculator into 'DEG'
90 mode, and enter "45 INV DRG". The display should now show
91 something along the lines of ".785398", which is 45 degrees
92 converted to radians. The corresponding action procedure is
93 degree().
94
95 e The constant 'e'. (2.7182818...). The corresponding action
96 procedure is e().
97
98 EE Used for entering exponential numbers. For example, to get
99 "-2.3E-4" you'd enter "2 . 3 +/- EE 4 +/-". The correspond‐
100 ing action procedure is scientific().
101
102 log Calculates the log (base 10) of the number in the display.
103 When inverted, it raises "10.0" to the number in the display.
104 For example, entering "3 INV log" should result in "1000".
105 The corresponding action procedure is logarithm().
106
107 ln Calculates the log (base e) of the number in the display.
108 When inverted, it raises "e" to the number in the display.
109 For example, entering "e ln" should result in "1". The cor‐
110 responding action procedure is naturalLog().
111
112 y^x Raises the number on the left to the power of the number on
113 the right. For example "2 y^x 3 =" results in "8", which is
114 2^3. For a further example, "(1+2+3) y^x (1+2) =" equals "6
115 y^x 3" which equals "216". The corresponding action proce‐
116 dure is power().
117
118 PI The constant 'pi'. (3.1415927....) The corresponding action
119 procedure is pi().
120
121 x! Computes the factorial of the number in the display. The
122 number in the display must be an integer in the range 0-500,
123 though, depending on your math library, it might overflow
124 long before that. The corresponding action procedure is fac‐
125 torial().
126
127 ( Left parenthesis. The corresponding action procedure for TI
128 calculators is leftParen().
129
130 ) Right parenthesis. The corresponding action procedure for TI
131 calculators is rightParen().
132
133 / Division. The corresponding action procedure is divide().
134
135 * Multiplication. The corresponding action procedure is multi‐
136 ply().
137
138 - Subtraction. The corresponding action procedure is sub‐
139 tract().
140
141 + Addition. The corresponding action procedure is add().
142
143 = Perform calculation. The TI-specific action procedure is
144 equal().
145
146 STO Copies the number in the display to the memory location. The
147 corresponding action procedure is store().
148
149 RCL Copies the number from the memory location to the display.
150 The corresponding action procedure is recall().
151
152 SUM Adds the number in the display to the number in the memory
153 location. The corresponding action procedure is sum().
154
155 EXC Swaps the number in the display with the number in the memory
156 location. The corresponding action procedure for the TI cal‐
157 culator is exchange().
158
159 +/- Negate; change sign. The corresponding action procedure is
160 negate().
161
162 . Decimal point. The action procedure is decimal().
163
164
165 Calculator Key Usage (RPN mode): The number keys, CHS (change sign), +,
166 -, *, /, and ENTR keys all do exactly what you would expect them to do.
167 Many of the remaining keys are the same as in TI mode. The differences
168 are detailed below. The action procedure for the ENTR key is enter().
169
170
171 <- This is a backspace key that can be used if you make a mis‐
172 take while entering a number. It will erase digits from the
173 display. (See BUGS). Inverse backspace will clear the X
174 register. The corresponding action procedure is back().
175
176 ON Clears the display, the state, and the memory. Pressing it
177 with the third pointer button turns off the calculator, in
178 that it exits the program. To clear state, the action proce‐
179 dure is off; to quit, quit().
180
181 INV Inverts the meaning of the function keys. This would be the
182 f key on an HP calculator, but xcalc does not display multi‐
183 ple legends on each key. See the individual function keys
184 for details.
185
186 10^x Raises "10.0" to the number in the top of the stack. When
187 inverted, it calculates the log (base 10) of the number in
188 the display. The corresponding action procedure is ten‐
189 power().
190
191 e^x Raises "e" to the number in the top of the stack. When
192 inverted, it calculates the log (base e) of the number in the
193 display. The action procedure is epower().
194
195 STO Copies the number in the top of the stack to a memory loca‐
196 tion. There are 10 memory locations. The desired memory is
197 specified by following this key with a digit key.
198
199 RCL Pushes the number from the specified memory location onto the
200 stack.
201
202 SUM Adds the number on top of the stack to the number in the
203 specified memory location.
204
205 x:y Exchanges the numbers in the top two stack positions, the X
206 and Y registers. The corresponding action procedure is Xex‐
207 changeY().
208
209 R v Rolls the stack downward. When inverted, it rolls the stack
210 upward. The corresponding action procedure is roll().
211
212 blank These keys were used for programming functions on the HP-10C.
213 Their functionality has not been duplicated in xcalc.
214
215 Finally, there are two additional action procedures: bell(), which
216 rings the bell; and selection(), which performs a cut on the entire
217 number in the calculator's ``liquid crystal'' display.
218
220 Accelerators are shortcuts for entering commands. xcalc provides some
221 sample keyboard accelerators; also users can customize accelerators.
222 The numeric keypad accelerators provided by xcalc should be intuitively
223 correct. The accelerators defined by xcalc on the main keyboard are
224 given below:
225
226 TI Key HP Key Keyboard Accelerator TI Function HP Function
227 ─────────────────────────────────────────────────────────────────────
228 SQRT SQRT r squareRoot() squareRoot()
229 AC ON space clear() clear()
230 AC <- Delete clear() back()
231 AC <- Backspace clear() back()
232 AC <- Control-H clear() back()
233 AC Clear clear()
234 AC ON q quit() quit()
235 AC ON Control-C quit() quit()
236
237 INV i i inverse() inverse()
238 sin s s sine() sine()
239 cos c c cosine() cosine()
240 tan t t tangent() tangent()
241 DRG DRG d degree() degree()
242
243 e e e()
244 ln ln l naturalLog() naturalLog()
245 y^x y^x ^ power() power()
246
247 PI PI p pi() pi()
248 x! x! ! factorial() factorial()
249 ( ( leftParen()
250 ) ) rightParen()
251
252 / / / divide() divide()
253 * * * multiply() multiply()
254 - - - subtract() subtract()
255 + + + add() add()
256 = = equal()
257
258 0..9 0..9 0..9 digit() digit()
259 +/- CHS n negate() negate()
260
261 x:y x XexchangeY()
262 ENTR Return enter()
263 ENTR Linefeed enter()
264
266 The application class name is XCalc.
267
268 xcalc has an enormous application defaults file which specifies the
269 position, label, and function of each key on the calculator. It also
270 gives translations to serve as keyboard accelerators. Because these
271 resources are not specified in the source code, you can create a cus‐
272 tomized calculator by writing a private application defaults file,
273 using the Athena Command and Form widget resources to specify the size
274 and position of buttons, the label for each button, and the function of
275 each button.
276
277 The foreground and background colors of each calculator key can be
278 individually specified. For the TI calculator, a classical color
279 resource specification might be:
280
281 XCalc.ti.Command.background: gray50
282 XCalc.ti.Command.foreground: white
283
284 For each of buttons 20, 25, 30, 35, and 40, specify:
285 XCalc.ti.button20.background: black
286 XCalc.ti.button20.foreground: white
287
288 For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39:
289 XCalc.ti.button22.background: white
290 XCalc.ti.button22.foreground: black
291
293 In order to specify resources, it is useful to know the hierarchy of
294 the widgets which compose xcalc. In the notation below, indentation
295 indicates hierarchical structure. The widget class name is given
296 first, followed by the widget instance name.
297 XCalc xcalc
298 Form ti or hp (the name depends on the mode)
299 Form bevel
300 Form screen
301 Label M
302 Toggle LCD
303 Label INV
304 Label DEG
305 Label RAD
306 Label GRAD
307 Label P
308 Command button1
309 Command button2
310 Command button3
311 and so on, ...
312 Command button38
313 Command button39
314 Command button40
315
317 rpn (Class Rpn)
318 Specifies that the rpn mode should be used. The default is TI
319 mode.
320
321 stipple (Class Stipple)
322 Indicates that the background should be stippled. The default
323 is ``on'' for monochrome displays, and ``off'' for color dis‐
324 plays.
325
326 cursor (Class Cursor)
327 The name of the symbol used to represent the pointer. The
328 default is ``hand2''.
329
331 If you would like xcalc to use its ti colors, include the following in
332 the #ifdef COLOR section of the file you read with xrdb:
333
334 *customization: -color
335
336 This will cause xcalc to pick up the colors in the app-defaults color
337 customization file: /usr/share/X11/app-defaults/XCalc-color.
338
340 X(7), xrdb(1), the Athena Widget Set
341
343 HP mode is not completely debugged. In particular, the stack is not
344 handled properly after errors.
345
347 Copyright 1994 X Consortium
348 See X(7) for a full statement of rights and permissions.
349
351 John Bradley, University of Pennsylvania
352 Mark Rosenstein, MIT Project Athena
353 Donna Converse, MIT X Consortium
354
355
356
357X Version 11 xcalc 1.0.6 XCALC(1)