1XCALC(1)                    General Commands Manual                   XCALC(1)
2
3
4

NAME

6       xcalc - scientific calculator for X
7

SYNOPSIS

9       xcalc [-stipple] [-rpn] [-toolkitoption...]
10       xcalc -version
11       xcalc -help
12

DESCRIPTION

14       xcalc  is  a scientific calculator desktop accessory that can emulate a
15       TI-30 or an HP-10C.
16

OPTIONS

18       xcalc accepts all of the standard toolkit command  line  options  along
19       with these additional options:
20
21       -stipple
22               This  option  indicates  that  the background of the calculator
23               should be drawn using a stipple of  the  foreground  and  back‐
24               ground colors.  On monochrome displays improves the appearance.
25
26       -rpn    This  option  indicates  that Reverse Polish Notation should be
27               used.  In this mode the calculator will look and behave like an
28               HP-10C.  Without this flag, it will emulate a TI-30.
29
30       -help   This option indicates that xcalc should print its usage message
31               and exit.
32
33       -version
34               This option indicates that xcalc should print its  version  and
35               exit.
36

OPERATION

38       Pointer Usage: Operations may be performed with pointer button 1, or in
39       some cases, with the keyboard.  Many common calculator operations  have
40       keyboard  accelerators.   To quit, press pointer button 3 on the AC key
41       of the TI calculator, or the ON key of the HP calculator.
42
43       Calculator Key Usage (TI mode): The numbered keys, the +/- key, and the
44       +,  -,  *,  /, and = keys all do exactly what you would expect them to.
45       It should be noted that the operators obey the standard rules of prece‐
46       dence.   Thus, entering "3+4*5=" results in "23", not "35".  The paren‐
47       theses can be used to override this.  For  example,  "(1+2+3)*(4+5+6)="
48       results in "6*15=90".
49
50       The  entire  number in the calculator display can be selected, in order
51       to paste the result of a calculation into text.
52
53       The action procedures associated with each function  are  given  below.
54       These are useful if you are interested in defining a custom calculator.
55       The action used for all digit keys is digit(n), where n is  the  corre‐
56       sponding digit, 0..9.
57
58       1/x       Replaces  the number in the display with its reciprocal.  The
59                 corresponding action procedure is reciprocal().
60
61       x^2       Squares the number in the display.  The corresponding  action
62                 procedure is square().
63
64       SQRT      Takes the square root of the number in the display.  The cor‐
65                 responding action procedure is squareRoot().
66
67       CE/C      When pressed once, clears the number in the  display  without
68                 clearing  the state of the machine.  Allows you to re-enter a
69                 number if you make a mistake.  Pressing it twice  clears  the
70                 state,  also.  The corresponding action procedure for TI mode
71                 is clear().
72
73       AC        Clears the display, the state, and the memory.   Pressing  it
74                 with  the  third  pointer button turns off the calculator, in
75                 that it exits the program.  The action procedure to clear the
76                 state is off(); to quit, quit().
77
78       INV       Invert  function.   See  the individual function keys for de‐
79                 tails.  The corresponding action procedure is inverse().
80
81       sin       Computes the sine of the number in  the  display,  as  inter‐
82                 preted  by  the  current  DRG  mode (see DRG, below).  If in‐
83                 verted, it computes the arcsine.   The  corresponding  action
84                 procedure is sine().
85
86       cos       Computes  the cosine, or arccosine when inverted.  The corre‐
87                 sponding action procedure is cosine().
88
89       tan       Computes the tangent, or arctangent when inverted.  The  cor‐
90                 responding action procedure is tangent().
91
92       DRG       Changes the DRG mode, as indicated by 'DEG', 'RAD', or 'GRAD'
93                 at the bottom of the calculator ``liquid  crystal''  display.
94                 When in 'DEG' mode, numbers in the display are taken as being
95                 degrees.  In 'RAD' mode,  numbers  are  in  radians,  and  in
96                 'GRAD'  mode,  numbers  are in grads.  When inverted, the DRG
97                 key has a feature of converting degrees to radians  to  grads
98                 and  vice-versa.   Example:   put  the  calculator into 'DEG'
99                 mode, and enter "45 INV DRG".  The display  should  now  show
100                 something  along  the lines of ".785398", which is 45 degrees
101                 converted to radians.  The corresponding action procedure  is
102                 degree().
103
104       e         The  constant 'e'.  (2.7182818...).  The corresponding action
105                 procedure is e().
106
107       EE        Used for entering exponential numbers.  For example,  to  get
108                 "-2.3E-4"  you'd enter "2 . 3 +/- EE 4 +/-".  The correspond‐
109                 ing action procedure is scientific().
110
111       log       Calculates the log (base 10) of the number  in  the  display.
112                 When inverted, it raises "10.0" to the number in the display.
113                 For example, entering "3 INV log" should  result  in  "1000".
114                 The corresponding action procedure is logarithm().
115
116       ln        Calculates  the  log  (base  e) of the number in the display.
117                 When inverted, it raises "e" to the number  in  the  display.
118                 For  example, entering "e ln" should result in "1".  The cor‐
119                 responding action procedure is naturalLog().
120
121       y^x       Raises the number on the left to the power of the  number  on
122                 the  right.  For example "2 y^x 3 =" results in "8", which is
123                 2^3.  For a further example, "(1+2+3) y^x (1+2) =" equals  "6
124                 y^x  3"  which equals "216".  The corresponding action proce‐
125                 dure is power().
126
127       not       Performs a bitwise not.  The corresponding  action  procedure
128                 is not().
129
130       and       Performs  a  bitwise and.  The corresponding action procedure
131                 is and().
132
133       or        Performs a bitwise or.  The corresponding action procedure is
134                 or().
135
136       xor       Performs  a  bitwise  exclusive or.  The corresponding action
137                 procedure is xor().
138
139       trunc     Truncates the number in the display to an integer.  The  cor‐
140                 responding action procedure is trunc().
141
142       PI        The constant 'pi'.  (3.1415927....)  The corresponding action
143                 procedure is pi().
144
145       x!        Computes the factorial of the number  in  the  display.   The
146                 number  in the display must be an integer in the range 0-500,
147                 though, depending on your math  library,  it  might  overflow
148                 long before that.  The corresponding action procedure is fac‐
149                 torial().
150
151       (         Left parenthesis.  The corresponding action procedure for  TI
152                 calculators is leftParen().
153
154       )         Right parenthesis.  The corresponding action procedure for TI
155                 calculators is rightParen().
156
157       base      Changes the number base, as  indicated  by  'DEC',  'HEX,  or
158                 'OCT' at the bottom of the calculator display.  When in 'DEC'
159                 mode, numbers in the display are taken as being decimal (base
160                 10).   In  'HEX'  mode, numbers are in hexadecimal (base 16),
161                 and in 'OCT' mode, numbers are in octal (base 8).  The corre‐
162                 sponding action procedure is base().
163
164       shl       Performs  an arithmetic bitwise shift left,  For example, en‐
165                 tering "1 shl 2" should result in "4".  The corresponding ac‐
166                 tion procedure is shl().
167
168       shr       Performs an arithmetic bitwise shift right,  For example, en‐
169                 tering "8 shr 1" should result in "4".  The corresponding ac‐
170                 tion procedure is shr().
171
172       mod       Performs the modulo operation, which calculates the remainder
173                 when dividing the first number by the second.   For  example,
174                 entering  "14 mod 8" should result in "6".  The corresponding
175                 action procedure is mod().
176
177       /         Division.  The corresponding action procedure is divide().
178
179       *         Multiplication.  The corresponding action procedure is multi‐
180                 ply().
181
182       -         Subtraction.   The  corresponding  action  procedure  is sub‐
183                 tract().
184
185       +         Addition.  The corresponding action procedure is add().
186
187       =         Perform calculation.  The  TI-specific  action  procedure  is
188                 equal().
189
190       STO       Copies the number in the display to the memory location.  The
191                 corresponding action procedure is store().
192
193       RCL       Copies the number from the memory location  to  the  display.
194                 The corresponding action procedure is recall().
195
196       SUM       Adds  the  number  in the display to the number in the memory
197                 location.  The corresponding action procedure is sum().
198
199       EXC       Swaps the number in the display with the number in the memory
200                 location.  The corresponding action procedure for the TI cal‐
201                 culator is exchange().
202
203       +/-       Negate; change sign.  The corresponding action  procedure  is
204                 negate().
205
206       .         Decimal point.  The action procedure is decimal().
207
208
209       Calculator Key Usage (RPN mode): The number keys, CHS (change sign), +,
210       -, *, /, and ENTR keys all do exactly what you would expect them to do.
211       Many of the remaining keys are the same as in TI mode.  The differences
212       are detailed below.  The action procedure for the ENTR key is enter().
213
214
215       <-        This is a backspace key that can be used if you make  a  mis‐
216                 take  while entering a number.  It will erase digits from the
217                 display.  (See BUGS).  Inverse backspace  will  clear  the  X
218                 register.  The corresponding action procedure is back().
219
220       ON        Clears  the  display, the state, and the memory.  Pressing it
221                 with the third pointer button turns off  the  calculator,  in
222                 that it exits the program.  To clear state, the action proce‐
223                 dure is off; to quit, quit().
224
225       INV       Inverts the meaning of the function keys.  This would be  the
226                 f  key on an HP calculator, but xcalc does not display multi‐
227                 ple legends on each key.  See the  individual  function  keys
228                 for details.
229
230       10^x      Raises  "10.0"  to  the number in the top of the stack.  When
231                 inverted, it calculates the log (base 10) of  the  number  in
232                 the  display.   The  corresponding  action  procedure is ten‐
233                 power().
234
235       e^x       Raises "e" to the number in the top of the stack.   When  in‐
236                 verted,  it  calculates the log (base e) of the number in the
237                 display.  The action procedure is epower().
238
239       STO       Copies the number in the top of the stack to a  memory  loca‐
240                 tion.   There are 10 memory locations.  The desired memory is
241                 specified by following this key with a digit key.
242
243       RCL       Pushes the number from the specified memory location onto the
244                 stack.
245
246       SUM       Adds  the  number  on  top  of the stack to the number in the
247                 specified memory location.
248
249       x:y       Exchanges the numbers in the top two stack positions,  the  X
250                 and  Y registers.  The corresponding action procedure is Xex‐
251                 changeY().
252
253       R v       Rolls the stack downward.  When inverted, it rolls the  stack
254                 upward.  The corresponding action procedure is roll().
255
256       blank     These keys were used for programming functions on the HP-10C.
257                 Their functionality has not been duplicated in xcalc.
258
259       Finally, there are two  additional  action  procedures:  bell(),  which
260       rings  the  bell;  and  selection(), which performs a cut on the entire
261       number in the calculator's ``liquid crystal'' display.
262

ACCELERATORS

264       Accelerators are shortcuts for entering commands.  xcalc provides  some
265       sample  keyboard  accelerators;  also users can customize accelerators.
266       The numeric keypad accelerators provided by xcalc should be intuitively
267       correct.   The  accelerators  defined by xcalc on the main keyboard are
268       given below:
269
270       TI Key   HP Key   Keyboard Accelerator   TI Function    HP Function
271       ─────────────────────────────────────────────────────────────────────
272       SQRT     SQRT     r                      squareRoot()   squareRoot()
273       AC       ON       space                  clear()        clear()
274       AC       <-       Delete                 clear()        back()
275       AC       <-       Backspace              clear()        back()
276       AC       <-       Control-H              clear()        back()
277       AC                Clear                  clear()
278       AC       ON       q                      quit()         quit()
279       AC       ON       Control-C              quit()         quit()
280
281       INV      i        i                      inverse()      inverse()
282       sin      s        s                      sine()         sine()
283       cos      c        c                      cosine()       cosine()
284       tan      t        t                      tangent()      tangent()
285       DRG      DRG      d                      degree()       degree()
286
287       e                 e                      e()
288       ln       ln       l                      naturalLog()   naturalLog()
289       y^x      y^x      ^                      power()        power()
290
291       PI       PI       p                      pi()           pi()
292       x!       x!       !                      factorial()    factorial()
293       (                 (                      leftParen()
294       )                 )                      rightParen()
295
296       /        /        /                      divide()       divide()
297       *        *        *                      multiply()     multiply()
298       -        -        -                      subtract()     subtract()
299       +        +        +                      add()          add()
300       =                 =                      equal()
301
302       0..9     0..9     0..9                   digit()        digit()
303       +/-      CHS      n                      negate()       negate()
304
305                x:y      x                                     XexchangeY()
306                ENTR     Return                                enter()
307                ENTR     Linefeed                              enter()
308

CUSTOMIZATION

310       The application class name is XCalc.
311
312       xcalc has an enormous application defaults file which specifies the po‐
313       sition,  label,  and  function  of each key on the calculator.  It also
314       gives translations to serve as keyboard  accelerators.   Because  these
315       resources  are  not specified in the source code, you can create a cus‐
316       tomized calculator by writing a private application defaults file,  us‐
317       ing  the  Athena  Command and Form widget resources to specify the size
318       and position of buttons, the label for each button, and the function of
319       each button.
320
321       The  foreground and background colors of each calculator key can be in‐
322       dividually specified.  For the TI calculator,  a  classical  color  re‐
323       source specification might be:
324
325       XCalc.ti.Command.background:          gray50
326       XCalc.ti.Command.foreground:          white
327
328       For each of buttons 20, 25, 30, 35, and 40, specify:
329       XCalc.ti.button20.background:         black
330       XCalc.ti.button20.foreground:         white
331
332       For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39:
333       XCalc.ti.button22.background:         white
334       XCalc.ti.button22.foreground:         black
335

WIDGET HIERARCHY

337       In  order  to  specify resources, it is useful to know the hierarchy of
338       the widgets which compose xcalc.  In the  notation  below,  indentation
339       indicates  hierarchical  structure.   The  widget  class  name is given
340       first, followed by the widget instance name.
341       XCalc xcalc
342               Form  ti  or  hp    (the name depends on the mode)
343                       Form  bevel
344                               Form  screen
345                                       Label  M
346                                       Toggle  LCD
347                                       Label  INV
348                                       Label  DEG
349                                       Label  RAD
350                                       Label  GRAD
351                                       Label  P
352                       Command  button1
353                       Command  button2
354                       Command  button3
355       and so on, ...
356                       Command  button38
357                       Command  button39
358                       Command  button40
359

APPLICATION RESOURCES

361       rpn (Class Rpn)
362               Specifies that the rpn mode should be used.  The default is  TI
363               mode.
364
365       stipple (Class Stipple)
366               Indicates  that the background should be stippled.  The default
367               is ``on'' for monochrome displays, and ``off'' for  color  dis‐
368               plays.
369
370       cursor (Class Cursor)
371               The  name of the symbol used to represent the pointer.  The de‐
372               fault is ``hand2''.
373

COLORS

375       If you would like xcalc to use its ti colors, include the following  in
376       the #ifdef COLOR section of the file you read with xrdb:
377
378       *customization:                 -color
379
380       This  will  cause xcalc to pick up the colors in the app-defaults color
381       customization file: /usr/share/X11/app-defaults/XCalc-color.
382

SEE ALSO

384       X(7), xrdb(1), the Athena Widget Set
385

BUGS

387       HP mode is not completely debugged.  In particular, the  stack  is  not
388       handled properly after errors.
389

AUTHORS

391       John Bradley, University of Pennsylvania
392       Mark Rosenstein, MIT Project Athena
393       Donna Converse, MIT X Consortium
394
395
396
397X Version 11                      xcalc 1.1.2                         XCALC(1)
Impressum