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

NAME

6       sc - spreadsheet calculator
7

SYNOPSIS

9       sc  [-a]  [-c]  [-e]  [-m]  [-n] [-o] [-q] [-r] [-v] [-x] [-C] [-R] [-P
10       range[/address] | /address] [-W range] [file...]
11

DESCRIPTION

13       The spreadsheet calculator sc is based on rectangular tables much  like
14       a  financial  spreadsheet.   When invoked, it first looks for a file in
15       the user's home directory called .scrc and if found,  reads  that  file
16       into  memory.  If that file contains the command ``set scrc'', sc looks
17       for a file called .scrc in the current directory, and if  found,  reads
18       that  file  into memory, too.  Next, it reads the options from the com‐
19       mand line, and finally, it reads in the file or files specified on  the
20       command  line  and  presents  the data in a table organized as rows and
21       columns of cells.  If invoked without a file  argument,  the  table  is
22       initially  empty,  unless it is running in a pipeline, in which case it
23       will read its data from the standard input.  If more than one  file  is
24       specified,  all files except the first one will be merged.  The default
25       filename for saving a file with the Put command will be the same as the
26       first  file  specified,  and the other files will be treated as macros.
27       If you want to use advanced macros from the  command  line,  the  ``|''
28       must be quoted to prevent it from being expanded by the shell.
29
30       Options  begin  with  -.   However,  an  argument of a single - will be
31       interpreted to mean that spreadsheet data will be taken from the  stan‐
32       dard  input.  This is useful for including sc in a pipeline if the sys‐
33       tem supports pipes.  However, if standard input is not a terminal,  the
34       -  is  only necessary if there are multiple files and standard input is
35       not the last to be read, since standard input is automatically read  in
36       after  all other files in such cases if it is not specified explicitly,
37       or if there are no other filenames on  the  command  line.   If  sc  is
38       included  in  a pipeline, and a filename of ``-'' is not specified, the
39       standard input will be merged in after all of  the  other  named  files
40       have been processed.
41
42       The first argument not beginning with a -, or a single - by itself, and
43       any subsequent arguments will all be interpreted as filenames (a  file‐
44       name  of  -  meaning  standard  input as noted above).  In addition, an
45       argument of -- may be used to signify  that  all  subsequent  arguments
46       should  be treated as filenames even if they begin with a -, but unlike
47       -, -- won't be treated as a filename itself.
48
49       Each cell may have associated with it a numeric value, a label  string,
50       and/or  an  expression  (formula) which evaluates to a numeric value or
51       label string, often based on other cell values.
52
53       For an online tutorial, type the command:
54
55              sc /usr/share/doc/sc/tutorial.sc
56
57       To print a quick reference card, type the command:
58
59              scqref | [your_printer_commmand]
60

OPTIONS

62       -a     Do not run the autorun macro, if one is specified in the file.
63
64       -c     Start the program with the recalculation being  done  in  column
65              order.
66
67       -e     Start   the   program  with  round-to-even  (banker's  rounding)
68              enabled.
69
70       -m     Start the program with automatic  recalculation  disabled.   The
71              spreadsheet  will be recalculated only when the ``@'' command is
72              used.
73
74       -n     Start the program in quick numeric entry mode (see below).
75
76       -o     Start the program with  automatic  optimization  of  expressions
77              enabled.
78
79       -q     Quit  after  loading all files, but before becoming interactive.
80              This is useful in shell scripts for getting information  from  a
81              file,  for  example, or using sc as a non-interactive calculator
82              using the eval command.
83
84       -r     Start the program with the recalculation being done in row order
85              (default option).
86
87       -v     When  piping  data  out  using the -P option (below), change all
88              expressions to values.  The -v option must precede the -P option
89              to  have  an  effect.   If the -P option is used more than once,
90              there must be a separate -v option for each instance of  the  -P
91              option.
92
93       -x     Cause  the  Get  and  Put  commands  (see  below) to encrypt and
94              decrypt data files.
95
96       -C     Start the program with automatic newline action set to increment
97              the column (see below).
98
99       -P range[/address]
100       -P /address
101              Pipe  a range to standard output.  The output is similar to that
102              of the Put command (below), except that only cell data and  for‐
103              matting  information  for cells in the range are output, without
104              all of the colors, range definitions,  column  formatting,  etc.
105              The  optional  /address  is  used to adjust all addresses in the
106              range to a new starting point.  This is useful for copying  data
107              from  one  file  to another, especially when used in conjunction
108              with the -v option (above), using something like merge  "|sc  -v
109              -Prange/address  filename"  (note the pipe symbol).  This option
110              may be used more than once to specify  multiple  ranges.   Note,
111              however,  that  the  -v option must precede the -P option on the
112              command line, and there must be a separate -v  option  for  each
113              instance  of  the -P option.  Any instance of -P not preceded by
114              its own -v option will output unevaluated expressions.
115
116              A range of ``%'' may be used to refer to the entire spreadsheet.
117              If  the range is left out, as shown in the second form above, sc
118              will be started interactively in navigate mode, allowing you  to
119              navigate  the  spreadsheet  and  highlight the range you want to
120              output.  Pressing ESC, ^G, or  q  will  terminate  without  out‐
121              putting any data.
122
123       -R     Start the program with automatic newline action set to increment
124              the row (see below).
125
126       -W     Pipe a range to standard output.  The  output  is  identical  to
127              that of the Write command (below).  This option may be used more
128              than once to specify multiple ranges.  A range of ``%''  may  be
129              used to refer to the entire spreadsheet.
130
131       All  of  these  options  can be changed with the ^T and S commands (see
132       below) while sc is running.  Options specified when sc is invoked over‐
133       ride options saved in the data file.
134
135   Personal Initialization File
136       When  sc first starts, it looks for a file in the user's home directory
137       called .scrc and if found, loads it into memory.  The  format  of  this
138       file  is the same as any other sc file, but should be reserved for set‐
139       ting certain defaults.  Any options set which have  equivalent  command
140       line  options may be overridden by the command line.  If that file con‐
141       tains the command ``set scrc'', sc will then look  for  a  file  called
142       .scrc  in the current directory, and if found, load that file into mem‐
143       ory, too (this is analogous to the ``set exrc'' command used by vi/ex).
144       These ``dotfiles'' may be created by any text editor.  Several commands
145       exist specifically for setting default  file  name  extensions  in  the
146       .scrc  file,  although  they  may  also  be  used from macros, ordinary
147       spreadsheet files, or from within sc at the command  line.   They  will
148       not,  however,  be saved along with the file.  The extensions should be
149       quoted, and should not include the preceding `.' (e.g., scext "sc" will
150       add the extension .sc ).  These commands are:
151
152       scext  This is the default extension for normal sc files (those created
153              with the Put command).  If this command  is  not  used,  all  sc
154              files  will  be  saved  without  an  extension, and any existing
155              extension will not be removed.  Setting this option  causes  all
156              sc  files to be saved with the specified extension added, unless
157              it is already present.  If the file name already has  an  exten‐
158              sion of .sc, it will first be removed.  Any other extension will
159              not be removed.
160
161       ascext This is the default extension for plain text files created  with
162              the  Write  command.  The file name will first be checked to see
163              if it already has an extension of either .sc  or  the  extension
164              specified  with  scext  above, and if either one exists, it will
165              first be removed before  adding  the  new  extension.   If  this
166              option is not set, a default of .asc will be used.
167
168       tbl0ext
169              This  is  the  default  extension for files created with the Tbl
170              command if tblstyle is set to 0 (default).  The file  name  will
171              first be checked to see if it already has an extension of either
172              .sc or the extension specified with scext above, and  if  either
173              one  exists,  it  will  first  be  removed before adding the new
174              extension.  If this option is not set, a default of .cln will be
175              used.
176
177       tblext This  is  the  default  extension for files created with the Tbl
178              command if tblstyle is set to tbl.  The file name will first  be
179              checked  to  see if it already has an extension of either .sc or
180              the extension specified with scext  above,  and  if  either  one
181              exists,  it  will  first be removed before adding the new exten‐
182              sion.  If this option is not set, a  default  of  .tbl  will  be
183              used.
184
185       latexext
186              This  is  the  default  extension for files created with the Tbl
187              command if tblstyle is set to latex.  The file name  will  first
188              be  checked  to see if it already has an extension of either .sc
189              or the extension specified with scext above, and if  either  one
190              exists,  it  will  first be removed before adding the new exten‐
191              sion.  If this option is not set, a  default  of  .lat  will  be
192              used.
193
194       slatexext
195              This  is  the  default  extension for files created with the Tbl
196              command if tblstyle is set to slatex.  The file name will  first
197              be  checked  to see if it already has an extension of either .sc
198              or the extension specified with scext above, and if  either  one
199              exists,  it  will  first be removed before adding the new exten‐
200              sion.  If this option is not set, a  default  of  .stx  will  be
201              used.
202
203       texext This  is  the  default  extension for files created with the Tbl
204              command if tblstyle is set to tex.  The file name will first  be
205              checked  to  see if it already has an extension of either .sc or
206              the extension specified with scext  above,  and  if  either  one
207              exists,  it  will  first be removed before adding the new exten‐
208              sion.  If this option is not set, a  default  of  .tex  will  be
209              used.
210
211   General Information
212       The  screen is divided into four regions.  The top line is for entering
213       commands and displaying cell values.  The second line is  for  messages
214       from sc.  The third line and the first four columns show the column and
215       row numbers, from which are derived cell addresses, e.g.   A0  for  the
216       cell  in column A, row 0.  Note that column names are case-insensitive:
217       you can enter A0 or a0.
218
219       The rest of the screen forms a window looking at a portion of  the  ta‐
220       ble.  The total number of display rows and columns available, hence the
221       number of table rows and columns displayed, is set by curses(3) and may
222       be  overridden  by setting the LINES and COLUMNS environment variables,
223       respectively.
224
225       The screen has two cursors: a cell cursor, indicated by either a  high‐
226       lighted  cell  or  a ``<'' on the screen, and a character cursor, indi‐
227       cated by the terminal's hardware cursor.
228
229       If a cell's numeric value is wider than the column  width  (see  the  f
230       command),  the cell is filled with asterisks.  If a cell's label string
231       is wider than the column width, it is truncated at  the  start  of  the
232       next non-blank cell in the row, if any.
233
234       Cursor  control commands and row and column commands can be prefixed by
235       a numeric argument which indicates how many times the command is to  be
236       executed.  You can type ^U before a repeat count if quick numeric entry
237       mode is enabled.
238
239   Changing Options
240
241       ^To    Toggle options.  This command allows you to switch the state  of
242              one  option selected by o.  A small menu lists the choices for o
243              when you type ^T.  Unless otherwise noted, the options  selected
244              are  saved when the data and formulas are saved so that you will
245              have the same setup next time you enter the spreadsheet.
246
247              a      Automatic Recalculation.  When set, each  change  in  the
248                     spreadsheet  causes  the  entire  spreadsheet be recalcu‐
249                     lated.  Normally this is not  noticeable,  but  for  very
250                     large  spreadsheets,  it may be faster to clear automatic
251                     recalculation  mode  and  update  the   spreadsheet   via
252                     explicit ``@'' commands.  Default is automatic recalcula‐
253                     tion on.
254
255              b      Braille enhancement mode.  See the braille section  under
256                     the  Set  command below for a complete description of how
257                     to use this mode.  This option is not saved when saving a
258                     file,  to  allow  blind and sighted users to easily share
259                     files.  It is intended for use in a user's .scrc file.
260
261              c      Current cell highlighting.  If enabled, the current  cell
262                     is  highlighted  (using  the terminal's standout mode, if
263                     available) and the cell  pointer  ``<''  is  turned  off.
264                     This is enabled by default.
265
266              e      External  function  execution.   When  disabled, external
267                     functions (see @ext() below) are not called.  This  saves
268                     a  lot of time at each screen update.  External functions
269                     are disabled by default.  If disabled, and external func‐
270                     tions  are  used anywhere, a warning is printed each time
271                     the screen is updated, and the result of  @ext()  is  the
272                     value from the previous call, if any, or a null string.
273
274              i      Automatic  insertion of rows/columns.  If this is enabled
275                     and craction is set to move the cell cursor  either  down
276                     or  to the right after entering data into a cell, and the
277                     last cell in a row/column in the scrolling portion  of  a
278                     framed  range was just filled, causing the cell cursor to
279                     move outside of this range,  a  new  column/row  will  be
280                     inserted,  thus  enlarging  the range and allowing you to
281                     continue entering data into the row/column without  over‐
282                     writing  the frame (which may contain expressions of some
283                     sort, such as totals).  If autowrap is also  enabled,  it
284                     will  take  precedence, and a new row/column will only be
285                     inserted after entering data in the very last cell  (bot‐
286                     tom right corner) of the scrolling range.  The default is
287                     no automatic insertion.
288
289              w      Automatic wrap to next row/column.  If  this  is  enabled
290                     and  craction  is set to move the cell cursor either down
291                     or to the right after entering data into a cell, and  the
292                     last  cell  in a row/column in the scrolling portion of a
293                     framed range was just filled, causing the cell cursor  to
294                     move  outside of this range, the cell cursor will move to
295                     the first cell in the next row/column in this range.   If
296                     this would also take the cursor out of the scrolling por‐
297                     tion of the range, the cursor will remain in last  edited
298                     cell instead, unless autoinsert is also enabled, in which
299                     case a new row/column will be added so  that  the  cursor
300                     can wrap.  The default is no autowrap.
301
302              l      Autolabeling.   If enabled, using the define command (rd)
303                     causes a label to be automatically generated in the  cell
304                     to  the  left  of the defined cell.  This is only done if
305                     the cell to the left is empty.  Default is enabled.
306
307              n      Quick numeric  entry.   If  enabled,  a  typed  digit  is
308                     assumed  to  be the start of a numeric value for the cur‐
309                     rent cell, not a repeat count,  unless  preceded  by  ^U.
310                     Also,  the  `+'  and  `-' keys will enter insert mode and
311                     append a `+' or `-' to the existing contents of the cell,
312                     allowing  the  user to easily add to or subtract from the
313                     current numeric contents of the cell.   The  cursor  con‐
314                     trols  (^P,  ^N,  or  any of the arrow keys) in this mode
315                     will end a numeric entry if  the  entry  was  started  by
316                     pressing  `+',  `-',  or  a digit.  Switching from insert
317                     mode to edit mode  will  cause  the  cursor  controls  to
318                     revert to their normal functions.
319
320              o      Automatic   optimization  of  expressions.   If  this  is
321                     enabled, expressions which evaluate  to  a  constant  are
322                     automatically  optimized upon entry.  For example, if you
323                     enter @pow(2,32) into a cell, the value  4294967296  will
324                     be stored in that cell, whereas if optimization is turned
325                     off, the calculated value  will  be  displayed,  but  the
326                     actual  expression  will  be  stored in the cell instead.
327                     This allows you to edit the  expression  instead  of  re-
328                     entering  it  from  scratch  when you just want to make a
329                     minor change.  Default is automatic optimization off.
330
331              t      Top line display.  If enabled, the name and value of  the
332                     current  cell  is displayed on the top line.  If there is
333                     an associated label string, the first  character  of  the
334                     string  value is ``|'' for a centered string, ``<'' for a
335                     leftstring or ``>'' for a rightstring (see  below),  fol‐
336                     lowed  by  "string" for a constant string or {expr} for a
337                     string expression.  A constant string  may  be  preceeded
338                     with a backslash (`\').  In this case the constant string
339                     will be used as a ``wheel'' to fill a column,  e.g.  "\-"
340                     for a line in a column, and "\Yeh " for "Yeh Yeh Ye".  If
341                     the cell has a numeric  value,  it  follows  as  [value],
342                     which may be a constant or expression.
343
344              $      Dollar  prescale.  If enabled, all numeric constants (not
345                     expressions) which you enter are multipled by 0.01 so you
346                     don't  have to keep typing the decimal point if you enter
347                     lots of dollar figures.
348
349              r      Newline action.  This is a 3-way toggle which  determines
350                     which  direction to move after pressing the RETURN key to
351                     enter data into a cell.  It has the same effect as  using
352                     the  set (S) command to set the value of craction.  After
353                     selecting this option,  you  will  be  prompted  for  the
354                     direction  you  want  to move.  Valid directions are down
355                     (craction=1) and to the right (craction=2).  Pressing  j,
356                     ^N,  or the cursor-down key will cause the cursor to move
357                     down a cell each time you press the RETURN key and press‐
358                     ing  l, the cursor-right key, or the space bar will cause
359                     the cursor to move one cell to the right.   Pressing  the
360                     RETURN  key  at the prompt selects no action (craction=0,
361                     which means that the cursor will remain  in  the  current
362                     cell).   No  action  is  the default unless sc is started
363                     with either the -R or -C option.  This option is  ignored
364                     if  the  cell into which data is being entered is not the
365                     current cell.
366
367              s      Enable/disable color slop.  If a cell's label  string  is
368                     wider  than  the column width, it will slop over into the
369                     next cell to the right if that cell is  empty.   However,
370                     if  that  cell  is  in  a  different color range than the
371                     first, this slopover  will  be  disabled,  regardless  of
372                     whether the colors assigned to the two ranges are differ‐
373                     ent or not.  If cslop is enabled, strings may  slop  over
374                     even if the next cell is in a different color range, car‐
375                     rying their color with them, which  may  cause  a  ragged
376                     boundary between the ranges, but may allow the strings to
377                     be seen in their entirety.  Cslop is disabled by default.
378
379              x      Encryption.  See the -x option.
380
381              z      Set newline action limits.  This option  sets  limits  to
382                     the  newline  action  option  above.  When this option is
383                     invoked, the row and  column  of  the  current  cell  are
384                     remembered.   If  a  later  newline action would take the
385                     current cell to the right of the remembered column,  then
386                     the  current cell is instead moved to the first column of
387                     the next row.  If a newline action would take the current
388                     cell  below  the remembered row, then the current cell is
389                     instead moved to the top row of the next column.
390
391              C      Color.  This option enables color, and must be set before
392                     any other color options, such as colorneg (color negative
393                     numbers) or colorerr (color cells with errors), will have
394                     an  effect.   On a slow connection, turning off color can
395                     noticeably speed up screen updates.
396
397              E      Color cells with errors.  Setting this option will  cause
398                     all  cells  with  expressions  which evaluate to ERROR or
399                     INVALID to be set to color 3.  Color must be enabled  for
400                     this option to take effect.
401
402              N      Color  negative  numbers.   When  this option is set, all
403                     cells containing negative numbers will have  their  color
404                     number incremented by one.  Cells with color 8 will cycle
405                     back to color 1.  Color must be enabled for  this  option
406                     to take effect.
407
408              The  quick  numeric entry, newline action and set newline action
409              limits options can be combined to  allow  very  quick  entry  of
410              large  amounts  of  data.  If all the data to be entered is in a
411              single row or column then setting the quick  numeric  entry  and
412              the  appropriate  newline  action  will  allow the numbers to be
413              entered without any explicit commands to  position  the  current
414              cell or enter a number.
415
416              If  the data entry involves several entries in each row for many
417              rows, then setting the quick numeric entry option,  setting  the
418              newline  action  to  move right after each entry and setting the
419              newline action limits on the last column on which data should be
420              entered  will allow the data to entered quickly.  An alternative
421              to setting newline action limits is to  enclose  the  range  for
422              entry  in  a  frame (see "Framed Ranges" below), and setting the
423              autowrap option.  Setting autoinsert will  insert  new  rows  as
424              needed  if the frame includes data at the bottom.  If necessary,
425              columns which do not need data to be entered can be hidden  with
426              the  z  command.   Similar arrangements can be made for entering
427              several rows of data in each column.
428
429       S      Set options.  This command allows you to set various options.  A
430              small  menu  lists the options that cannot be changed through ^T
431              above.
432
433              byrows/bycols
434                     Specify the order cell evaluation when  updating.   These
435                     options  also  affect the order in which cells are filled
436                     (see rf) and whether a row or column is cleared by  an  x
437                     command.
438
439              iterations=n
440                     Set  the  maximum  number  of  recalculations  before the
441                     screen is displayed again.  Iterations is set  to  10  by
442                     default.
443
444              tblstyle=s
445                     Control  the  output  of  the  T  command.   s  can be: 0
446                     (default) to give colon delimited  fields,  with  no  tbl
447                     control  lines;  tbl to give colon delimited fields, with
448                     tbl(1) control lines; latex to give a LaTeX tabular envi‐
449                     ronment;  slatex  to  give  a SLaTeX (Scandinavian LaTeX)
450                     tabular environment; tex to  give  a  TeX  simple  tabbed
451                     alignment  with  ampersands  as  delimiters; and frame to
452                     give a tblstyle output for FrameMaker.
453
454              pagesize=n
455                     Set the page size for the PageUp, PageDown, J, and K com‐
456                     mands.   If  set  to 0, the default is to move up or down
457                     half the number of rows displayed on the  screen,  or  if
458                     the current cell is in a framed range, half the number of
459                     displayed rows in the scrolling region of that range.
460
461              Other Set options are normally used only in sc data files  since
462              they  are  available through ^T.  You can also use them interac‐
463              tively.
464
465              autocalc/!autocalc
466                     Set/clear auto recalculation mode.
467
468              autoinsert/!autoinsert
469                     Set/clear automatic insertion mode.
470
471              autowrap/!autowrap
472                     Set/clear autowrap mode.
473
474              optimize/!optimize
475                     Set/clear auto optimize mode.
476
477              numeric/!numeric
478                     Set/clear numeric mode.
479
480              prescale/!prescale
481                     Set/clear numeric prescale mode.
482
483              extfun/!extfun
484                     Enable/disable external functions.
485
486              toprow/!toprow
487                     Set/clear top row display mode.
488
489              rndtoeven/!rndtoeven
490                     Default: *.5 will be rounded  up  to  the  next  integer;
491                     doing  a  'set  rndtoeven' will cause it to be rounded to
492                     the closest even number instead (aka banker's  rounding).
493                     Round-to-even  has  advantages  over the default rounding
494                     for some applications.  For example, if X+Y is  an  inte‐
495                     ger, then X+Y = rnd(X)+rnd(Y) with round-to-even, but not
496                     always with the defaulting rounding method.   This  could
497                     be an advantage, for example, when trying to split an odd
498                     amount of money  evenly  between  two  people  (it  would
499                     determine  who  gets  the  extra penny).  Note: rndtoeven
500                     only effects the @rnd and @round functions.   It  has  no
501                     effect on how a number is rounded to fit the display for‐
502                     mat of a cell.
503
504              craction=n
505                     Set the newline action.  n can be: 0 (default) to give no
506                     action;  1  to  move  down after each entry; or 2 to move
507                     right after each entry.
508
509              rowlimit=n
510                     Set the remembered limit for the maximum row below  which
511                     the  current  cell  will  be moved to the top of the next
512                     column if the newline action is set to move  the  current
513                     cell  down.  n can be -1 (default) to disable this facil‐
514                     ity.
515
516              collimit=n
517                     Set the remembered limit for the maximum  column  to  the
518                     right of which the current cell will be moved to the left
519                     of the next row if the newline action is set to move  the
520                     current  cell  right.   n  can be -1 (default) to disable
521                     this facility.
522
523              color/!color
524                     Enable color.  This option must  be  set  for  any  other
525                     color  options,  such  as  colorneg  or colorerr, to take
526                     effect.  On a slow  connection,  turning  off  color  can
527                     noticeably speed up screen updates.
528
529              colorneg/!colorneg
530                     Color  negative  numbers.   When  this option is set, all
531                     cells containing negative numbers will have  their  color
532                     number  increased  by one.  Cells with color 8 will cycle
533                     back to color 1.  Color must be enabled for  this  option
534                     to take effect.
535
536              colorerr/!colorerr
537                     Color  cells with errors.  Setting this option will cause
538                     all cells with expressions which  evaluate  to  ERROR  or
539                     INVALID  to be set to color 3.  Color must be enabled for
540                     this option to take effect.
541
542              cslop/!cslop
543                     Enable color slop.  If a cell's  label  string  is  wider
544                     than  the  column  width, it will slop over into the next
545                     cell to the right if that cell  is  empty.   However,  if
546                     that  cell  is in a different color range than the first,
547                     this slop over will be disabled,  regardless  of  whether
548                     the  colors  assigned  to the two ranges are different or
549                     not.  If cslop is enabled, strings may slop over even  if
550                     the  next  cell  is  in a different color range, carrying
551                     their color with them, which may cause a ragged  boundary
552                     between  the ranges, but may allow the strings to be seen
553                     in their entirety.  Cslop is disabled by default.
554
555              The following Set options are considered  personal  preferences,
556              or are terminal dependent, and are therefore not saved when sav‐
557              ing a file, but are instead intended for use in a  user's  .scrc
558              file.
559
560              braille/!braille
561                     Set/clear   braille   enhancement   mode.   When  braille
562                     enhancement mode is set, the cursor behaves in  a  manner
563                     that makes the use of sc much easier when using a braille
564                     display.  In spite of its name, this mode also works well
565                     with screen readers such as SpeakUp, and can even be used
566                     by sighted users to make cutting and  pasting  using  the
567                     screen program much easier.
568
569                     There are actually two different braille modes.  When the
570                     braille option is set, the C command, which  is  normally
571                     used  to set colors, will instead change from one braille
572                     mode to the other.  If it is desired to set/change colors
573                     so  you  can  share files with others not using a braille
574                     display, braille mode will have to be switched off tempo‐
575                     rarily,  and then switched back on after the color opera‐
576                     tion is done.
577
578                     When the braille option is set, the default braille  mode
579                     will  cause  the cursor to be positioned at the left edge
580                     of the current cell, while  the  alternate  braille  mode
581                     will  cause  the  cursor to be placed at the beginning of
582                     the top line, which will contain information such as  the
583                     current  cell  address,  contents of the cell, and column
584                     formatting information.  The column names  will  also  be
585                     moved  to  the  left  edge of their respective columns in
586                     order to remain aligned with the cursor as  it  moves  up
587                     and down the column.
588
589                     In either mode, the cursor will be placed in the top line
590                     when editing a line, except when  switching  to  navigate
591                     mode,  in  which case the cursor will be placed in either
592                     the current cell (default braille  mode)  or  the  second
593                     line,  where  the  cell  address or default range will be
594                     displayed (alternate braille mode).
595
596                     Whenever a message is displayed on the second line,  such
597                     as  an  error  message or prompt for further information,
598                     both modes will cause the cursor  to  be  placed  at  the
599                     beginning of that message.  After this message goes away,
600                     the cursor will revert to its former behavior.  The easi‐
601                     est  way  to  make this message go away without effecting
602                     anything, except in the cases where it is asking the user
603                     for  more  information, is to press CC, which effectively
604                     changes modes twice, with a net effect of leaving  sc  in
605                     the original mode.
606
607              locale/!locale
608                     If  locale  support is compiled into sc, this option will
609                     cause certain locale-dependent  behaviors,  such  as  the
610                     display  of  numbers and the determination of word bound‐
611                     aries for some operations in edit  mode.   Note  that  if
612                     this option is set and the environment variable LC_ALL is
613                     unrecognized, unset, or set to either ``POSIX'' or ``C'',
614                     commas in format commands will be ignored.
615
616              cellcur/!cellcur
617                     Set/clear current cell highlighting mode.  This option is
618                     included here because it is likely to be terminal  depen‐
619                     dent and/or a user preference, and therefore is not saved
620                     when saving a file.
621
622              scrc   It tells sc to also read the file .scrc  in  the  current
623                     directory  when  starting.   Settings  in  this file will
624                     override those in $HOME/.scrc but may themselves be over‐
625                     ridden  by command line options.  Setting this could be a
626                     potential  security  risk,  since  starting  sc  with  an
627                     unknown  .scrc  could  potentially execute arbitrary com‐
628                     mands.  This  risk  is  probably  very  slight,  since  a
629                     spreadsheet  program  is not likely to be run in just any
630                     directory, and should never be run as root.
631
632   Cursor Control Commands
633
634       ^A     Go to cell A0 (same as HOME).
635
636       ^P     Move the cell cursor up to the previous row.
637
638       ^N     Move the cell cursor down to the next row.
639
640       ^H     Move the cell cursor backward one column.
641
642       SPACE  Move the cell cursor forward one column.  When in navigate mode,
643              if a range is highlighted, insert the highlighted range into the
644              command line, followed by a space, while remaining  in  navigate
645              mode.   This  is  useful when entering copy, move, or frame com‐
646              mands, for example, which accept more than one range argument.
647
648       h, j, k, l
649              These are alternate, vi-compatible cell cursor  controls  (left,
650              down, up, right).  Space is just like l (right).
651
652       H, J, K, L
653              These move the cursor by half pages (left, down, up, right).  If
654              pagesize is nonzero, up/down paging will be  by  pagesize  rows,
655              instead.
656
657       ^F, ^B Same as J and K above.
658
659       PAGE-DOWN PAGE-UP
660              Same as J and K above.
661
662       TAB    If  the  character  cursor is on the top line, TAB tries to com‐
663              plete a range name if the character immediately preceding it  is
664              alphanumeric  or  ``_'',  and starts a range if not (see below).
665              Otherwise, move the cell cursor forward one column.
666
667       HOME   Go to cell A0.
668
669       END    Same as ^E (see below).
670
671       Arrow Keys
672              The terminal's arrow keys provide another alternate set of  cell
673              cursor controls if they exist and are supported in the appropri‐
674              ate termcap entry.  Some terminals have arrow  keys  which  con‐
675              flict  with  other  control  key codes.  For example, a terminal
676              might send ^H when the back arrow  key  is  pressed.   In  these
677              cases,  the  conflicting arrow key performs the same function as
678              the key combination it mimics.
679
680       ^      Move the cell cursor up to row 0 of the current column.
681
682       #      Move the cell cursor down to the last valid row of  the  current
683              column.
684
685       0      Move  the  cell  cursor backward to column A of the current row.
686              This command must be prefixed with ^U  if  quick  numeric  entry
687              mode is enabled.
688
689       $      Move  the  cell  cursor  forward to the last valid column of the
690              current row.
691
692       b      Scan the cursor backward (left and up)  to  the  previous  valid
693              cell.
694
695       w      Scan the cursor forward (right and down) to the next valid cell.
696
697       g      Go  to  a cell.  sc prompts for a cell's name, a regular expres‐
698              sion surrounded by quotes, or a number.  If a cell's  name  such
699              as  ae122 or the name of a defined range is given, the cell cur‐
700              sor goes directly to that cell.  If a quoted regular  expression
701              such  as " Tax Table " or " ^Jan [0-9]*$ " is given, sc searches
702              for a cell containing a string matching the regular  expression.
703              See  regex(3)  or  ed(1) for more details on the form of regular
704              expressions.
705
706              You can also search formatted numbers or expressions using regu‐
707              lar  expressions  by preceding the opening quotes of the regular
708              expression with a ``#'' (for formatted numbers) or a ``%''  (for
709              expressions).   These are handy for searching for dates within a
710              specified range or cells which reference a given cell, for exam‐
711              ple,  although  they  are somewhat slower than searching through
712              ordinary strings, since all numbers must be formatted or expres‐
713              sions decompiled on the fly during the search.
714
715              If  a number is given, sc will search for a cell containing that
716              number.  Searches for either strings or numbers proceed  forward
717              from the current cell, wrapping back to a0 at the end of the ta‐
718              ble, and terminate at the current cell if the string  or  number
719              is  not  found.  You may also go to a cell with an ERROR (divide
720              by zero, etc. in this cell) or INVALID (references a  cell  con‐
721              taining  an  ERROR).   g error  will take you to the next ERROR,
722              while g invalid take you to the next INVALID.  The last  g  com‐
723              mand  is saved, and can be re-issued by entering g<return>.  You
724              can also repeat the last search by pressing n.
725
726              An optional second argument is available whose  meaning  depends
727              on  whether you're doing a search or jumping to a specific cell.
728              When doing a search, the second argument specifies  a  range  to
729              search.   When  jumping  to a specific cell, the second argument
730              specifies which cell should be in the upper lefthand  corner  of
731              the screen, if possible, which allows you to position the desti‐
732              nation cell where you want it on the screen.
733
734       ^Ed    Go to end of range.  Follow ^E by a direction indicator such  as
735              ^P or j.  If the cell cursor starts on a non-blank cell, it goes
736              in the indicated direction until  the  last  non-blank  adjacent
737              cell.  If the cell cursor starts on a blank cell, it goes in the
738              indicated direction until the first non-blank cell.   This  com‐
739              mand  is  useful  when  specifying ranges of adjacent cells (see
740              below), especially when the range is  bigger  than  the  visible
741              window.
742
743              If  ^E is pressed twice in succession, or if it is pressed after
744              another ^E or a ^Y, it will cause the screen to scroll up  with‐
745              out moving the cell cursor, unless the cell cursor is already at
746              the top of the screen, in which case, it will remain at the  top
747              of the visible screen.
748
749       ^Y     Causes the screen to scroll down without moving the cell cursor,
750              unless the cell cursor is already at the bottom of  the  screen,
751              in  which  case,  it  will  remain  at the bottom of the visible
752              screen.
753
754       mx     Mark the current cell.  sc will prompt for a lowercase letter to
755              be  used  as  a mark specifier.  Marked cells may be used as the
756              source for the c (copy a marked cell) command, or as the  target
757              of  a  ` or ' (go to marked cell) command.  In addition to cells
758              marked with lowercase letters, sc also automatically  marks  the
759              last  nine cells that have been edited with the numbers 1-9, and
760              the current cell being edited with the number 0.  When not edit‐
761              ing a cell, marks 0 and 1 usually refer to the same cell, unless
762              the last edit was begun in one cell, but the  cell  address  was
763              changed  before  pressing  the  RETURN key, or the last edit was
764              aborted prematurely.
765
766       `x     Jump to a previously marked cell.  If the target  cell  is  cur‐
767              rently  on  the  screen, sc will simply jump to the target cell,
768              making it current.  Otherwise, sc will  attempt  to  center  the
769              cell  on  the screen, if possible.  As a special case, following
770              the ` with another ` will return you to the  cell  you  were  in
771              before  the last g, ', `, *, or ^E (or END key) was used to jump
772              to another cell.
773
774       'x     Jump to a previously marked cell.  ' works just like ` ,  except
775              that ' will attempt to restore the marked cell to the same posi‐
776              tion on the screen as when it  was  marked.   It  does  this  by
777              remembering  which cell was in the upper left hand corner of the
778              screen at the time the mark was set, and restoring that cell  to
779              its  original position.  As a special case, following the ' with
780              another ' will return you to the cell you  were  in  before  the
781              last  g, ', `, *, or ^E (or END key) was used to jump to another
782              cell, and will also try to position that cell on the  screen  in
783              the same position as when you left it.
784
785       z<RETURN>
786              Move  the  current row to the top of the screen.  If the current
787              row is in a framed range, move the current row to the top of the
788              scrolling region.
789
790       z.     Move the current row to the center of the screen.
791
792       z|     Move the current column to the center of the screen.
793
794       zc     Center the current cell both horizontally and vertically.
795
796   Cell Entry and Editing Commands
797       Cells  can  contain  both  a  numeric value and a string value.  Either
798       value can be the result of an expression, but not both  at  once,  i.e.
799       each  cell can have only one expression associated with it.  Entering a
800       valid numeric expression alters the cell's previous numeric  value,  if
801       any,  and replaces the cell's previous string expression, if any, leav‐
802       ing only the previously  computed  constant  label  string.   Likewise,
803       entering a valid string expression alters the cell's the previous label
804       string, if any, and replaces the cell's previous numeric expression, if
805       any, leaving only the previously computed constant numeric value.
806
807       =      Enter  a  numeric  constant or expression into the current cell.
808              sc prompts for the expression on the top line.  The usual way to
809              enter a number into a cell is to type ``='', then enter the num‐
810              ber in response to the  prompt  on  the  top  line.   The  quick
811              numeric  entry  option, enabled through the -n option or ^T com‐
812              mand, shows the prompt when you enter the first digit of a  num‐
813              ber  (you can skip typing ``='').  If you want to begin entering
814              an expression in the current cell, but you want to start out  in
815              navigate  mode  (e.g. to enter cell addresses, or sums of ranges
816              using ``@sum''), use the ``+'' command instead (see below).
817
818       <      Enter a label string into the current cell to  be  flushed  left
819              against the left edge of the cell.
820
821       \      Enter a label string into the current cell to be centered in the
822              column.
823
824       >      Enter a label string into the current cell to be  flushed  right
825              against the right edge of the cell.
826
827       {      Left justify the string in the current cell.
828
829       |      Center the string in the current cell.
830
831       }      Right justify the string in the current cell.
832
833       F      Enter a format string into the current cell.  This format string
834              overrides the precision specified with the f command unless & is
835              present in the fractional part of the format string (see below).
836              The format only applies to numeric values.  There are two  types
837              of  format  strings  allowed: standard numeric and date.  (Note:
838              these format strings may also be used with the f command to cre‐
839              ate user-defined format types.)  The following characters can be
840              used to build a standard numeric format string:
841
842              #      Digit placeholder.  If the number  has  fewer  digits  on
843                     either side of the decimal point than there are `#' char‐
844                     acters in  the  format,  the  extra  `#'  characters  are
845                     ignored.   The  number  is rounded to the number of digit
846                     placeholders as there are to the  right  of  the  decimal
847                     point.  If there are more digits in the number than there
848                     are digit placeholders on the left side  of  the  decimal
849                     point, then those digits are displayed.
850
851              0      Digit  placeholder.  Same as for `#' except that the num‐
852                     ber is padded with zeroes on either side of  the  decimal
853                     point.   The  number  of zeroes used in padding is deter‐
854                     mined by the number of digit placeholders after  the  `0'
855                     for  digits  on the left side of the decimal point and by
856                     the number of digit placeholders before the `0' for  dig‐
857                     its on the right side of the decimal point.
858
859              .      Decimal  point.  Determines how many digits are placed on
860                     the right and left sides of the decimal point in the num‐
861                     ber.   If locale is set, the decimal point for the user's
862                     current locale will be used  when  formatting  a  number.
863                     Note  that numbers smaller than 1 will begin with a deci‐
864                     mal point if the left side of the decimal point  contains
865                     only  a  `#' digit placeholder.  Use a `0' placeholder to
866                     get a leading zero in decimal formats.
867
868              %      Percentage.  For each `%' character in  the  format,  the
869                     actual  number  gets multiplied by 100 (only for purposes
870                     of formatting -- the original number is left  unmodified)
871                     and  the  `%' character is placed in the same position as
872                     it is in the format.
873
874              ,      Thousands separator.  The presence of a `,' in the format
875                     (multiple  commas are treated as one) will cause the num‐
876                     ber to be formatted with a `,'  separating  each  set  of
877                     three  digits in the integer part of the number with num‐
878                     bering beginning from the right end of the  integer.   If
879                     locale  is  set,  the  thousands separator for the user's
880                     current locale will be used in place of  the  comma.   If
881                     the  environment  variable LC_ALL is unset, unrecognized,
882                     or is set to ``POSIX'' or ``C'',  any commas in the  for‐
883                     mat string will be ignored.
884
885              &      Precision.   When  this character is present in the frac‐
886                     tional part of the number, it is equivalent to  a  number
887                     of  0's  equal  to  the precision specified in the column
888                     format command.  For example, if the precision is 3,  `&'
889                     is equivalent to `000'.
890
891              \      Quote.   This  character  causes the next character to be
892                     inserted into the formatted string directly with no  spe‐
893                     cial interpretation.
894
895              E- E+ e- e+
896                     Scientific  format.  Causes the number to be formatted in
897                     scientific notation.  The case of the `E' or `e' given is
898                     preserved.   If  the  format uses a `+', then the sign is
899                     always given for the exponent value.  If the format  uses
900                     a  `-',  then  the  sign  is only given when the exponent
901                     value is negative.  Note that if there is no digit place‐
902                     holder  following  the  `+' or `-', then that part of the
903                     formatted number is left out.  In general,  there  should
904                     be one or more digit placeholders after the `+' or `-'.
905
906              ;      Format selector.  Use this character to separate the for‐
907                     mat into two distinct formats.  The format to the left of
908                     the  `;'  character  will  be used if the number given is
909                     zero or positive.  The format to the  right  of  the  `;'
910                     character is used if the number given is negative.
911
912              Some  example  formats  are  integer  (``0''  or  ``#''),  fixed
913              (``0.00''),  percentage  (``0%''   or   ``0.00%''),   scientific
914              (``0.00E+00''), and currency (``$#,0.00;($#,0.00)'').
915
916              Date  format  strings  are identified by the presence of a ^D in
917              the first postition.  If this is present, the remainder  of  the
918              string  is passed to the strftime() function, and therefore uses
919              the same conversion specifiers as strftime().  For more informa‐
920              tion  on  conversion specifiers for date format strings, see the
921              man page for strftime(3).
922
923       Strings you enter must start with ".  You can leave off the trailing  "
924       and  sc will add it for you.  You can also enter a string expression by
925       backspacing over the opening " in the prompt.
926
927       e      Edit the value associated with the current cell.  This is  iden‐
928              tical  to ``='' except that the command line starts out contain‐
929              ing the old numeric value  or  expression  associated  with  the
930              cell.  The editing in this mode is vi-like.
931
932              ^H     Move back a character
933
934              ^V, v  Enter  navigate  mode.   This mode allows you to navigate
935                     the spreadsheet while editing a command.  When  in  navi‐
936                     gate mode, v will insert the numeric value of the current
937                     cell, if any, into the command line,  instead,  while  ^V
938                     will return to the previous mode (like the ESCAPE key).
939
940              ^W     Insert  the  expression attached to the current cell into
941                     the command line.  If there is none, the result is ``?''.
942                     This only works while in navigate mode.
943
944              ^A     In  navigate  mode,  go to cell A0.  When not in navigate
945                     mode, jump to the beginning of the line instead.
946
947              ^E     Jump to the end of the line.  Unlike ``$'' (below),  this
948                     can also be used from insert mode.
949
950              TAB    If  the  character  immediately  preceding  the cursor is
951                     alphanumeric or ``_'', TAB tries to find a match  in  the
952                     list  of  range names, and if one is found, the name will
953                     be completed on the command line.  If there are  multiple
954                     matches, pressing TAB repeatedly without any other inter‐
955                     vening keys will cycle through all of the valid  matches.
956                     If  the character immediately preceding the cursor is not
957                     alphanumeric or ``_'', TAB defines a range of  cells  via
958                     the  cursor control commands or the arrow keys.  Pressing
959                     TAB automatically switches sc to  navigate  mode  if  you
960                     haven't  already  done  so  using the ^V command, and the
961                     range is highlighted, starting  at  the  cell  where  you
962                     typed  TAB,  and  continuing  through  the  current cell.
963                     Pressing TAB again causes the  highlighted  range  to  be
964                     inserted  into  the  command line, the highlighting to be
965                     turned off, and the previous mode to be  restored.   This
966                     is  most  useful for defining ranges to functions such as
967                     @sum().  Pressing ``)'' acts just like typing the TAB key
968                     the  second  time  and adds the closing ``)''.  Note that
969                     when you give a range command, if the first  argument  to
970                     the command is a range, you don't need to press the first
971                     TAB to begin defining a range starting with  the  current
972                     cell.
973
974              :      Synonym for TAB, when in navigate mode.
975
976              ` '    In navigate mode, go to marked cell.
977
978              *      In navigate mode, go to note linked to current cell.
979
980              +      Forward through history (same as j)
981
982              -      Backward through history (same as k)
983
984              ESC    Done editing
985
986              CR     Save.  When in navigate mode, insert the name of the cur‐
987                     rent cell (the one at the cell cursor) into  the  command
988                     line.   This  is  useful  when entering expressions which
989                     refer to other cells in the table.
990
991              $      Goto last column
992
993              %      Goto matching parenthesis
994
995              .      Insert current dot buffer.  When in navigate  mode,  this
996                     is a synonym for : or TAB.
997
998              ;      Repeat the last f, F, t, or T command.
999
1000              ,      Repeat the last f, F, t, or T command, but in the reverse
1001                     direction.
1002
1003              ~      Change the case of the character under the cursor.
1004
1005              /      Search backwards for a string in the history
1006                     ESC  edit the string you typed
1007                     CR   search
1008                     ^H   backspace
1009
1010              ?      Search forward for a string in  the  history  (see  ``/''
1011                     above)
1012
1013              0      Goto column 0
1014
1015              B      Move  back a word.  Like b, except words are space delim‐
1016                     ited only.
1017
1018              C      Change to end of line (delete first,  then  enter  insert
1019                     mode)
1020
1021              D      Delete to end of line
1022
1023              F      Find the next char typed, moving backwards in the line
1024
1025              G      Go  to  the  end of history, i.e., to the line being cur‐
1026                     rently entered
1027
1028              I      Insert at column 0; ESC revert back to edit mode
1029
1030              N      Repeat the last search in the opposite direction
1031
1032              P      Insert the most recently deleted text before the cursor
1033
1034              R      Replace mode; ESC revert back to edit mode
1035
1036              T      Goto a char, moving backwards in the line
1037
1038              W      Forward a word.  Like w, except words are space delimited
1039                     only.
1040
1041              X      Delete the char to the left
1042
1043              a      Append after cursor; ESC revert back to edit mode
1044
1045              b      Move back a word
1046
1047              c      Change  mode;  ESC revert back to edit mode.  In navigate
1048                     mode, insert color range which includes the current cell.
1049
1050              d      Delete ...
1051                     0    delete to beginning of line
1052                     $    delete to end of line
1053                     b    back word
1054                     e    delete to end of word
1055                     f    forward (right)
1056                     h    back char
1057                     l    forward
1058                     t    delete forward up to a given char (next char typed)
1059                     w    delete next word forward
1060
1061              e      Forward to next end-of-word
1062
1063              f      Find the next char typed.  In navigate mode,  insert  the
1064                     outer frame range which includes the current cell.
1065
1066              g      In  navigate  mode, allows you to `goto' a cell or range,
1067                     just like the regular goto  command.   Ignored  in  edit,
1068                     insert or replace modes.
1069
1070              h      Move left a char
1071
1072              i      Insert before cursor; ESC revert back to edit mode
1073
1074              j      Forward through history (same as +)
1075
1076              k      Backward through history (same as -)
1077
1078              l      Move right a char
1079
1080              n      Repeat the last search (find the next match)
1081
1082              o      When  highlighting  a range in navigate mode, move to the
1083                     opposite corner of the highlighted range.
1084
1085              p      Insert the most recently deleted text after the cursor
1086
1087              q      Stop editing
1088
1089              r      Replace char.  In navigate mode, insert the  inner  frame
1090                     range which includes the current cell.
1091
1092              s      Delete  current  char  and  enter insert mode (stands for
1093                     substitute)
1094
1095              t      Goto a char
1096
1097              u      Undo
1098
1099              w      Forward a word
1100
1101              x      Delete the current char (moving to the right)
1102
1103              y      Copies to the delete buffer without deleting.  Use like d
1104                     (above).
1105
1106       E      Edit the string associated with the current cell.  This is iden‐
1107              tical to ``<'', ``\'', or ``>'' except  that  the  command  line
1108              starts out containing the old string value or expression associ‐
1109              ated with the cell.  SEE e ABOVE.
1110
1111       To enter and edit a cell's number part, use the  ``='',  ``+'',  and  e
1112       commands.   To  enter  and  edit  a  cell's string part, use the ``<'',
1113       ``\'', ``>'', and E commands.  See the sections below  on  numeric  and
1114       string expressions for more information.
1115
1116       Note  that  the  descriptions of the ``+'' and ``-'' commands below may
1117       seem very confusing at first, but once  they're  understood,  they  can
1118       facilitate  the rapid entry of expressions which add and subtract large
1119       numbers of cells and sums of ranges of cells, so read them  over  care‐
1120       fully several times until you understand them.
1121
1122       "      Specify  a  named  buffer for the next yank/delete/pull command.
1123              Buffers are  named  with  a  single  character.   Buffers  ``a''
1124              through ``z'' are general purpose buffers, buffers ``1'' through
1125              ``9'' hold the last nine deletions, with buffer ``1'' being  the
1126              most  recent,  and  buffer  ``0''  holds  the last cell or range
1127              yanked.  Buffer ``"'' is the default  buffer,  which  holds  the
1128              last cell or range that was deleted or yanked.
1129
1130       x      Clear  the  current  cell.   Deletes  the  numeric  value, label
1131              string, and/or numeric or string  expression.   You  can  prefix
1132              this  command with a count of the number of cells on the current
1133              row to clear.  The current column is used if  column  recalcula‐
1134              tion  order  is  set.   Cells  cleared  with this command may be
1135              recalled with any of the pull commands (see below).
1136
1137       mx     Mark the current cell.  sc will prompt for a lowercase letter to
1138              be  used  as  a mark specifier.  Marked cells may be used as the
1139              source for the copy command, or as the target of a ` or ' (go to
1140              marked cell) command.
1141
1142       cx     Copy a marked cell to the current cell, adjusting row and column
1143              references in its numeric or string expression, if any.  sc will
1144              prompt  for  the  name  of the cell to be copied, which may be a
1145              lowercase letter specified previously  with  the  m  command,  a
1146              digit 1-9 to reference one of the last nine edited cells (0 will
1147              reference the last cell in which an edit was  begun,  regardless
1148              of  whether  the edit was completed or not), or ``.''  to refer‐
1149              ence the current cell, which, as a special case, is to  be  used
1150              as  a source rather than a destination, and is to be copied into
1151              a range which includes the current cell.  When ``.''  is  speci‐
1152              fied,  the  current  cell is set as the default source range for
1153              the range copy (rc)  command,  and  then  the  copy  command  is
1154              entered  into the command line and sc switches to navigate mode.
1155              Moving the cell  cursor  will  then  highlight  the  destination
1156              range.   After the desired range is highlighted, press RETURN to
1157              execute the copy.
1158
1159       +      If not  in  numeric  mode,  add  the  current  numeric  argument
1160              (default 1) to the value of the current cell.  The current value
1161              of the cell must not be  an  expression.   In  numeric  mode,  +
1162              switches  to  insert  mode  and  appends  a ``+'' to the current
1163              expression or value, if any, which  makes  it  easy  to  add  to
1164              existing data.
1165
1166              In  navigate  mode,  + inserts the current cell address into the
1167              line, followed by another +, and sc remains  in  navigate  mode,
1168              unless  a  range  is highlighted.  If a range is highlighted and
1169              the character immediately preceding the cursor  is  a  ``+''  or
1170              ``-'',  or  the  cursor  is at the beginning of an empty ``let''
1171              expression, the string ``@sum('' will be inserted,  followed  by
1172              the  highlighted range, followed by ``)+''.  If a range is high‐
1173              lighted and the character immediately preceding  the  cursor  is
1174              not  a ``+'' or ``-'', and the cursor is not at the beginning of
1175              an empty ``let''  expression,  the  highlighted  range  will  be
1176              inserted, followed by  ``)+''.
1177
1178       -      If  not  in  numeric mode, subtract the current numeric argument
1179              (default 1) from the value of the  current  cell.   The  current
1180              value of the cell must not be an expression.  In numeric mode, -
1181              switches to insert mode and  appends  a  ``-''  to  the  current
1182              expression  or  value,  if  any, which makes it easy to subtract
1183              from existing data.
1184
1185              In navigate mode, - inserts the current cell  address  into  the
1186              line,  followed  by  another -, and sc remains in navigate mode,
1187              unless a range is highlighted.  If a range  if  highlighted  and
1188              the  character  immediately  preceding  the cursor is a ``+'' or
1189              ``-'', or the cursor is at the beginning  of  an  empty  ``let''
1190              expression,  the  string ``@sum('' will be inserted, followed by
1191              the highlighted range, followed by ``)-''.  If a range is  high‐
1192              lighted  and  the  character immediately preceding the cursor is
1193              not a ``+'' or ``-'', and the cursor is not at the beginning  of
1194              an  empty  ``let''  expression,  the  highlighted  range will be
1195              inserted, followed by  ``)-''.
1196
1197       RETURN If you are not editing a cell  (top  line  is  empty),  pressing
1198              RETURN  will  make  sc enter insert mode.  At this point you may
1199              type any valid command or press ESC once to edit.
1200
1201   File Commands
1202
1203       G      Get a new database from a file.  If encryption is  enabled,  the
1204              file is decrypted before it is loaded into the spreadsheet.
1205
1206       P      Put the current database into a file.  If encryption is enabled,
1207              the file is encrypted before it is saved.
1208
1209       ZZ     Save the current database into a file if it has  been  modified,
1210              and  then  quit.   This  is like the P command followed by the q
1211              command, except that the default filename will be  used  instead
1212              of  prompting you for one, and the file will only be saved if it
1213              was modified.  If there is no default filename, an error message
1214              will be displayed, and no action taken.
1215
1216       W      Write  a  listing  of the current database into a file in a form
1217              that matches its appearance on the screen.   This  differs  from
1218              the  Put  command  in that its files are intended to be reloaded
1219              with Get, while Write produces a file for  people  to  look  at.
1220              Hidden rows or columns are not shown when the data is printed.
1221
1222       T      Write  a  listing of the current database to a file, but include
1223              delimiters suitable for processing by the tbl, LaTeX, or TeX ta‐
1224              ble  processors.   The delimiters are controlled by the tblstyle
1225              option.  See Set above.  The  delimiters  are  a  colon (:)  for
1226              style 0 or tbl and an ampersand (&) for style latex or tex.
1227
1228       With  the  Put,  Write, and Table commands, the optional range argument
1229       writes a subset of the spreadsheet to the output file.
1230
1231       With the Write and Table commands, if you try to write to the last file
1232       used with the Get or Put commands, or the file specified on the command
1233       line when sc was invoked, you are asked to  confirm  that  the  (poten‐
1234       tially) dangerous operation is really what you want.
1235
1236       The three output commands, Put, Write, and Table, can pipe their (unen‐
1237       crypted only) output to a program.  To use this feature, enter ``| pro‐
1238       gram''  to  the prompt asking for a filename.  For example, to redirect
1239       the output of the Write command to the printer, you might enter ``| lpr
1240       -p''.
1241
1242       M      Merge  the  database  from the named file into the current data‐
1243              base.  Values and expressions defined in the named file are read
1244              into the current spreadsheet overwriting the existing entries at
1245              matching cell locations.
1246
1247       R      Run macros.  There are two different kinds of macros that can be
1248              used  with  sc:  simple  macros,  which are stored in plain text
1249              files, and advanced macros,  which  are  executable  files,  and
1250              which  can  be written in the language of your choice.  Advanced
1251              macros are only available on systems that support pipes.
1252
1253              Simple macros are interpreted by sc's internal parser,  and  use
1254              the  same  commands  used to enter data and perform other opera‐
1255              tions (the single key commands are  shortcuts  which  switch  to
1256              input  mode  after first entering the beginning of the full com‐
1257              mand for you).  These are also the same  commands  found  in  sc
1258              files created with the Put command.  Since sc files are saved as
1259              ASCII files, it is possible to use them as primitive macro defi‐
1260              nition files.  The Run command makes this easier.  It's like the
1261              Merge command, but prints a saved path name as the start of  the
1262              filename  to merge in.  The string to use is set with the Define
1263              command.  To write macros, you must be familiar  with  the  file
1264              format written by the Put command.
1265
1266              Advanced macros use executable files that are started by sc as a
1267              child process with stdin and stdout redirected back  to  sc  for
1268              bidirectional communication.  Special commands are available for
1269              requesting information such as cell contents, formatting  infor‐
1270              mation,  or  the  current location of the cell cursor.  Commands
1271              are written to stdout, and responses are read  from  stdin.   To
1272              use  advanced  macros, the filename must be preceded by a | (the
1273              pipe symbol), and the file must be executable.  If the  pathname
1274              set  with  the Define command begins with a |, all files in that
1275              path will be executed as advanced macros.  It is  also  possible
1276              to  include  a  filename as part of the path when using advanced
1277              macros, which allows you to put  multiple  macros  in  a  single
1278              file,  and  use the Run command to add command line arguments or
1279              options to determine which macro should be run.  Advanced macros
1280              are relatively new, and documentation is still incomplete.  This
1281              feature will probably be enhanced in future releases.
1282
1283       A      Specify a macro to be automatically  run  whenever  the  current
1284              sheet is reloaded from a file.
1285
1286       D      Define a path for the Run command to use (see above).
1287
1288       All file operations take a filename as the first argument to the prompt
1289       on the top line.  The prompt supplies a " to aid in typing in the file‐
1290       name.   The filename can also be obtained from a cell's label string or
1291       string expression.  In  this  case,  delete  the  leading  "  with  the
1292       backspace  key  and  enter  a  cell  name  such as a22 instead.  If the
1293       resulting string starts with ``|'', the rest of the  string  is  inter‐
1294       preted as a UNIX command, as above.
1295
1296   Row and Column Commands
1297       These  are two-letter commands which can be used on either rows or col‐
1298       umns.  The exceptions are the f command, which only works  on  columns,
1299       and therefore doesn't require a second letter, and the p command which,
1300       in addition to operating on rows or columns, has several other  options
1301       for  merging the data in directly, without opening up a new row or col‐
1302       umn.  There are also a few special cases where pressing the same letter
1303       twice  will  affect  only  the  current cell instead of a row or column
1304       (except for ZZ, which is a special case all its own).
1305
1306       In all of the remaining cases, the second letter of the command will be
1307       either  r  or c, depending on whether the operation should be performed
1308       on rows or columns, respectively (additional options for the p  command
1309       and  the double letter cases are listed below).  A small menu lists the
1310       choices for the second letter when you type the first letter of one  of
1311       these commands.
1312
1313       Alternatively,  you may define a range of rows or columns by moving the
1314       cell cursor, either a cell at a time, or by pages (roughly 1/2  screen,
1315       unless  the  pagesize option has been set), but this only works for the
1316       d, y, and Z commands.  Vertical cursor movement will begin highlighting
1317       rows,  and  horizontal  movement  will highlight columns.  Pressing the
1318       RETURN key will then perform the  chosen  operation  on  the  specified
1319       rows/columns.
1320
1321       Commands  which copy cells also modify the row and column references in
1322       affected cell expressions.  The references may be frozen by  using  the
1323       @fixed  operator  or using the $ character in the reference to the cell
1324       (see below).  Commands which create new rows or  columns  will  include
1325       all  newly  created  cells in the same ranges (named, framed, color, or
1326       those used in expressions) as their counterparts in the current row  or
1327       column.   This  can  sometimes  be  a  significant factor when deciding
1328       whether to use ir/ic or or/oc.
1329
1330       ir, ic Insert a new row (column) by moving the row (column)  containing
1331              the  cell cursor, and all following rows (columns), down (right)
1332              one row (column).  The new row  (column)  is  empty.   Inserting
1333              rows while the cell cursor is in a framed range will only effect
1334              rows in that range, leaving all  rows  to  the  left  and  right
1335              untouched.
1336
1337       or, oc Open a new row (column).  These commands work like the ir and ic
1338              commands, except that the new  row  (column)  will  be  inserted
1339              after the current row (column) instead of before it.
1340
1341       ar, ac Append  a new row (column) immediately following the current row
1342              (column).  It is initialized as  a  copy  of  the  current  one.
1343              Appending  rows  while the cell cursor is in a framed range will
1344              only effect rows in that range, leaving all rows to the left and
1345              right untouched.
1346
1347       dr, dc, dd
1348              Delete  the  current  row (column).  dd deletes the current cell
1349              (i.e., it is a synonym for x).  Deleting  rows  while  the  cell
1350              cursor is in a framed range will only effect rows in that range,
1351              leaving all rows to the left and right untouched.
1352
1353       yr, yc, yy
1354              Yank a copy of the current row (column) into the  delete  buffer
1355              without  actually deleting it.  yy yanks the current cell (simi‐
1356              lar to x, but without actually  deleting  the  contents  of  the
1357              cell).   Yanking rows while the cell cursor is in a framed range
1358              will only copy the portion of each row contained in that  range,
1359              while ignoring everything outside the range.
1360
1361       pr, pc, pp, pm, px, pt, pC, p.
1362              Pull  deleted rows/columns/cells back into the spreadsheet.  The
1363              last set of cells that was deleted or yanked is  put  back  into
1364              the spreadsheet at the current location.  pr inserts enough rows
1365              to hold the data.  pc inserts enough columns to hold  the  data.
1366              pp  (paste)  does  not insert rows or columns; it overwrites the
1367              cells beginning at the current cell cursor location.  pm (merge)
1368              merges  the  cells  in  at the current cell cursor location, but
1369              does not erase the destination range first like pp.  The differ‐
1370              ence  between pp and pm is similar to the difference between the
1371              Get and Merge commands.  pf (format) works like pm  except  that
1372              only  cell  formatting  information  is  merged  in, leaving the
1373              actual data untouched.  This makes it easy to copy cell  formats
1374              from  one  part  of  the  spreadsheet  to  another, such as when
1375              expanding an existing spreadsheet file.   px  (exchange)  copies
1376              the  contents  of  the delete buffer into the range beginning at
1377              the current cell cursor location, while  simultaneously  copying
1378              the  contents of this range back into the delete buffer, replac‐
1379              ing its current contents.  pt (transpose) overwrites  the  cells
1380              beginning  at  the  current  cell  cursor  location like pp, but
1381              transposes rows for columns and vice  versa.   pC  (copy)  works
1382              like  pp,  except  that  all cell references are adjusted in the
1383              same way that they are for the copy command.  p.  is the same as
1384              pC,  except  that it switches to navigate mode and allows you to
1385              define the destination range to be used.  This  works  like  the
1386              copy  command  in  that if the source range (the contents of the
1387              delete buffer) is a single row, column, or cell, multiple copies
1388              may be made.
1389
1390       vr, vc, vv
1391              Remove  expressions  from  the  affected rows (columns), leaving
1392              only the values which were in the cells before the  command  was
1393              executed.  When used in a framed range, vr only affects the por‐
1394              tion of the the row inside the range, leaving the  rest  of  the
1395              row  unchanged.   vv  only  affects  the contents of the current
1396              cell.
1397
1398       Zr, Zc, ZZ
1399              Hide (``zap'') the current row (column).  This keeps a row (col‐
1400              umn)  from  being  displayed but keeps it in the data base.  The
1401              status of the rows and columns is saved with the  data  base  so
1402              hidden rows and columns will still be hidden when you reload the
1403              spreadsheet.  Hidden rows or columns are not printed  by  the  W
1404              command.   The  ZZ  command is a special case.  It does not hide
1405              anything.  Instead, the file will be saved, if modified, and  sc
1406              will exit.  See ZZ above, under File Commands.
1407
1408       sr, sc Show  hidden rows (columns).  Enter a range of rows (columns) to
1409              be revealed.  The default is the first range of  rows  (columns)
1410              currently  hidden.   This  command  ignores the repeat count, if
1411              any.
1412
1413       f      Set the output format to be used for printing the numeric values
1414              in  each  cell  in  the current column.  This command has only a
1415              column version (no second letter).  You may  change  the  column
1416              width  by pressing the h, <, or cursor left key to reduce it, or
1417              the l, >, or cursor right key to increase it.  Likewise, you may
1418              change  the  precision  (the  number of digits to follow decimal
1419              points) by pressing the j, -, or cursor down key to  reduce  it,
1420              or  the  k,  +,  or  cursor up key to increase it.  You may also
1421              change the format type for the column by pressing any digit.  If
1422              the  f  command is preceded by a numeric argument, that argument
1423              will determine how many columns  should  be  changed,  beginning
1424              with  the  current  column,  and  in the case of incrementing or
1425              decrementing the width or precision of the columns, each  column
1426              will be incremented or decremented separately, regardless of its
1427              initial values.  Several formatting operations may be  performed
1428              in sequence.  To leave the formatting command, simply press ESC,
1429              ^G, q, or RETURN .
1430
1431              Alternatively, you may press SPACE to get the format command  in
1432              the  top  line  and  enter all three values directly.  In order,
1433              these are: the total width in characters of the column, the pre‐
1434              cision,  and  the  format  type.   Format  types are 0 for fixed
1435              point, 1 for scientific notation, 2 for engineering notation,  3
1436              for  dates  with  a  two digit year, and 4 for dates with a four
1437              digit year.  Values are rounded off  to  the  least  significant
1438              digit  displayed.   The  total  column width affects displays of
1439              strings as well as numbers.  A preceding count can  be  used  to
1440              affect more than one column.
1441
1442              You  can  also  create your own format types by pressing = after
1443              the f command, followed by any digit (see the  F  command  above
1444              under  Cell  Entry and Editing Commands for a description of how
1445              to build a format string).  Format  numbers  0  through  4  will
1446              supersede  the  built-in format types, while numbers 5 through 9
1447              will supplement them.  User defined format types may be used  in
1448              the same way as the built-in types.  For example, the command
1449
1450                     format 5 = "#,0.& ;(#,0.&)"
1451
1452              will define a currency format which may then be assigned to col‐
1453              umn C, for example, with the command
1454
1455                     format C 10 2 5
1456
1457       @myrow, @mycol
1458              Are functions that return the row or column of the current  cell
1459              respectively.   ex: The cell directly above a cell in the D col‐
1460              umn could then be accessed by @nval("d",@myrow-1).  NOTE: @myrow
1461              and @mycol can't be used in specifying ranges.
1462
1463       @lastrow, @lastcol
1464              These return the last row and column of the spreadsheet, respec‐
1465              tively.  They are useful for macros designed to default  to  the
1466              whole spreadsheet.
1467
1468   Range Commands
1469       Range  operations  affect a rectangular region on the screen defined by
1470       the upper left and lower right cells in the region.  All  of  the  com‐
1471       mands  in this class begin with ``r''; the second letter of the command
1472       indicates which command.  A small menu lists the choices for the second
1473       letter  when you type ``r''.  sc prompts for needed parameters for each
1474       command.  Phrases surrounded by  square  brackets  in  the  prompt  are
1475       informational only and may be erased with the backspace key.
1476
1477       Prompts  requesting  variable  names  may  be  satisfied with either an
1478       explicit variable name, such as A10, or with a variable name previously
1479       defined in a rd command (see below).  Range name prompts require either
1480       an explicit range such as A10:B20, or a range name  previously  defined
1481       with a rd command.  A default range shown in the second line is used if
1482       you omit the range from the command or press the TAB key  (see  below).
1483       The default range can be changed by moving the cell cursor via the con‐
1484       trol commands (^P or ^N) or the arrow keys.  The cells in  the  default
1485       range  are  highlighted  (using the terminal's standout mode, if avail‐
1486       able).
1487
1488       rx     Clear a range.  Cells cleared with this command will be saved in
1489              the delete buffer, and may be recalled with any of the pull com‐
1490              mands.
1491
1492       ry     Yank a range.  Like rx, cells yanked with this command  will  be
1493              saved  in the delete buffer, and may be recalled with any of the
1494              pull commands.  This command differs from rx, however,  in  that
1495              the  original  cells will not be cleared.  Although this command
1496              may be used to copy a range of cells, it treats  all  references
1497              as  fixed.   Use rc if you want references to be relative to the
1498              cell which contains them unless specified otherwise, either with
1499              the @fixed operator or using the $ character in the reference to
1500              the cell.
1501
1502       rc     Copy a source range to a destination range.  The source and des‐
1503              tination  may  be  different sizes.  The result is always one or
1504              more full copies of the source.  Copying a row to a row yields a
1505              row.   Copying  a column to a column yields a column.  Copying a
1506              range to anything yields a range.  Copying a row to a column  or
1507              a  column  to  a  row  yields a range with as many copies of the
1508              source as there are cells in the destination.  This command  can
1509              be used to duplicate a cell through an arbitrary range by making
1510              the source a single cell range such as b20:b20.
1511
1512              If the source range is omitted  (second  argument),  the  source
1513              range from the last copy command will be used, unless a range is
1514              currently highlighted, in which case the highlighted range  will
1515              be  copied  instead.   If  both the source range and destination
1516              range are omitted, the current cell will be used as the destina‐
1517              tion, unless a range is currently highlighted, in which case the
1518              highlighted range will serve as the destination, and the  source
1519              range from the last copy command will be copied into that desti‐
1520              nation.
1521
1522       rm     Move a source range to a destination range.  This  differs  from
1523              deleting  a range with rx and pulling it back in with pm in that
1524              any expressions that reference a cell in the range to  be  moved
1525              will  reference  the  cell  at  its  new address after the move.
1526              Unlike the rc command, the destination of a  move  is  a  single
1527              cell,  which  will  be  the  upper lefthand corner of the source
1528              range after the move.
1529
1530       rv     Values only.  This command removes the expressions from a  range
1531              of cells, leaving just the values of the expressions.
1532
1533       rs     Sort  a  range.   The rows in the specified range will be sorted
1534              according to criteria given in the form of a string  of  charac‐
1535              ters.   This  string,  enclosed in double quotes, may comprise a
1536              single criterion or multiple criteria  in  decreasing  order  of
1537              precedence.   Each  criterion  has three parts, all of which are
1538              mandatory.  The first part is a single character, which must  be
1539              either  +  or -, which specifies whether the sort should be done
1540              in ascending or  descending  order,  respectively.   The  second
1541              part,  which  is also a single character, must be either # or $,
1542              and is used to specify whether the sort should be based  on  the
1543              numeric  portion  or  the  string  portion, respectively, of the
1544              cells being used for the comparison.   The  third  part  may  be
1545              either  one  or  two  characters,  and  must be alphabetic (case
1546              insensitive), and specifies the column to be  used  when  making
1547              the comparisons.  This column must be in the range being sorted.
1548              Any number of criteria may be concatenated, and will be used  in
1549              the  order specified.  If no criteria are specified, the default
1550              behavior is to sort in ascending order, first by string and then
1551              by  number, using the leftmost column of the range being sorted.
1552              This is equivalent to specifying  the  sort  criteria  to  be  "
1553              +$a+#a  ",  where both a's are replaced by the name of the left‐
1554              most column of the range being sorted.
1555
1556       rf     Fill a range with constant values starting with  a  given  value
1557              and  increasing by a given increment.  Each row is filled before
1558              moving on to the next row if row  order  recalculation  is  set.
1559              Column  order fills each column in the range before moving on to
1560              the next column.  The start and increment numbers may  be  posi‐
1561              tive  or  negative.  To fill all cells with the same value, give
1562              an increment of zero.
1563
1564       r{     Left justify all strings in the specified range.
1565
1566       r}     Right justify all strings in the specified range.
1567
1568       r|     Center all strings in the specified range.
1569
1570       rd     Use this command to assign a symbolic name to a single cell or a
1571              rectangular  range  of  cells on the screen.  The parameters are
1572              the name, surrounded by "", and either a single cell  name  such
1573              as A10 or a range such as a1:b20.  Names defined in this fashion
1574              are used by the program in future prompts,  may  be  entered  in
1575              response  to  prompts  requesting  a cell or range name, and are
1576              saved when the spreadsheet is saved with the Put command.  Names
1577              defined  may  be  any combination of alphanumeric characters and
1578              `_' as long as the name isn't a valid cell  address.   Thus,  x,
1579              H2SO4, and 3rdDay are all valid names, but H2 is not.
1580
1581       rl     Use  this  command to lock the current cell or a range of cells,
1582              i.e. make them immune to any type of  editing.   A  locked  cell
1583              can't be changed in any way until it is unlocked.
1584
1585       rU     This  command is the opposite of the rl command and thus unlocks
1586              a locked cell and makes it editable.
1587
1588       rS     This command shows lists of the currently defined  range  names,
1589              framed  ranges,  and color definitions and ranges, one after the
1590              other.  The output of this command will be piped  to  less.   If
1591              the  environment  variable  PAGER  is  set, its value is used in
1592              place of less.
1593
1594       ru     Use this command to undefine a previously defined range name.
1595
1596       rF     Use this command to assign a value format string (see the  ``F''
1597              cell entry command) to a range of cells.
1598
1599       rr     This  command  is  used  for  creating,  modifying, and deleting
1600              framed ranges.  A framed range, is one which  has  a  number  of
1601              rows or columns specified at the top, bottom, left, and/or right
1602              (the frame) which must remain onscreen whenever the cell  cursor
1603              is  within  that  range.  In other words, a frame consists of an
1604              outer range and an inner range, where the inner range is allowed
1605              to  scroll within the outer range.  Once a frame is defined, the
1606              inner range may be resized, but the outer  range  remains  fixed
1607              unless rows or columns are added or deleted within the range.
1608
1609              When  this command is invoked, you will be prompted for the type
1610              of frame-related action you would  like  to  perform.   You  may
1611              select an option from the list by typing its first letter.
1612
1613              The  options are top, bottom, left, right, all, and unframe.  If
1614              you choose top, bottom, left, or right, you will be prompted for
1615              a range and number of rows/columns.  The range may be omitted if
1616              the cell cursor is in a  previously  defined  framed  range,  in
1617              which  case  that range's outer range will be used instead.  The
1618              number of rows/columns will set or adjust the width of the  cor‐
1619              responding side of the frame.  If all of these widths are set to
1620              zero, the frame will be undefined (same as the unframe command).
1621
1622              If you choose all, you will be prompted for an outer  range  and
1623              an inner range, in which case the inner range will scroll within
1624              the outer range, and any rows or columns outside  of  the  inner
1625              range,  but inside the outer range will be part of the ``frame''
1626              that is to remain onscreen.  The outer range may be  omitted  if
1627              the  cell  cursor  is  in  a previously defined framed range, in
1628              which case the previously defined  outer  range  will  be  used.
1629              However,  if  a  single  range is specified on the command line,
1630              while another range wholly contained within this range is  high‐
1631              lighted,  the  specified  range will be used as the outer range,
1632              and the highlighted range will be used as the inner  range.   If
1633              no  range is specified on the command line, but a range is high‐
1634              lighted, and the highlighted range is wholly contained within  a
1635              previously  defined  framed range, the highlighted range will be
1636              used as the inner range, and the previously defined outer  range
1637              will be used as the outer range.
1638
1639              If  you choose unframe, you will be prompted for a range, and if
1640              the range is found in the list of  frames,  the  frame  will  be
1641              deleted, and the framing will no longer be active (the specified
1642              range must be the outer range of the previously defined frame to
1643              be  deleted).  The range may be omitted if the cell cursor is in
1644              a previously defined framed range, in which case that range will
1645              be used by default.
1646
1647              Framed  ranges  may not be nested or overlapping.  If you try to
1648              define a range that contains any cells in common with  a  previ‐
1649              ously defined framed range, an error message will be issued, and
1650              the frame will not be created.
1651
1652       rC     This command defines  a  color  range,  and  specifies  a  fore‐
1653              ground/background  pair  to  be used for that range.  See "Color
1654              Commands" below for more information.
1655
1656   Note Commands
1657       A note is a cell or range of cells that can be jumped to  quickly  from
1658       another  cell  by  creating  a special link in that cell.  The note may
1659       contain text explaining the contents of the cell containing  the  link,
1660       similar  to a footnote, or it may simply be another part of the spread‐
1661       sheet that is related to the cell in some way.  When you press the  `n'
1662       key,  you will get a short prompt asking you whether you want to add or
1663       delete a note, or to ``show'' (by  highlighting)  which  cells  on  the
1664       screen have attached notes.
1665
1666       If  a cell with an attached note contains numeric data, it will be pre‐
1667       ceded with an ``*''.  If color is available and turned  on,  the  ``*''
1668       will  be  displayed  with color 4.  Also, the note address will be dis‐
1669       played in curly braces on the top line, preceded by an ``*'', when  the
1670       cell  is  current  (e.g.   {*AC30:AE43} or {*note1} for a named range).
1671       You may also use the *s (Note/Show) command to highlight all  cells  on
1672       the current screen with attached notes.
1673
1674       *a     Add  a  note.  This will bring up the addnote command in the top
1675              line, followed by the target address of the cell where you  want
1676              the note added.  You must then enter the cell or range where the
1677              note resides to add the note.  If you omit the note  address  or
1678              range,  the  currently  highlighted range, if any, will be used.
1679              Otherwise, the current cell will be used (you would, of  course,
1680              want to move away from the cell in which the addnote command was
1681              invoked in the latter case).
1682
1683       *d     Delete a note.  If there is a note attached to the current cell,
1684              the link will be removed (deleted).  The note itself will not be
1685              removed from the spreadsheet.  If it is  no  longer  needed,  it
1686              must be deleted in a separate step.
1687
1688       *s     Show all notes on the current screen.  If there are any cells on
1689              the visible portion of the spreadsheet  which  contain  attached
1690              notes, they will be highlighted until the next screen change, no
1691              matter how minor.  Simply moving to a new cell will be enough to
1692              turn off the highlighting.
1693
1694       **     Jump  to  a  note.   If  there is a note attached to the current
1695              cell, you will be immediately transported to that cell.  You may
1696              return from the note to where you were by pressing ` twice.
1697
1698   Color Commands
1699       Color may be enabled by setting the color option (``set color''), or by
1700       toggling it with ^TC (control-T followed by an uppercase C).  If  color
1701       is  enabled, you may define up to eight color pairs, each consisting of
1702       a foreground color and a background color.  Each of these colors may be
1703       defined  by  an expression which is evaluated at the same time the rest
1704       of the spreadsheet is evaluated.   Color  expressions  may  be  simple,
1705       specifying  only a foreground color and a background color, or they may
1706       be arbitrarily complex, causing the colors to change based  upon  other
1707       data in the spreadsheet, for example.  Color ranges may then be defined
1708       using the rC command, with a color number (1-8) assigned to  the  range
1709       (see below).
1710
1711       Some  of  the color numbers may have special meaning under certain cir‐
1712       cumstances, but may also be used explicitly  at  the  same  time.   For
1713       example,  color  1 is the default color pair if color is enabled but no
1714       color has been defined for a given cell.  It is also the color used for
1715       the  column  and row labels and the top two lines of the display, which
1716       are used for prompts, input, error messages, etc.  Color 2,  while  not
1717       explicitly  used  for  all  negative numbers, will be used for negative
1718       numbers in cells which have no other color  defined  when  colorneg  is
1719       turned  on  (``set colorneg'' or ^TN).  This is because colorneg causes
1720       all cells with negative numbers to have their color number  incremented
1721       by  one  (cycling back to color 1 if the cell is defined as using color
1722       8).  Color 3 is used for all cells with errors (ERROR or  INVALID),  if
1723       colorerr  is  set  (``set colorerr'' or ^TE), regardless of which color
1724       they have been defined to use, or whether they have been defined to use
1725       any  color at all.  Color 4 is used to highlight the ``*'' which signi‐
1726       fies that a cell has a note attached.
1727
1728       If two color ranges are nested or overlapping, any cell that is  common
1729       to  both will be displayed using the color of the most recently defined
1730       color range.  You can list all color definitions and color ranges  with
1731       the rS (show) command (see below).
1732
1733       C      This  command  first  prompts you for the color number you would
1734              like to define (or redefine).  After selecting a  number  (1-8),
1735              you  may  enter  an  expression which defines the foreground and
1736              background colors.  If the  chosen  color  has  previously  been
1737              defined,  the old definition will be presented for editing.  The
1738              syntax of the color command is:
1739
1740                     color number = expression
1741
1742              where number is the number of the color pair you want to define,
1743              and expression is the definition.  If the expression is missing,
1744              the specified color number will be unset (it will revert to  its
1745              default  start-up  colors).  Unlike setting it explicitly to its
1746              original value, this will not cause the expression to be written
1747              to  the  file  when  saved.  See below for an explanation of the
1748              format of a color expression.
1749
1750       rC     This command defines  a  color  range,  and  specifies  a  fore‐
1751              ground/background pair to be used for that range.  Although this
1752              command also uses the color command,  the  syntax  is  different
1753              from that used for defining a color pair.  This syntax is:
1754
1755                     color range number
1756
1757       rS     This  command  shows lists of the currently defined range names,
1758              framed ranges, and color definitions and ranges, one  after  the
1759              other.   The  output  of this command will be piped to less.  If
1760              the environment variable PAGER is set,  its  value  is  used  in
1761              place of less.
1762
1763       Color  expressions  are  exactly like any other numeric expression, and
1764       may contain any function or operator that is valid in any other numeric
1765       expression.  There are, however special functions designed specifically
1766       for defining colors.  These functions are:
1767
1768               @black
1769               @red
1770               @green
1771               @yellow
1772               @blue
1773               @magenta
1774               @cyan
1775               @white
1776
1777       Although these function names are intended to reflect  the  color  they
1778       produce,  and  use  the  same  names  as the curses colors, @yellow may
1779       appear as brown on many displays, especially those  based  on  the  VGA
1780       standard.
1781
1782       In addition to special functions for specifying colors, there is also a
1783       special operator for combining two such colors  into  a  single  number
1784       which  specifies both a foreground and a background color.  This opera‐
1785       tor is the semicolon (;).  For example, the command
1786
1787              color 1 = @white;@green
1788
1789       will set the foreground color to white  and  the  background  color  to
1790       green  for  any cell or range of cells defined to use color 1, or which
1791       have no color defined.  If the semicolon operator is not used, and only
1792       one color is specified, that color will be used for the foreground, and
1793       the background will default to black.
1794
1795       Although the above example is the easiest way to specify foreground and
1796       background  colors,  and  will  probably  meet  most people's needs, sc
1797       allows much more power and flexibility, should the need arise,  due  to
1798       the  fact  that any color can be specified by an expression.  For exam‐
1799       ple,
1800
1801              color 5 = B23<E75?(@black;@cyan):(@white;@magenta)
1802
1803       will cause all cells defined with color 5 to be displayed as black text
1804       on  a cyan background if the numeric value in cell B23 is less than the
1805       numeric value in cell E75; otherwise, they will be displayed  as  white
1806       text on a magenta background.  If you prefer to have the foreground and
1807       background colors dependent on different criteria, you could  do  some‐
1808       thing like this:
1809
1810              color 5 = (B23<E75?@white:@cyan);(D5%2?@red:@blue)
1811
1812       This  will cause the text color for color 5 to be either white or cyan,
1813       depending on the numeric values in cells B23 and E75, as in the  previ‐
1814       ous example, and the background color to be either red or blue, depend‐
1815       ing on whether the numeric value in cell D5 is odd or even.
1816
1817       Note that although a color expression may contain any function which is
1818       valid  in any other numeric expression, the @myrow and @mycol functions
1819       will always evaluate to 0.  This is because a color expression  is  not
1820       tied  to  any  particular  cell, but is instead evaluated once, and the
1821       result used for all cells defined to use that color.
1822
1823       Also note that if a color expression results in  an  error,  the  color
1824       will  default  to black text on a black background.  If color 1 results
1825       in an error, color will be disabled so that you can see the input  line
1826       to correct the error, after which color will need to be reenabled manu‐
1827       ally.
1828
1829       Default colors are in effect for all colors  until  defined  otherwise.
1830       These default colors are as follows:
1831
1832               color 1 = @white;@blue
1833               color 2 = @red;@blue
1834               color 3 = @white;@red
1835               color 4 = @black;@yellow
1836               color 5 = @black;@cyan
1837               color 6 = @red;@cyan
1838               color 7 = @white;@black
1839               color 8 = @red;@black
1840
1841   Miscellaneous Commands
1842
1843       Q
1844       q
1845       ^C     Exit  from  sc.   If  you made any changes since the last Get or
1846              Put, sc asks about saving your data before exiting.
1847
1848       ^G
1849       ESC    Abort entry of the current command.
1850
1851       ?      Enter an interactive help facility.  Lets you look up brief sum‐
1852              maries  of  the main features of the program.  The help facility
1853              is structured like this manual page so it is easy to  find  more
1854              information  on  a particular topic, although it may not be com‐
1855              pletely up-to-date.
1856
1857       !      Shell escape.  sc prompts for a shell command to run.   End  the
1858              command  line  with the RETURN key.  If the environment variable
1859              SHELL is defined, that shell is run.  If not, /bin/sh  is  used.
1860              Giving a null command line starts the shell in interactive mode.
1861              A second ``!'' repeats the previous command.
1862
1863       ~      Abbreviations.  You may set abbreviations to speed up the  entry
1864              of  repetitive data.  Abbreviations work much like abbreviations
1865              in vi, except that  when  defining  an  abbreviation,  both  the
1866              abbreviation  and  the  expanded  text  must be contained within
1867              quotes, separated by a single space.  If  more  than  one  space
1868              separates  the  abbreviation  from the expanded text, it will be
1869              included as part of the expanded text.
1870
1871              There are three types of abbreviations available in sc.  In  the
1872              first type, all characters must be either alphanumeric or ``_''.
1873              In the second type, the last character must be  alphanumeric  or
1874              ``_'',  but  all  other  characters  must not be alphanumeric or
1875              ``_''.  Neither type may contain  spaces.   The  third  type  of
1876              abbreviation  is a single character, and must be alphanumeric or
1877              ``_''.
1878
1879              When using abbreviations, the first type must be at  the  begin‐
1880              ning  of the line, or must be preceded by any character which is
1881              not alphanumeric or ``_''.  The  second  type  must  be  at  the
1882              beginning of the line, or must be preceded either by an alphanu‐
1883              meric character, ``_'', or a space.  Single character  abbrevia‐
1884              tions  must  be  at  the  beginning of the line or preceded by a
1885              space.
1886
1887              Abbreviations will be automatically  expanded  as  soon  as  the
1888              space bar or return key is pressed, or when pressing the ESC key
1889              at the end of the abbreviation to switch to edit mode.  You  can
1890              also force an abbreviation to be expanded by following it with a
1891              ^], which won't be inserted into the line.  If you don't want an
1892              abbreviation  to  be expanded, you must either press ^V twice or
1893              switch to edit mode and back again somewhere within the abbrevi‐
1894              ation  (pressing  ^V  twice  also has the effect of switching to
1895              navigate mode and back again).
1896
1897              If the string in the abbreviation command  contains  no  spaces,
1898              the  entire  string  will  be looked up in the list of abbrevia‐
1899              tions, and if found, the definition will  be  displayed  in  the
1900              form  of  the  original  abbreviation command used to define it.
1901              When looking up an abbreviation in this manner, be sure to  dis‐
1902              able  abbreviation expansion, as described above, or the results
1903              may not be what you expect.
1904
1905              If the string is empty, a list of all  abbreviations  and  their
1906              corresponding  expanded text will be output to your pager.  Note
1907              that abbreviations are not saved with  the  file.   This  allows
1908              each  user  to  create  his own file of abbreviations and either
1909              merge them in or include them in his own .scrc file, rather than
1910              force all users who access a file to use the same list of abbre‐
1911              viations.
1912
1913       ^L     Redraw the screen.
1914
1915       ^R     Redraw the screen with  special  highlighting  of  cells  to  be
1916              filled  in.   This is useful for finding values you need to pro‐
1917              vide or update in a form with which you aren't  familiar  or  of
1918              which you have forgotten the details.
1919
1920              It's  also  useful  for  checking  a form you are creating.  All
1921              cells which contain constant numeric values (not the result of a
1922              numeric  expression) are highlighted temporarily, until the next
1923              screen change, however minor.  To avoid ambiguity,  the  current
1924              range (if any) and current cell are not highlighted.
1925
1926       ^X     This  command  is similar to ^R, but highlights cells which have
1927              expressions.  It also displays  the  expressions  in  the  high‐
1928              lighted  cells  as  left-flushed strings, instead of the numeric
1929              values and/or label strings of those cells.  This command  makes
1930              it  easier to check expressions, at least when they fit in their
1931              cells or the following cell(s) are blank so the expressions  can
1932              slop  over  (like  label strings).  In the latter case, the slop
1933              over is not cleared on the next screen update, so you  may  want
1934              to type ^L after the ^X in order to clean up the screen.
1935
1936       @      Recalculates the spreadsheet.
1937
1938   Variable Names
1939       Normally, a variable name is just the name of a cell, such as K20.  The
1940       value is the numeric or string value of the cell, according to context.
1941
1942       When a cell's expression (formula) is copied to  another  location  via
1943       copy  or  range-copy,  variable references are by default offset by the
1944       amount the formula moved.  This allows the new formula to work  on  new
1945       data.   If  cell  references  are not to change, you can either use the
1946       @fixed operator (see below), or one of the following variations on  the
1947       cell name.
1948
1949       K20    References  cell  K20; the reference changes when the formula is
1950              copied.
1951
1952       $K$20  Always refers to cell K20; the reference stays  fixed  when  the
1953              formula is copied.
1954
1955       $K20   Keeps the column fixed at column K; the row is free to vary.
1956
1957       K$20   Similarly, this fixes the row and allows the column to vary.
1958
1959       These  conventions  also hold on defined ranges.  Range references vary
1960       when formulas containing them are copied.  If the range is defined with
1961       fixed variable references, the references do not change.
1962
1963       @fixed To  make  a variable not change automatically when a cell moves,
1964              put the word @fixed in front of the reference, for example: B1 ∗
1965              @fixed C3.
1966
1967   Numeric Expressions
1968       Numeric  expressions  used  with the ``='' and e commands have a fairly
1969       conventional syntax.  Terms may be constants, variable names, parenthe‐
1970       sized expressions, and negated terms.  Ranges may be operated upon with
1971       range functions such as sum (@sum()) and average (@avg()).   Terms  may
1972       be combined using binary operators.
1973
1974       -e     Negation.
1975
1976       e+e    Addition.
1977
1978       e-e    Subtraction.
1979
1980       ee    Multiplication.
1981
1982       e/e    Division.
1983
1984       e1%e2  e1 mod e2.
1985
1986       e^e    Exponentiation.
1987
1988       e<e
1989       e<=e
1990       e=e
1991       e!=e
1992       e>=e
1993       e>e    Relationals:  true  (1)  if  and  only if the indicated relation
1994              holds, else false (0).  Note that ``<='', ``!='', and ``>='' are
1995              converted to their ``!()'' equivalents.
1996
1997       ~e     Boolean operator NOT.
1998
1999       e&e    Boolean operator AND.
2000
2001       e|e    Boolean operator OR.
2002
2003       @if(e,e,e)
2004       e?e:e  Conditional:  If  the first expression is true then the value of
2005              the second is returned, otherwise the value of the third.
2006
2007       Operator precedence from highest to lowest is:
2008
2009              -, ~, !
2010              ^
2011              ∗, /
2012              +, -
2013              <, <=, =, !=, >=, >
2014              &
2015              |
2016              ?:
2017
2018   Built-in Range Functions
2019       These functions return numeric values.  The @sum, @prod, @avg,  @count,
2020       @max,  @min, and @stddev functions may take an optional second argument
2021       which is an expression that is to be evaluated for  each  cell  in  the
2022       specified  range  to  determine which cells to include in the function.
2023       Only those cells for which the expression evaluates to true  (non-zero)
2024       will  be used in calculating the value of the function.  Before evalua‐
2025       tion for each cell, the expression is first  converted  as  if  it  was
2026       being  copied  from the cell in the upper left-hand corner of the range
2027       into the cell under consideration, with all  cell  references  adjusted
2028       accordingly.   Because  the  parts of the expression that should remain
2029       fixed during the evaluation of the function may not necessarily be  the
2030       same  as  those  which should remain fixed during an actual copy opera‐
2031       tion, the rules for adjusting cell references during a  copy  operation
2032       are  slightly different than normal.  In particular, these rules differ
2033       in two different ways.
2034
2035       The first difference is that the @fixed operator is  ignored  during  a
2036       copy  operation  unless it is enclosed in parentheses.  This is so that
2037       selected cells whose addresses should remain  fixed  during  any  given
2038       evaluation  of  a  range  function can be adjusted relative to the cell
2039       containing the range function when copied (the $ prefix is  still  hon‐
2040       ored  for  these cells when copying).  Enclosing the @fixed operator in
2041       parentheses will have the opposite effect.  That is, it will cause cell
2042       references  to  be  fixed  while  copying,  while  allowing  them to be
2043       adjusted when the function is being evaluated, subject to  any  $  pre‐
2044       fixes  present.   Note  that  only the @fixed operator itself should be
2045       enclosed in parentheses for this to work properly.
2046
2047       The second difference is that any references  in  the  expression  that
2048       refer to cells in the range in the first argument of the range function
2049       will have any $ prefixes ignored, and the references  will  be  treated
2050       instead  as  if  they  had  the same $ prefixes as the left side of the
2051       range argument.  For example, if the left side of  the  range  argument
2052       (the  cell  address on the left side of the colon) has a fixed row, but
2053       does not have a fixed column, any cell references that refer  to  cells
2054       in  that  range  will  also have a fixed row, but will not have a fixed
2055       column.  This is so that if the range  reference  moves  when  copying,
2056       references to any cells in that range will also move accordingly.
2057
2058       Note  that the test expression will be evaluated once for every cell in
2059       the range, which means that excessive use of these functions  with  the
2060       optional test expression, or the use of overly complex test expressions
2061       or with very large ranges can greatly slow down the recalculation of  a
2062       spreadsheet,  and  may require turning off autocalc for speed, and then
2063       manually recalculating with the @ command.
2064
2065       @sum(r)
2066       @sum(r,e)         Sum all valid (nonblank) entries in the region  whose
2067                         two  corners  are  defined  by the two variable names
2068                         (e.g.  c5:e14) or  the  range  name  specified.   The
2069                         optional  second  argument is an expression which can
2070                         be used to determine which cells in the range to  sum
2071                         (see above).
2072
2073       @prod(r)
2074       @prod(r,e)        Multiply together all valid (nonblank) entries in the
2075                         specified region.  The optional second argument is an
2076                         expression which can be used to determine which cells
2077                         in the range to multiply (see above).
2078
2079       @avg(r)
2080       @avg(r,e)         Average all valid (nonblank) entries in the specified
2081                         region.   The  optional second argument is an expres‐
2082                         sion which can be used to determine  which  cells  in
2083                         the range to average (see above).
2084
2085       @count(r)
2086       @count(r,e)       Count  all  valid (nonblank) entries in the specified
2087                         region.  The optional second argument is  an  expres‐
2088                         sion  which  can  be used to determine which cells in
2089                         the range to count (see above).
2090
2091       @max(r)
2092       @max(r,e)         Return the maximum value  in  the  specified  region.
2093                         The  optional  second argument is an expression which
2094                         can be used to exclude specific cells  in  the  range
2095                         when determining this maximum value (see above).  See
2096                         also the multi argument version of @max below.
2097
2098       @min(r)
2099       @min(r,e)         Return the minimum value  in  the  specified  region.
2100                         The  optional  second argument is an expression which
2101                         can be used to exclude specific cells  in  the  range
2102                         when determining this minimum value (see above).  See
2103                         also the multi argument version of @min below.
2104
2105       @stddev(r)
2106       @stddev(r,e)      Return the sample standard deviation of the cells  in
2107                         the  specified  region.  The optional second argument
2108                         is an expression which can be used  to  exclude  spe‐
2109                         cific  cells  in the range when calculating the stan‐
2110                         dard deviation (see above).
2111
2112       @rows(r)          Return the number of rows in the specified range.
2113
2114       @cols(r)          Return the number of columns in the specified range.
2115
2116       @lookup(e,r)
2117       @lookup(r,e)
2118       @lookup(se,r)
2119       @lookup(r,se)     Evaluates the expression then  searches  through  the
2120                         range  r  for  a matching value.  The range should be
2121                         either a single row or a single column.  The  expres‐
2122                         sion  can  be either a string expression or a numeric
2123                         expression.  If it is a numeric expression, the range
2124                         is searched for the the last value less than or equal
2125                         to e.  If the expression is a string expression,  the
2126                         string  portions  of  the  cells  in  the  range  are
2127                         searched  for  an  exact  string  match.   The  value
2128                         returned  is  the numeric value from the next row and
2129                         the same column as the match, if the range was a sin‐
2130                         gle  row,  or  the value from the next column and the
2131                         same row as the match if the range was a single  col‐
2132                         umn.
2133
2134       @hlookup(e,r,n)
2135       @hlookup(r,e,n)
2136       @hlookup(se,r,n)
2137       @hlookup(r,se,n)  Evaluates  the  expression  then searches through the
2138                         first row in the range r for a matching  value.   The
2139                         expression  can  be  either  a string expression or a
2140                         numeric expression.  If it is a  numeric  expression,
2141                         the  row is searched for the the last value less than
2142                         or equal to e.  If the expression is a string expres‐
2143                         sion, the string portions of the cells in the row are
2144                         searched  for  an  exact  string  match.   The  value
2145                         returned  is the numeric value from the same column n
2146                         rows below the match.
2147
2148       @vlookup(e,r,n)
2149       @vlookup(r,e,n)
2150       @vlookup(se,r,n)
2151       @vlookup(r,se,n)  Evaluates the expression then  searches  through  the
2152                         first  column  in  the  range r for a matching value.
2153                         The expression can be either a string expression or a
2154                         numeric  expression.   If it is a numeric expression,
2155                         the column is searched for the the  last  value  less
2156                         than  or  equal  to e.  If the expression is a string
2157                         expression, the string portions of the cells  in  the
2158                         column  are  searched for an exact string match.  The
2159                         value returned is the numeric value from the same row
2160                         n columns to the right of the match.
2161
2162       @index(e1,r)
2163       @index(r,e1)
2164       @index(r,e1,e2)   Use  the values of expressions e1 and (optionally) e2
2165                         to index into the range r.  The numeric value at that
2166                         position  is returned.  With two arguments, the range
2167                         should be either a single row or a single column.  An
2168                         expression with the value 1 selects the first item in
2169                         the range, 2 selects  the  second  item,  etc.   With
2170                         three  arguments,  the range must come first, and the
2171                         second and third arguments will then  be  interpreted
2172                         as  row and column, respectively, for indexing into a
2173                         two-dimensional table.
2174
2175       @stindex(e1,r)
2176       @stindex(r,e1)
2177       @stindex(r,e1,e2) Use the values of expressions e1 and (optionally)  e2
2178                         to  index into the range r.  The string value at that
2179                         position is returned.  With two arguments, the  range
2180                         should be either a single row or a single column.  An
2181                         expression with the value 1 selects the first item in
2182                         the  range,  2  selects  the  second item, etc.  With
2183                         three arguments, the range must come first,  and  the
2184                         second  and  third arguments will then be interpreted
2185                         as row and column, respectively, for indexing into  a
2186                         two-dimensional table.
2187
2188   Built-in Numeric Functions
2189       All  of these functions operate on floating point numbers (doubles) and
2190       return numeric values.  Most of them are standard system functions more
2191       fully  described in math(3).  The trig functions operate with angles in
2192       radians.
2193
2194       @sqrt(e)          Return the square root of e.
2195
2196       @exp(e)           Return the exponential function of e.
2197
2198       @ln(e)            Return the natural logarithm of e.
2199
2200       @log(e)           Return the base 10 logarithm of e.
2201
2202       @floor(e)         Return the largest integer not greater than e.
2203
2204       @ceil(e)          Return the smallest integer not less than e.
2205
2206       @rnd(e)           Round e to the nearest integer.  default: *.5 will be
2207                         rounded  up  to the next integer; doing a 'set rndto‐
2208                         even' will cause it to be rounded to the closest even
2209                         number  instead  (aka banker's round).  Round-to-even
2210                         has advantages over the  default  rounding  for  some
2211                         applications.   For  example,  if  X+Y is an integer,
2212                         then X+Y = rnd(X)+rnd(Y) with round-to-even, but  not
2213                         always  with  the  defaulting  rounding method.  This
2214                         could be an advantage, for example,  when  trying  to
2215                         split  an odd amount of money evenly between two peo‐
2216                         ple (it would determine who gets the extra penny).
2217
2218       @round(e,n)       Round e to n decimal places.  n may  be  positive  to
2219                         round  off  the right side of the decimal or negative
2220                         to round off the left side.  See  @rnd(e)  above  for
2221                         rounding types.
2222
2223       @abs(e)
2224       @fabs(e)          Return the absolute value of e.
2225
2226       @pow(e1,e2)       Return e1 raised to the power of e2.
2227
2228       @hypot(e1,e2)     Return  sqrt(e1∗e1+e2∗e2), taking precautions against
2229                         unwarranted overflows.
2230
2231       @pi               A constant quite close to pi.
2232
2233       @dtr(e)           Convert e in degrees to radians.
2234
2235       @rtd(e)           Convert e in radians to degrees.
2236
2237       @sin(e)
2238       @cos(e)
2239       @tan(e)           Return trigonometric functions of  radian  arguments.
2240                         The  magnitude  of  the  arguments are not checked to
2241                         assure meaningful results.
2242
2243       @asin(e)          Return the arc sine of e in the range -pi/2 to pi/2.
2244
2245       @acos(e)          Return the arc cosine of e in the range 0 to pi.
2246
2247       @atan(e)          Return the arc tangent of e in  the  range  -pi/2  to
2248                         pi/2.
2249
2250       @atan2(e1,e2)     Returns  the arc tangent of e1/e2 in the range -pi to
2251                         pi.
2252
2253       @max(e1,e2,...)   Return the maximum of the values of the  expressions.
2254                         Two  or  more expressions may be specified.  See also
2255                         the range version of @max above.
2256
2257       @min(e1,e2,...)   Return the minimum of the values of the  expressions.
2258                         Two  or  more expressions may be specified.  See also
2259                         the range version of @min above.
2260
2261       @ston(se)         Convert string expression se to a numeric value.
2262
2263       @eqs(se1,se2)     Return 1 if string expression se1 has the same  value
2264                         as string expression se2, 0 otherwise.
2265
2266       @nval(se,e)       Return  the numeric value of a cell selected by name.
2267                         String expression se must evaluate to a  column  name
2268                         (``A''-``AE'')  and  e  must evaluate to a row number
2269                         (0-199).  If se or e is out of bounds,  or  the  cell
2270                         has  no  numeric value, the result is 0.  You can use
2271                         this for simple table lookups.   Be  sure  the  table
2272                         doesn't move unexpectedly!  See also @sval() below.
2273
2274       @err              Force an error.  This will force the expression which
2275                         contains it to result in an error.
2276
2277   String Expressions
2278       String expressions are made up of  constant  strings  (characters  sur‐
2279       rounded  by double quotation marks), variables (cell names, which refer
2280       to the cells's label strings or  expressions),  and  string  functions.
2281       Note  that  string  expressions are only allowed when entering a cell's
2282       label string, not its numeric part.  Also note that  string  expression
2283       results may be left or right flushed or centered, according to the type
2284       of the cell's string label.
2285
2286       #      Concatenate strings.  For example, the string expression
2287
2288                   A0 # "zy dog"
2289
2290              displays the string ``the lazy dog'' in the cell if the value of
2291              A0's string is ``the la''.
2292
2293   Built-in String Functions
2294
2295       @filename(e)      Return  the  current  default  filename, as specified
2296                         when the file was first loaded or created, or  during
2297                         the last save, with the Put command.  If e is 0, only
2298                         the actual filename will be returned, with  any  path
2299                         removed.  If non-zero, the full path specified on the
2300                         command line or in the last Get or Put  command  will
2301                         be  returned.  If the path begins with ``~'', it will
2302                         be expanded to the appropriate users home directory.
2303
2304       @substr(se,e1,e2) Extract and return from string expression se the sub‐
2305                         string indexed by character number e1 through charac‐
2306                         ter number e2 (defaults to the size of se  if  beyond
2307                         the end of it).  If e1 is less than 1 or greater than
2308                         e2, the result is the null string.  For example,
2309
2310                              @substr ("Nice jacket", 4, 8)
2311
2312                         returns the string ``e jac''.
2313
2314       @fmt(se,e)        Convert a number to a string.  The argument  se  must
2315                         be  a  valid printf(3) format string.  e is converted
2316                         according to the standard rules.   For  example,  the
2317                         expression
2318
2319                              @fmt ("∗∗%6.3f∗∗", 10.5)
2320
2321                         yields  the string ``∗∗10.500∗∗''.  e is a double, so
2322                         applicable formats are e, E, f, g, and G.  Try ``%g''
2323                         as a starting point.
2324
2325       @sval(se,e)       Return  the  string value of a cell selected by name.
2326                         String expression se must evaluate to a  column  name
2327                         (``A''-``AE'')  and  e  must evaluate to a row number
2328                         (0-199).  If se or e is out of bounds,  or  the  cell
2329                         has  no  string value, the result is the null string.
2330                         You can use this for simple table lookups.   Be  sure
2331                         the table doesn't move unexpectedly!
2332
2333       @upper(se)
2334       @lower(se)        will case the string expression to upper or lower.
2335
2336       @capital(se)      will  convert  the  first letter of words in a string
2337                         into upper case and other letters to lower case  (the
2338                         latter if all letters of the string are upper case).
2339
2340       @ext(se,e)        Call  an  external function (program or script).  The
2341                         purpose is to allow arbitrary  functions  on  values,
2342                         e.g.   table   lookups  and  interpolations.   String
2343                         expression se is a command or command  line  to  call
2344                         with  popen(3).   The  value  of  e is converted to a
2345                         string and appended to the command line as  an  argu‐
2346                         ment.   The  result  of @ext() is a string: the first
2347                         line printed to standard output by the command.   The
2348                         command  should  emit exactly one output line.  Addi‐
2349                         tional output, or output to standard error, messes up
2350                         the  screen.  @ext() returns a null string and prints
2351                         an appropriate warning if external functions are dis‐
2352                         abled,  se is null, or the attempt to run the command
2353                         fails.
2354
2355                         External functions can be slow to run, and if enabled
2356                         are  called  at  each screen update, so they are dis‐
2357                         abled by default.  You can enable them with  ^T  when
2358                         you really want them called.
2359
2360                         A simple example:
2361
2362                              @ext ("echo", a1)
2363
2364                         You can use @ston() to convert the @ext() result back
2365                         to a number.  For example:
2366
2367                              @ston (@ext ("form.sc.ext", a9 + b9))
2368
2369                         Note that you can build  a  command  line  (including
2370                         more  argument  values) from a string expression with
2371                         concatenation.  You can also "hide" the second  argu‐
2372                         ment by ending the command line (first argument) with
2373                         `` #'' (shell comment).
2374
2375       @coltoa(e)        Returns a string name for a column from  the  numeric
2376                         argument.  For example:
2377
2378                              @coltoa(@mycol-1)        @nval(coltoa(@mycol-1),
2379                         @myrow+1)
2380
2381
2382
2383   Built-in Financial Functions
2384       Financial functions compute the  mortgage  (or  loan)  payment,  future
2385       value,  and the present value functions.  Each accepts three arguments,
2386       an amount, a rate of interest (per period), and the number of  periods.
2387       These  functions  are the same as those commonly found in other spread‐
2388       sheets and financial calculators
2389
2390       @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly payments for
2391                         a  $60000  mortgage  at  12% annual interest (.01 per
2392                         month) for 30 years (360 months).
2393
2394       @fv(e1,e2,e3)     @fv(100,.005,36) computes the  future  value  for  36
2395                         monthly  payments  of  $100  at 6% interest (.005 per
2396                         month).  It answers the question: "How  much  will  I
2397                         have  in  36  months if I deposit $100 per month in a
2398                         savings  account  paying   6%   interest   compounded
2399                         monthly?"
2400
2401       @pv(e1,e2,e3)     @pv(1000,.015,36)  computes  the  present value of an
2402                         ordinary annuity of 36 monthly payments of  $1000  at
2403                         18%  annual  interest.  It answers the question: "How
2404                         much can I borrow at 18% for 3 years if I  pay  $1000
2405                         per month?"
2406
2407   Built-in Date and Time Functions
2408       Time  for  sc  follows the system standard: the number of seconds since
2409       the beginning of 1970.  All date  and  time  functions  except  @date()
2410       return numbers, not strings.
2411
2412       @now              Return the current time encoded as the number of sec‐
2413                         onds since the beginning of the epoch  (December  31,
2414                         1969, midnight, GMT).
2415
2416       @dts(e1,e2,e3)    Convert  a  date  to  the  number of seconds from the
2417                         epoch to the first  second  of  the  specified  date,
2418                         local time.  Dates may be specified in either (m,d,y)
2419                         or (y,m,d) format, although the latter is  preferred,
2420                         since it's more universally recognized (m,d,y is only
2421                         used in America).  If e2  >  12  or  e3  >  31,  then
2422                         (m,d,y)  is  assumed.  Otherwise, (y,m,d) is assumed.
2423                         For example, @date(@dts(1976,12,14)) yields
2424
2425                              Tue Dec 14 00:00:00 1976
2426
2427                         The month should range from  1 to 12; the day  should
2428                         range  from  1 to the number of days in the specified
2429                         month; and the year should include the century  (e.g.
2430                         1999  instead of 99).  Any date capable of being han‐
2431                         dled by the system is valid, typically 14 Dec 1901 to
2432                         18  Jan  2038  on a system that uses a 32 bit time_t.
2433                         Invalid dates or dates outside  of  this  range  will
2434                         return  ERROR.   For  rapid entry of dates using only
2435                         the numeric keypad, sc provides the alternate  syntax
2436                         y.m.d  or  m.d.y, which is automatically converted to
2437                         the @dts(...) format above.  The year, month, and day
2438                         must  be entered numerically in the alternate syntax;
2439                         formulas are not allowed.
2440
2441       @tts(e1,e2,e3)    @tts(8,20,45) converts the time 8:40:45 to the number
2442                         of  seconds  since  midnight,  the night before.  The
2443                         hour should range from 0 to 23; the minutes and  sec‐
2444                         onds should range from 0 to 59.
2445
2446       The following functions take the time in seconds (e.g. from @now) as an
2447       argument and return the specified value.   The  functions  all  convert
2448       from GMT to local time.
2449
2450       @date(e)
2451       @date(e,se)       Convert the time in seconds to a date string.  With a
2452                         single numeric argument, the date will be 24  charac‐
2453                         ters long in the following form:
2454
2455                              Sun Sep 16 01:03:52 1973
2456
2457                         Note  that you can extract parts of this fixed-format
2458                         string with @substr().  A  format  string  compatible
2459                         with  the strftime() function may optionally be given
2460                         as a second argument to override the default  format.
2461                         See the strftime(3) man page for details.
2462
2463       @year(e)          Return  the  year.   Valid  years  begin  with  1970,
2464                         although many systems will return years prior to 1970
2465                         if  e  is  negative.   The  last legal year is system
2466                         dependent.
2467
2468       @month(e)         Return the  month,  encoded  as  1  (January)  to  12
2469                         (December).
2470
2471       @day(e)           Return the day of the month, encoded as 1 to 31.
2472
2473       @hour(e)          Return the number of hours since midnight, encoded as
2474                         0 to 23.
2475
2476       @minute(e)        Return the number of  minutes  since  the  last  full
2477                         hour, encoded as 0 to 59.
2478
2479       @second(e)        Return  the  number  of  seconds  since the last full
2480                         minute, encoded as 0 to 59.
2481
2482   Spreadsheet Update
2483       Re-evaluation of spreadsheet expressions is done by row  or  by  column
2484       depending on the selected calculation order.  Evaluation is repeated up
2485       to iterations times for each update if necessary, so forward references
2486       usually  work as expected.  See set above.  If stability is not reached
2487       after ten iterations, a warning is printed.  This is usually due  to  a
2488       long  series  of  forward  references, or to unstable cyclic references
2489       (for example, set A0's expression to ``A0+1'').
2490
2491       @numiter          Returns the number of iterations performed so far.
2492
2493   Programmable Function Keys
2494       Function keys can be used in sc if your  terminal  supports  them,  and
2495       they  are programmable.  To program the function keys, you use the fkey
2496       command.  This command may be used in a .scrc file or a macro file,  or
2497       it  may  be  entered directly into sc's command line.  Defined function
2498       keys will be saved with the file.  There is no shortcut,  as  there  is
2499       with  most  commands,  so  the full command must be typed in.  Pressing
2500       enter when not editing a line will start you off with a blank line  for
2501       this purpose.  The format of the fkey command is:
2502
2503              fkey n = "command"
2504
2505       where  n is the function key number (n = 1 for F1, n = 2 for F2, etc.),
2506       and command is the command to be run.  For example,
2507
2508              fkey 2 = "merge \"|~/scmacros/macro1\""
2509
2510       will run the macro called macro1 located in a subdirectory of your home
2511       directory called scmacros when the F2 key is pressed.  Note that embed‐
2512       ded quotes must be escaped by a backslash.  If you want to include  the
2513       cell  address of the current cell in the command line, you may do so by
2514       entering ``$$'' in its place in the command.  For example,
2515
2516              fkey 5 = "fmt $$ \"^D%A\""
2517
2518       will cause the F5 key to format the current cell to  display  the  full
2519       weekday name of the numeric date value stored there.  The ^D is a CTRL-
2520       D character, which denotes a date format.
2521
2522       Although it may be overridden by the fkey command, the F1 key is prede‐
2523       fined  by  default to execute man sc.  Unlike the user-defined function
2524       keys, this definition will also work in edit, insert, replace, and nav‐
2525       igate modes.
2526
2527       To  undefine a function key, merely define it as the empty string ("").
2528       Undefining the F1 key will restore the default behavior.
2529
2530   Plugins
2531       There are three ways in which external programs can be used as  plugins
2532       with  sc.   First, they can be used as external commands.  When used as
2533       an external command, any command not recognized by sc will be  searched
2534       for  first in $HOME/.sc/plugins, and then in /usr/share/doc/sc/plugins.
2535       If found, it will be run with its standard input  and  standard  output
2536       redirected back to sc.  These are used to send commands to, and receive
2537       responses back from sc in the same way that advanced macros do.
2538
2539       The second and third ways that programs can be used as plugins with  sc
2540       are to automatically convert files to and from sc format based on their
2541       extensions.  In order to use them in this way, you must first associate
2542       a  given  extension  to a corresponding plugin (for reading) or plugout
2543       (for writing) using the plugin and plugout  commands.   These  commands
2544       should be placed in your .scrc file, and have the following syntax:
2545
2546              plugin "ext" = "programname"
2547
2548       or
2549
2550              plugout "ext" = "programname"
2551
2552       where  ext  is  the extension and programname is the name of the plugin
2553       program to be used for filenames with that extension.  For  input,  the
2554       plugin merely reads the specified file, performs whatever conversion is
2555       necessary, and writes the resulting data to standard output.  For  out‐
2556       put,  the  plugin  writes  sc commands to standard output and reads the
2557       replies from standard input in the same  way  that  an  advanced  macro
2558       would,  and then converts the data to the appropriate format and writes
2559       it to a file with the specified filename.
2560

FILES

2562       /usr/share/doc/sc/tutorial.sc Tutorial spreadsheet.
2563
2564       $HOME/.scrc                   Initialization commands.
2565
2566       ./.scrc                       More initialization commands.
2567

SEE ALSO

2569       bc(1), dc(1), crypt(1), psc(1)
2570

BUGS

2572       Top-to-bottom, left-to-right evaluation of  expressions  is  silly.   A
2573       proper  following  of  the  dependency graph with (perhaps) recourse to
2574       relaxation should be implemented.
2575
2576       On some systems, if the cell cursor is in column 0 with topline enabled
2577       (so  the  current  cell  is highlighted), or if any cell in column 0 is
2578       highlighted, the corresponding  row  number  gets  displayed  and  then
2579       blanked during a screen refresh.  This looks like a bug in curses.
2580
2581       Many  commands give no indication (a message or beep) if they have null
2582       effect.  Some should give confirmation of their action, but they don't.
2583

AUTHORS

2585       This is a much modified version of a public domain spread sheet  origi‐
2586       nally  authored  by James Gosling, and subsequently modified and posted
2587       to USENET by Mark Weiser under the name vc.   The  program  was  subse‐
2588       quently renamed sc, and further modified by numerous contributors, Jeff
2589       Buhrt of Proslink, Inc.  and Robert Bond of  Sequent,  prominent  among
2590       them.  The current maintainer is Chuck Martin (nrocinu@myrealbox.com).
2591
2592       Other contributors include: Tom Anderson, Glenn T. Barry, Gregory Bond,
2593       Stephen (Steve) M. Brooks, Peter Brower, John Campbell, Lawrence Cipri‐
2594       ani,  Jim Clausing, Dave Close, Chris Cole, Jonathan Crompron, David I.
2595       Dalva, Glen Ditchfield, Sam Drake, James P. Dugal,  Paul  Eggert,  Andy
2596       Fyfe,  Jack  Goral, Piercarlo "Peter" Grandi, Henk Hesselink, Jeffrey C
2597       Honig, Kurt Horton, Jonathan I. Kamens, Peter King, Tom Kloos,  Michael
2598       Lapsley,  Casey  Leedom,  Jay  Lepreau,  Dave  Lewis, Rick Linck, Soren
2599       Lundsgaard, Tad Mannes, Rob McMahon, Chris  Metcalf,  Mark  Nagel,  Ulf
2600       Noren,  Marius  Olafsson,  Gene  H. Olson, Henk P. Penning, Rick Perry,
2601       Larry Philps, Eric Putz, Jim Richardson, Michael Richardson, R.  P.  C.
2602       Rodgers,  Kim  Sanders,  Mike Schwartz, Alan Silverstein, Lowell Skoog,
2603       Herr Soeryantono, Tim Theisen, Tom Tkacik, Andy Valencia, Adri Verhoef,
2604       Rick Walker, Petri Wessman, and Tim Wilson.
2605
2606
2607
2608SC 7.16                        19 September 2002                         SC(1)
Impressum