home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / sc5.1 / part01 next >
Encoding:
Internet Message Format  |  1988-01-30  |  26.6 KB

  1. Subject:  v13i016:  SC spreadsheet program, version 5.1, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: nscpdc.nsc.com!rgb
  7. Posting-number: Volume 13, Issue 16
  8. Archive-name: sc5.1/part01
  9.  
  10. This is version 5.1 of the public domain spread sheet SC.  The code has
  11. been tested on BSD 4.3 and system 5.3.0 by the author; lots of other
  12. folks have tried it on other systems.  There are three parts to the
  13. archive.  When you get them unpacked, check out the README file for
  14. installation directions and hints about the Makefile.
  15.  
  16. Good luck with your 87 taxes!
  17.  
  18.                     Bob Bond
  19.                     rgb@nscpdc
  20. Disclaimer:
  21.  
  22. Sc is not a product of National Semiconductor.  It is supplied as is
  23. with no warranty, express or implied, as a service to Usenet readers.
  24.  
  25. # This is a shell archive.  Remove anything before this line
  26. # then unpack it by saving it in a file and typing "sh file"
  27. # (Files unpacked will be owned by you and have default permissions).
  28. # This archive contains the following files:
  29. #    ./README
  30. #    ./sc.doc
  31. #
  32. if `test ! -s ./README`
  33. then
  34. echo "Extracting ./README"
  35. cat > ./README << '\SHAR\EOF\'
  36. This is a much modified version of the public domain spread sheet sc,
  37. posted a year or two ago by Mark Weiser as vc, originally by James Gosling.
  38.  
  39. Changes since my last version (4.1):
  40.  
  41. 1)  Range and cursor reverse video highlighting.
  42.  
  43. 2)  QUICK #ifdefs changed to -n option.  (thanks to Dave Davey)
  44.  
  45. 3)  A shell escape. (more thanks to Dave) 
  46.  
  47. 4)  More things to toggle.
  48.  
  49. 5)  An "end" command which allows you to skip to the end of one
  50.     range or the start of another.
  51.  
  52. 6)  PRIMITIVE macro support.  Don't bug me about this.  I'll add to
  53.     it as I get the time.
  54.  
  55. 7)  A better /copy command.
  56.  
  57. 8)  String expressions in addition to constant labels - this includes
  58.     concatenation, substring and numeric to string and back functions.
  59.  
  60. 9)  Time and date functions.
  61.  
  62. 10) Better floating point error handling.  It no longer aborts on
  63.     fp errors.
  64.  
  65. 11) Fixed variable references such as $K$20.  This allows you to
  66.     fix one end of a range instead of the whole thing.
  67.  
  68. 12) File names can be kept in a cell as a label.  To access the
  69.     file, just use the variable name instead of the file name.
  70.  
  71. 13) Optional subranges on the file commands.
  72.  
  73. 14) "w", "b" and " " commands similar to those in vi.
  74.  
  75. When you get it built, try "sc tutorial.sc" for a simple introduction
  76. to the basic commands.
  77.  
  78. A new input parser program (psc) has been included.  This program
  79. formats ascii files for use in the spread sheet. 
  80.  
  81. I have modified the makefile to make it easy for you to call the
  82. program what you want (I saw at least five different names in
  83. correspondence and on the net).  Just change "name=sc" and "NAME=SC" to
  84. "name=myfavoritename" and "NAME=MYFAVORITENAME" and try "make
  85. myfavoritename".
  86.  
  87. Similarly, you can make the documentation with "make myfavoritename.man".
  88. "make install" will make and install the code in EXDIR.  The
  89. installation steps and documentation all key off of the name.  The
  90. makefile even changes the name in the nroffable man page.  If you don't
  91. have nroff, you will have to change sc.man yourself.
  92.  
  93. The code has been tested against a Vax running 4.2 and 4.3 and a National
  94. ICM-3216 with system V.2 and V.3.  The ICM has a National Semi 32016.  Just
  95. check the makefile for the system flags.   I have heard reports of lots
  96. of other machines that work. If you have problems with lex.c, and don't
  97. care about arrow keys, define SIMPLE (-DSIMPLE in the makefile).  SIMPLE
  98. causes the arrow keys to not be used.
  99.  
  100. Disclaimer:
  101.  
  102. Sc is not a product of National Semiconductor.  It is supplied as is with
  103. no warranty, express or implied, as a service to Usenet readers.
  104.  
  105.                     Bob Bond
  106.  
  107.     Robert Bond             ihnp4!nsc!nscpdc!rgb
  108.     National Semiconductor        tektronix!nscpdc!rgb
  109. \SHAR\EOF\
  110. else
  111.   echo "will not over write ./README"
  112. fi
  113. if [ `wc -c ./README | awk '{printf $1}'` -ne 2681 ]
  114. then
  115. echo `wc -c ./README | awk '{print "Got " $1 ", Expected " 2681}'`
  116. fi
  117. if `test ! -s ./sc.doc`
  118. then
  119. echo "Extracting ./sc.doc"
  120. cat > ./sc.doc << '\SHAR\EOF\'
  121. .TH PNAME 1
  122. .SH NAME
  123. pname \- spread sheet calculator
  124. .SH SYNOPSIS
  125. .B pname
  126. [
  127. .I -x
  128. ]
  129. [
  130. .I -n
  131. ]
  132. [
  133. .I file
  134. ]
  135.  
  136. .SH DESCRIPTION
  137. The spread sheet calculator
  138. .I pname
  139. is based on rectangular tables much like a financial spread sheet.
  140. When it is invoked it presents you with an empty
  141. table organized as rows and columns of cells.  Each cell may have a label
  142. string associated with it and an expression.  The expression may be a
  143. constant or it may compute something based on other entries.
  144.  
  145. The
  146. .I -x
  147. option causes the 
  148. .I put
  149. and
  150. .I get
  151. commands to encrypt and decrypt the data files.
  152. The 
  153. .I -n
  154. option starts the program in quick numeric entry mode.
  155. Both of these options can be changed while the program is running
  156. with the ^T command.
  157.  
  158. When 
  159. .I pname
  160. is running, the screen is divided into four regions. The top
  161. line is for entering commands. The second line is for messages from
  162. .I pname.
  163. The third line and the first four columns show the row and column numbers.
  164. The rest of the screen forms a window looking at the table.
  165. The screen has two
  166. cursors: a cell cursor (indicated by a reverse video cell and a '<' on
  167. the screen) and a character cursor (indicated by the terminal's
  168. hardware cursor).  The cell and character cursors are often the same.
  169. They will differ when the user is typing a command on the top line.
  170.  
  171. The cursor control commands and the row, column commands can be 
  172. prefixed by a numeric argument indicating how many times the command
  173. is to be executed.  "^U" can be used before the number if
  174. the number is to be entered while a command is being typed
  175. into the command line or if quick entry mode is in effect.
  176.  
  177. Commands which use the terminal's control key such as ^N will work both
  178. when a command is being typed and when in normal mode.
  179.  
  180. Cursor control commands:
  181.  
  182. .IP \fB^N\fP
  183. Move the cell cursor to the next row.
  184.  
  185. .IP \fB^P\fP
  186. Move the cell cursor to the previous row.
  187.  
  188. .IP \fB^F\fP
  189. Move the cell cursor forward one column.
  190.  
  191. .IP \fB^B\fP
  192. Move the cell cursor backward one column.
  193.  
  194. .IP \fB^H\fP
  195. Backspace one character.
  196.  
  197. .IP "\fBh, j, k, l\fP"
  198. Alternate cursor controls (left, down, up, right).  The space bar
  199. is also defined to be right one cell.
  200.  
  201. .IP "\fBArrow Keys\fP"
  202. The terminal's arrow keys provide another alternate set of cell
  203. cursor controls if they exist and are supported in the
  204. .I termcap
  205. entry.
  206. Some terminals have arrow keys which conflict
  207. with other control key codes.  For example, a terminal could send ^H when the
  208. back arrow key is depressed.  In these cases, the conflicting arrow key
  209. performs the same function as the key combination it mimics.
  210.  
  211. .IP \fB0\fP
  212. Move the cell cursor to column 0 of the current row. 
  213. This command must be prefixed with ^U if quick numeric entry mode
  214. is enabled.
  215.  
  216. .IP \fB$\fP
  217. Move the cell cursor to the last valid column in the current row.
  218.  
  219. .IP \fB^\fP
  220. Move the cell cursor to row 0 of the current column.
  221.  
  222. .IP \fB#\fP
  223. Move the cell cursor to the last valid row in the current column.
  224.  
  225. .IP \fBg\fP
  226. Go to a cell.  The program will prompt for the name of a cell.
  227. Enter a cell number such as 
  228. .I a0
  229. or 
  230. .I ae122.
  231.  
  232. .IP \fBw\fP
  233. Scan forward (right and down)  to the next valid cell.
  234.  
  235. .IP \fBb\fP
  236. Scan backwards (left and up) to the next valid cell.
  237.  
  238. .IP \fB^E<d>\fP
  239. Go to end of range.  The 
  240. .I ^E
  241. is followed by a direction indication.
  242. This can be any of h, j, k, l, ^N, ^P, ^F, ^B or the arrow
  243. keys.  If the cell cursor starts on a non-blank cell, it will go in the
  244. indicated direction until it hits the last non-blank adjacent cell.  If
  245. the cell cursor starts on a blank cell, it go in the indicated
  246. direction until it hits the first non-blank cell.  This command is
  247. useful when specifying ranges of adjacent cells, especially when the
  248. range is bigger than the visible window.
  249.  
  250. .PP
  251. Cell entry and editing commands:
  252.  
  253. .IP \fB=\fP
  254. Enter a numeric expression into the current cell.  The program will
  255. prompt for the expression on the top line.  The usual way to enter a
  256. number into a cell is to type 
  257. .I =
  258. then enter the number in response to
  259. the prompt on the top line.  The quick numeric entry option (selected
  260. through the ^T command) shows the prompt when the first digit of a
  261. number is entered.
  262.  
  263. .IP \fB"\fP
  264. Enter a string into the current cell.  The string entered must be surrounded
  265. by quotation characters.  A string expression can also be entered by
  266. backspacing over the quotation mark in the prompt.
  267.  
  268. .IP \fB<\fP
  269. Enter a string that will be flushed left against the
  270. left edge of the cell.  The string entered must be surrounded
  271. by quotation characters.
  272. A string expression can also be entered by back spacing over the 
  273. quotation mark in the prompt.
  274.  
  275. .IP \fB>\fP
  276. Enter a label that will be flushed right against the
  277. right edge of the cell.  The string entered must be surrounded
  278. by quotation characters.
  279. A string expression can also be entered by back spacing over the 
  280. quotation mark in the prompt.
  281.  
  282. .IP \fBx\fP
  283. Clears the current cell.  You may prefix this command with a count of
  284. the number of cells on the current row to clear.  Cells cleared with
  285. this command may be recalled with any of the variations of the pull
  286. command.
  287.  
  288. .IP \fBe\fP
  289. Edit the value associated with the current cell.  This is identical to '='
  290. except that the command line starts out containing the old value or
  291. expression associated with the cell.
  292.  
  293. .IP \fBE\fP
  294. Edit the string associated with the current cell.  This is the same as
  295. one of <, >,
  296. and ", with the additional
  297. fact that the command line starts out with the old string.
  298.  
  299. .IP \fBm\fP
  300. Mark a cell to be used as the source for the copy command.
  301.  
  302. .IP \fBc\fP
  303. Copy the last marked cell to the current cell, updating the row and
  304. column references.
  305.  
  306. .IP \fB^T\fP
  307. Toggle options.  This command allows the user to switch the state
  308. of the encryption, quick numeric entry and top line display options.
  309. The user should follow the ^T character with one of "x", "n", or
  310. "t" to pick the intended option.  A small menu lists the choices
  311. when ^T is typed.
  312.  
  313. .PP
  314. Cells can contain both a number and a string.  To enter and edit the
  315. number, use 
  316. .I = 
  317. and 
  318. .I e.
  319. To enter and edit the string, use quote, 
  320. .I <, >
  321. and
  322. .I E.
  323. Either the string or the number (but not both at the same
  324. time) can be the result of evaluating an expression.  See the sections below
  325. on numeric and string expressions for more details.
  326.  
  327. .PP
  328. File operations
  329.  
  330. .IP \fBG\fP
  331. Get a new database from a file.  If the encryption option
  332. is enabled,
  333. the file is decrypted before it is loaded into the
  334. spread sheet.
  335.  
  336. .IP \fBP\fP
  337. Put the current database into a file.  If the encryption option
  338. is enabled, the file is encrypted before it is saved.
  339. The optional range argument saves a subset of the spreadsheet to
  340. the output file.
  341.  
  342. .IP \fBW\fP
  343. Write a listing of the current database in a form that matches its
  344. appearance on the screen.  This differs from the 
  345. .I put 
  346. command in that
  347. put's files are intended to be reloaded with 
  348. .I get,
  349. while 
  350. .I write
  351. produces
  352. a file for people to look at.
  353. The optional range argument writes a subset of the spreadsheet to
  354. the output file.
  355. If you try to write to the last file used with the
  356. .I put
  357. or 
  358. .I get
  359. commands, or the file specified on the command line when the
  360. program is invoked, you will be asked to confirm that the (potentially)
  361. dangerous operation is really what you wanted.
  362.  
  363. .IP \fBT\fP
  364. Write a listing of the current database to a file, but put ":"s between
  365. each field.  This  is useful for tables that will be further formatted
  366. by the
  367. .I tbl
  368. preprocessor of
  369. .I nroff.
  370. The optional range argument writes a subset of the spreadsheet to
  371. the output file.
  372. If you try to write to the last file used with the
  373. .I put
  374. or 
  375. .I get
  376. commands, or the file specified on the command line when the
  377. program is invoked, you will be asked to confirm that the (potentially)
  378. dangerous operation is really what you wanted.
  379.  
  380. .IP \fBM\fP
  381. Merges the database from the named file into the current database.  Values,
  382. expressions and names defined in the named file are written into the current
  383. file, overwriting the existing entries at those locations.
  384.  
  385. .IP \fBR\fP
  386. Run macros.  Since 
  387. .I pname
  388. files are saved as ascii files, it is possible to use them as primitive
  389. macro definition files.  The
  390. .I R 
  391. command makes this easier by giving a saved a path name as the start of
  392. the file name in the merge command.  The string to use is defined by
  393. the 
  394. .I D
  395. command below.  To use write macros, you must be familier with
  396. the save file formats.  This facility is still primitive and could be
  397. much improved.
  398.  
  399. .IP \fBD\fP
  400. Define a path for the 
  401. .I R
  402. command to use.
  403.  
  404. .PP 
  405. The three output operators, 
  406. .I put, write
  407. and
  408. .I tbl
  409. can pipe their (unencrypted only) output to a program.  To use
  410. this option, enter "| program" to
  411. the prompt asking for a file name.  For example, to redirect the output
  412. of the write command to the printer, you could enter "| lpr -p".
  413.  
  414. All file operations take a file name as the first argument to the
  415. prompt on the top line.  The prompt supplies a quotation mark to aid in
  416. typing in the file name.   The file name can also be obtained from a
  417. cell from a label field or a string expression.  In this case, the
  418. leading quote should be deleted with the back space key and a cell name
  419. such as 
  420. .I a22
  421. entered instead.  If the string in the cell starts with
  422. "|", the rest of the string is interpeted as a unix command, as above.
  423.  
  424. .PP
  425. Row and Column operations.  Members of this class of commands can be used
  426. on either rows or columns.  The second letter of the command is either
  427. a column designator (one of the characters c, j, k, ^N, ^p) or a 
  428. row designator (one of r, l, h, ^B, ^F).
  429. Commands which move or copy cells also modify the variable references 
  430. in affected cell expressions.
  431. Variable references may be frozen by using the 
  432. .I fixed
  433. operator or using the "$" character in the reference to the cell.
  434.  
  435. .IP "\fBar, ac\fP"
  436. Creates a new row (column) immediately following the current row (column).
  437. It is initialized
  438. to be a copy of the current one.
  439.  
  440. .IP "\fBdr, dc\fP"
  441. Delete this row (column).
  442.  
  443. .IP "\fBpr, pc, pm\fP"
  444. Pull deleted rows (columns) back into the spread sheet.  The last deleted
  445. set of cells is put back into the spread sheet at the current location.
  446. .I Pr
  447. inserts enough rows to hold the data.
  448. .I Pc
  449. inserts enough columns to hold the data.
  450. .I Pm
  451. (merge) does not insert rows or columns. It overwrites the cells
  452. beginning at the current cursor location.
  453.  
  454. .IP "\fBir, ic\fP"
  455. Insert a new row (column) by moving the row (column) containing the cell
  456. cursor, and all
  457. following, down (right) one.  The new position will be empty.
  458.  
  459. .IP "\fBzr, zc\fP"
  460. Hide ("zap") the current row (column).  This keeps a row or column from being
  461. displayed but keeps it in the data base.
  462.  
  463. .IP "\fBvr, vc\fP"
  464. Removes expressions from the affected rows (columns), leaving only
  465. the values which were in the cells before the command
  466. was executed.
  467.  
  468. .IP "\fBsr, sc\fP"
  469. Show hidden rows (columns).  Type in a range of rows or columns
  470. to be revealed.  The command default is the first range of rows or
  471. columns currently hidden.
  472.  
  473. .IP \fBf\fP
  474. Sets the output format to be used for printing the numbers in each cell in
  475. the current column.  Type in two numbers which will be the width in
  476. characters of a column and the number of digits which will follow the
  477. decimal point.  Note that this command has only a column version and
  478. does not have a second letter.  A preceeding count can be used to
  479. specify that more than one column be formatted.
  480.  
  481. .PP
  482. Range Operations:
  483. Range operations
  484. affect a rectangular region on the screen.  
  485. All of the commands in this class start with a slash; the second
  486. letter of the command indicates which command.
  487. The program will prompt for needed parameters.  Phrases surrounded by
  488. square brackets in the prompt are informational only and may be erased with
  489. the backspace key.
  490.  
  491. Prompts requesting variable names
  492. may be satisfied with either an explicit variable name, such as 
  493. .I A10
  494. or with a variable name previously defined in a 
  495. .I /d
  496. command.  Range name prompts require either an explicit range such
  497. as 
  498. .I A10:B20
  499. or a range name previously defined with a 
  500. .I /d
  501. command.  A default range shown in line 2 is used if the range is
  502. omitted from the command.  The default range can be changed by moving
  503. the cell cursor via the control commands (^N, ^F, ^N, ^P) or the arrow
  504. keys.  The default range will be highlighted in standout mode on the
  505. terminal.
  506.  
  507. .IP "/\fBx\fP"
  508. Clear a range.  Cells cleared with this command may be recalled
  509. via any of the pull row or column commands.
  510.  
  511. .IP "/\fBc\fP"
  512. Copy a source range to a destination range. 
  513. The source and destination may be different sizes.  The result is
  514. always one or more full copies of the source.  Copying a row to a row
  515. yields a row.  Copying a column to a column yields a column.  Copying a
  516. range to anything yields a range.  Copying a row to a column or a
  517. column to a row yields a range with as many copies of the source as
  518. there are cells in the destination.  This command can be used to dup a
  519. cell though an arbitrary range by making the source a single cell
  520. range such as
  521. .I b20:b20.
  522.  
  523. .IP "/\fBf\fP"
  524. Fill a range with constant values.  The start and increment numbers
  525. may be positive or negative.
  526.  
  527. .IP "/\fBv\fP"
  528. Values only.  This command removes the formulas from a range of
  529. cells, leaving just the values of the expressions.
  530.  
  531. .IP "/\fBd\fP"
  532. This command is used to assign a symbolic name to a single cell or 
  533. a rectangular range of cells on the screen.  The parameters are the
  534. name, surrounded by quotation marks, and either a single cell name
  535. such as 
  536. .I A10 
  537. or a range such as 
  538. .I A10:B20.
  539. Names defined in this
  540. fashion will be used by the program in future prompts, may be
  541. entered in response to prompts requesting a cell or range name,
  542. and will be saved when the spread sheet is saved with a
  543. .I Put
  544. command.  Names defined must be more than two alpha
  545. characters long to differentiate them from a column names, and must not have
  546. embedded special characters.  Names may include the character "_" or numerals
  547. as long as they occur after the first three alpha characters.
  548.  
  549. .IP "/\fBs\fP"
  550. This command will list (show) the defined range names.
  551.  
  552. .IP "/\fBu\fP"
  553. This command is used to undefine a range name.  The range must have
  554. been previously defined.
  555.  
  556. .PP
  557. Miscellaneous commands:
  558.  
  559. .IP \fBq\fP
  560. Exit from
  561. .IR pname.
  562. If you were editing a file, and you modified
  563. it, then
  564. .I pname
  565. will ask about saving before exiting. 
  566. If you aren't editing a file and haven't saved the data you
  567. entered, you will get a chance to save the data
  568. before you exit.
  569.  
  570. .IP \fB^C\fP
  571. Alternate exit command.
  572.  
  573. .IP \fB?\fP
  574. Types a brief helpful message.
  575.  
  576. .IP "^\fBG or ESC\fP"
  577. Abort entry of the current command.
  578.  
  579. .IP "^\fBR or ^L\fP"
  580. Redraw the screen.
  581.  
  582. .IP \fB^V\fP
  583. Types, in the command line, the name of the cell referenced by
  584. the cell cursor.  This is used when typing in expressions which refer to
  585. entries in the table.
  586.  
  587. .IP \fB^W\fP
  588. Types, in the command line, the expression of the cell referenced
  589. by the cell cursor.
  590.  
  591. .IP \fB^A\fP
  592. Types, in the command line, the value of the cell referenced
  593. by the cell cursor.
  594.  
  595. .IP \fB!\fP
  596. Shell escape. 
  597. The program prompts for a shell command to run.  
  598. The user should terminate the command with a <return> key.
  599. No command will start the shell in interactive mode.
  600. A second "!" will repeat the last command.
  601. If the environment varible "SHELL" is defined, that shell is
  602. run.  If not, /bin/sh is used.
  603.  
  604. .IP <\fBTAB\fP>
  605. Starts highlight mode.  This allows the user to highlight a range of
  606. cells via the cursor control codes or the arrow keys.  The highlighted
  607. range starts at the cell where the user typed tab and continues through
  608. the current cell cursor.  Hitting tab again causes the highlighted
  609. range to be entered into the command line and the highlighting to be
  610. turned off.  This is most useful for defining ranges to functions such
  611. as @sum().  Hitting ')' acts just like typing the tab key the second
  612. time and adds the closing ')'.
  613.  
  614. .PP
  615. Expressions that are used with the '=' and 'e' commands have a fairly
  616. conventional syntax.  Terms may be variable names,
  617. parenthesised expressions, negated terms, and constants. 
  618. Ranges may be operated upon with '@' functions
  619. such as sum (@sum) and average (@avg).
  620. Terms may be combined using many binary
  621. operators.  Their precedences (from highest to lowest) are: ^; *,/; +,-;
  622. <,=,>,<=,>=; &; |; ?.
  623.  
  624. .TP 15
  625. e+e
  626. Addition.
  627.  
  628. .TP 15
  629. e-e
  630. Subtraction.
  631.  
  632. .TP 15
  633. e*e
  634. Multiplication.
  635.  
  636. .TP 15
  637. e/e
  638. Division.
  639.  
  640. .TP 15
  641. e^e
  642. Exponentiation.
  643.  
  644. .TP 15
  645. Variable Names
  646. Normally, a variable name is just the name of a cell, such as 
  647. .I K20.
  648. The value is the contents of the cell.  When the formula is copied to
  649. another location via copy or range copy, variable refernces are offset
  650. by the amount the formula moved.  This allows the new formula to work on
  651. new data.  If the cell reference is not to change, the user can either
  652. use the 
  653. .I fixed 
  654. operator below, or can use one of the following
  655. variations on the cell name:  
  656. .I K20
  657. references cell K20; the reference
  658. changes when the formula is copied.  
  659. .I $K$20
  660. always refers to K20; the
  661. reference stays fixed when the formula is copied.  
  662. .I $K20
  663. keeps the
  664. column fixed at column K, the row is free to vary.  Similarly, 
  665. .I K$20
  666. fixes the row and allows the column to vary.
  667.  
  668. These conventions also hold on defined ranges.  Range references
  669. vary when formulas containing them are copied.  If the range is defined
  670. with fixed variable references, the references do not change.
  671.  
  672. .TP 15
  673. @sum(range)
  674. Sum all valid (nonblank) entries in the region whose two corners are defined
  675. by the two variable (cell) names or the range name given.
  676.  
  677. .TP 15
  678. @avg(range)
  679. Average all valid (nonblank) entries in the region whose two corners are defined
  680. by the two variable (cell) names or the range name given.
  681.  
  682. .TP 15
  683. @prod(range)
  684. Multiply together all valid (nonblank) entries in the region whose two
  685. corners are defined by the two variable (cell) names or the range name given.
  686.  
  687. .TP 15
  688. @max(range)
  689. Return the maximum value in specified region.
  690.  
  691. .TP 15
  692. @min(range)
  693. Return the minimum value in the specified region.
  694.  
  695. .TP 15
  696. @stddev(range)
  697. Return the sample standard deviation of the specified region.
  698.  
  699. .TP 15
  700. e?e:e
  701. Conditional: If the first expression is true then the value of the second is
  702. returned, otherwise the value of the third is.
  703.  
  704. .TP 15
  705. <,=,>,<=,>=
  706. Relationals: true iff the indicated relation holds.
  707.  
  708. .TP 15
  709. &,|
  710. Boolean connectives.
  711.  
  712. .TP 15
  713. fixed
  714. To make a variable not change automatically when a cell moves,
  715. put the word \*(lqfixed\*(rq in front of the reference.  I.e.
  716. B1*fixed C3.
  717.  
  718. .PP
  719. Assorted math functions.  Most of these are standard system functions
  720. more fully described in
  721. .I math(3).
  722.  
  723. All of them operate on floating point numbers (doubles);
  724. the trig functions operate with angles in radians.
  725.  
  726. .TP 15
  727. @exp(expr)
  728. Returns exponential function of <expr>.
  729.  
  730. .TP 15
  731. @ln(expr)
  732. Returns the natural logarithm of <expr>.
  733.  
  734. .TP 15
  735. @log(expr)
  736. Returns the base 10 logarithm of <expr>.
  737.  
  738. .TP 15
  739. @pow(expr1,expr2)
  740. Returns <expr1> raised to the power of <expr2>.
  741.  
  742. .TP 15
  743. @floor(expr)
  744. Returns returns the largest integer not greater than <expr>.
  745.  
  746. .TP 15
  747. @ceil(expr)
  748. Returns the smallest integer not less than <expr>.
  749.  
  750. .TP 15
  751. @rnd(expr)
  752. Rounds <expr> to the nearest integer.
  753.  
  754. .TP 15
  755. @hypot(x,y)
  756. Returns SQRT(x*x+y*y), taking precautions against unwarranted overflows.
  757.  
  758. .TP 15
  759. @fabs(expr)
  760. Returns the absolute value |expr|.
  761.  
  762. .TP 15
  763. @sin(expr), @cos(expr), @tan(expr)
  764. Return trigonometric functions of radian arguments. The magnitude of the
  765. arguments are not checked to assure meaningful results.
  766.  
  767. .TP 15
  768. @asin(expr)
  769. Returns the arc sin in the range -pi/2 to pi/2
  770.  
  771. .TP 15
  772. @acos(expr)
  773. Returns the arc cosine in the range 0 to pi.
  774. }i(<|J
  775. .TP 15
  776. @atan(expr)
  777. Returns the arc tangent of <expr> in the range -pi/2 to pi/2.
  778.  
  779. .TP 15
  780. @dtr(expr)
  781. Converts <expr> in degrees to radians.
  782.  
  783. .TP 15
  784. @rtd(expr)
  785. Converts <expr> in radians to degrees.
  786.  
  787. .TP 15
  788. pi
  789. A constant quite close to pi.
  790.  
  791. .TP 15
  792. @gamma(expr1)
  793. Returns the natural log of the gamma function.
  794.  
  795. .TP 15
  796. @ston(se)
  797. Converts se from a string expression to a number.
  798.  
  799. .TP 15
  800. @eqs(se1, se2)
  801. Returns a one if se1 is the same string as se2.
  802.  
  803. .PP
  804. Time and date functions:
  805.  
  806. Time for 
  807. .I pname
  808. follows the system standard: the number of seconds since 1970.
  809. The following functions take the time in seconds as an argument and
  810. return the specified value.  The current time is available through
  811. .I @now,
  812. below.  The functions all convert from GMT to local time.
  813.  
  814. .TP 15
  815. @month(seconds)
  816. Returns the month, encoded from 1 (January) to 12 (December).
  817.  
  818. .TP 15
  819. @day(seconds)
  820. Returns the day, encoded from 1 to 31.
  821.  
  822. .TP 15
  823. @year(seconds)
  824. Returns the year.  Valid years begin with 1970.  The last legal year
  825. is system dependent.
  826.  
  827. .TP 15
  828. @hour(seconds)
  829. Returns the number of hours since midnight.  Encoded as 0 to 23.
  830.  
  831. .TP 15
  832. @minute(seconds)
  833. Returns the number of minutes since the last full hour.  Encoded as
  834. 0 to 59.
  835.  
  836. .TP 15
  837. @second(seconds)
  838. Returns the number of seconds since the last full minute, encoded
  839. from 0 to 59.
  840.  
  841. .TP 15
  842. @now
  843. Returns the current time encoded as the number of seconds since December
  844. 31, 1969, Midnight, GMT.
  845.  
  846. .PP 
  847. String expressions are made up of constant strings (characters surrounded
  848. with double quotation marks), and string functions.  The most useful operator
  849. is the concatenation operator, "#".  For example, the string expression
  850. "the"#" dog"
  851. displays the string "the dog" in the cell.  Other string operators 
  852. extract substrings and give the date in system standard
  853. format.  A cell name such as "A5" in a string expression will return
  854. the string associated with that cell.
  855.  
  856. Valid string operators include:
  857.  
  858. .TP 15
  859. "characters"
  860. Constant strings are characters surrounded by double quotation marks.
  861.  
  862. .TP 15
  863. @substr(se, i1, i2)
  864. Extract the substring indexed by character number
  865. .I i1
  866. through character
  867. number 
  868. .I i2 
  869. from the string expression
  870. .I se.
  871. As an example,
  872. @substr("Nice jacket", 4, 7)
  873. returns the string "e jac".
  874. .I Se
  875. can be any string expression.  
  876. .I I1
  877. and
  878. .I i2
  879. can be any numeric expressions.
  880.  
  881. .TP 15
  882. @fmt(se, e)
  883. Fmt converts a number to a string.  The argument
  884. .I se
  885. should be a valid 
  886. .I printf(3)
  887. format string.  
  888. .I e
  889. is converted according to the standard rules.  As an example,
  890. .I @fmt("**%6.3f**", 10.5)
  891. will yield the string
  892. .I **10.500**.
  893. The second argument,
  894. .I e,
  895. is a double, so applicable formats are e, E, f, g, and G.
  896. Try "%g" as a starting point.
  897.  
  898. .TP 15
  899. @date(e)
  900. Date converts the time in seconds to a date string 24 characters
  901. long in the following form:
  902.  
  903. .I Sun Sep 16 01:03:52 1973
  904.  
  905. .SH SEE ALSO
  906. bc(1), dc(1), crypt(1), ppname(1)
  907.  
  908. .SH BUGS
  909.  
  910. Expression reevaluation is done in the same top-to-bottom, left-to-right
  911. manner as is done in other spread sheet calculators.  This is silly.  A
  912. proper following of the dependency graph with (perhaps) recourse to
  913. relaxation should be implemented.
  914.  
  915. At most 200 rows and 40 columns.
  916. \SHAR\EOF\
  917. else
  918.   echo "will not over write ./sc.doc"
  919. fi
  920. if [ `wc -c ./sc.doc | awk '{printf $1}'` -ne 22846 ]
  921. then
  922. echo `wc -c ./sc.doc | awk '{print "Got " $1 ", Expected " 22846}'`
  923. fi
  924. echo "Finished archive 1 of 3"
  925. # if you want to concatenate archives, remove anything after this line
  926. exit
  927.  
  928.