


SC(1)                                                       SC(1)


NNAAMMEE
       sc - spread sheet calculator

SSYYNNOOPPSSIISS
       sscc [ _-_x ] [ _-_n ] [ _f_i_l_e ]


DDEESSCCRRIIPPTTIIOONN
       The  spread  sheet  calculator  _s_c is based on rectangular
       tables much like a financial spread  sheet.   When  it  is
       invoked  it  presents you with an empty table organized as
       rows and columns of cells.  Each cell  may  have  a  label
       string  associated with it and an expression.  The expres-
       sion may be a constant or it may compute  something  based
       on other entries.

       The  _-_x  option causes the _p_u_t and _g_e_t commands to encrypt
       and decrypt the data files.  The _-_n option starts the pro-
       gram  in  quick numeric entry mode.  Both of these options
       can be changed while the program is running  with  the  ^T
       command.

       When  _s_c  is  running,  the  screen  is  divided into four
       regions. The top line is for entering commands. The second
       line  is  for  messages  from  _s_c_.  The third line and the
       first four columns show the row and column  numbers.   The
       rest  of  the  screen forms a window looking at the table.
       The screen has two cursors: a cell cursor (indicated by  a
       reverse  video cell and a '<' on the screen) and a charac-
       ter cursor (indicated by the terminal's hardware  cursor).
       The  cell  and character cursors are often the same.  They
       will differ when the user is typing a command on  the  top
       line.

       The  cursor  control commands and the row, column commands
       can be prefixed by a numeric argument indicating how  many
       times  the  command  is  to be executed.  "^U" can be used
       before the number if the number is to be entered  while  a
       command  is  being typed into the command line or if quick
       entry mode is in effect.

       Commands which use the terminal's control key such  as  ^N
       will  work  both when a command is being typed and when in
       normal mode.

       Cursor control commands:


       ^^NN     Move the cell cursor to the next row.


       ^^PP     Move the cell cursor to the previous row.





                                                                1





SC(1)                                                       SC(1)


       ^^FF     Move the cell cursor forward one column.


       ^^BB     Move the cell cursor backward one column.


       ^^HH     Backspace one character.


       hh,, jj,, kk,, ll
              Alternate cursor controls (left, down, up,  right).
              The space bar is also defined to be right one cell.


       AArrrrooww KKeeyyss
              The terminal's arrow keys provide another alternate
              set  of  cell cursor controls if they exist and are
              supported in the  _t_e_r_m_c_a_p  entry.   Some  terminals
              have  arrow  keys which conflict with other control
              key codes.  For example, a terminal could  send  ^H
              when  the  back  arrow  key is depressed.  In these
              cases, the conflicting arrow key performs the  same
              function as the key combination it mimics.


       00      Move  the  cell  cursor  to column 0 of the current
              row.  This command must  be  prefixed  with  ^U  if
              quick numeric entry mode is enabled.


       $$      Move  the  cell  cursor to the last valid column in
              the current row.


       ^^      Move the cell cursor to row 0 of the  current  col-
              umn.


       ##      Move  the  cell cursor to the last valid row in the
              current column.


       gg      Go to a cell.  The program will prompt for the name
              of  a  cell.   Enter  a  cell  number such as _a_0 or
              _a_e_1_2_2_.


       ww      Scan forward (right and down)  to  the  next  valid
              cell.


       bb      Scan  backwards  (left  and  up)  to the next valid
              cell.




                                                                2





SC(1)                                                       SC(1)


       ^^EE<<dd>>  Go to end of range.  The _^_E is followed by a direc-
              tion  indication.   This  can be any of h, j, k, l,
              ^N, ^P, ^F, ^B or the arrow keys.  If the cell cur-
              sor  starts  on a non-blank cell, it will go in the
              indicated direction until it  hits  the  last  non-
              blank  adjacent cell.  If the cell cursor starts on
              a blank cell, it  go  in  the  indicated  direction
              until  it hits the first non-blank cell.  This com-
              mand is useful when specifying ranges  of  adjacent
              cells, especially when the range is bigger than the
              visible window.


       Cell entry and editing commands:


       ==      Enter a numeric expression into the  current  cell.
              The  program  will prompt for the expression on the
              top line.  The usual way to enter a number  into  a
              cell is to type _= then enter the number in response
              to the prompt on the top line.  The  quick  numeric
              entry  option  (selected  through  the  ^T command)
              shows the prompt when the first digit of  a  number
              is entered.


       ""      Enter  a  string into the current cell.  The string
              entered must be surrounded by quotation characters.
              A   string   expression  can  also  be  entered  by
              backspacing over the quotation mark in the  prompt.


       <<      Enter  a  string  that will be flushed left against
              the left edge of the cell.  The string entered must
              be  surrounded  by  quotation characters.  A string
              expression can also be entered by back spacing over
              the quotation mark in the prompt.


       >>      Enter  a  label  that will be flushed right against
              the right edge of the  cell.   The  string  entered
              must  be  surrounded  by  quotation  characters.  A
              string expression can also be entered by back spac-
              ing over the quotation mark in the prompt.


       xx      Clears  the current cell.  You may prefix this com-
              mand with a count of the number  of  cells  on  the
              current row to clear.  Cells cleared with this com-
              mand may be recalled with any of the variations  of
              the pull command.


       ee      Edit  the  value  associated with the current cell.



                                                                3





SC(1)                                                       SC(1)


              This is identical to '=' except  that  the  command
              line starts out containing the old value or expres-
              sion associated with the cell.


       EE      Edit the string associated with the  current  cell.
              This  is  the  same as one of <, >, and ", with the
              additional fact that the command  line  starts  out
              with the old string.


       mm      Mark  a  cell to be used as the source for the copy
              command.


       cc      Copy the last marked  cell  to  the  current  cell,
              updating the row and column references.


       ^^TT     Toggle  options.   This  command allows the user to
              switch the state of the encryption,  quick  numeric
              entry  and  top  line  display  options.   The user
              should follow the ^T character  with  one  of  "x",
              "n",  or  "t" to pick the intended option.  A small
              menu lists the choices when ^T is typed.


       Cells can contain both a number and a  string.   To  enter
       and  edit  the number, use _= and _e_.  To enter and edit the
       string, use quote, _<_, _> and _E_.  Either the string  or  the
       number  (but  not both at the same time) can be the result
       of evaluating an expression.  See the  sections  below  on
       numeric and string expressions for more details.


       File operations


       GG      Get  a new database from a file.  If the encryption
              option is enabled, the file is decrypted before  it
              is loaded into the spread sheet.


       PP      Put  the  current  database  into  a  file.  If the
              encryption option is enabled, the file is encrypted
              before  it  is  saved.  The optional range argument
              saves a subset of the  spreadsheet  to  the  output
              file.


       WW      Write  a  listing of the current database in a form
              that matches its appearance on  the  screen.   This
              differs  from  the  _p_u_t command in that put's files
              are intended to be reloaded with _g_e_t_,  while  _w_r_i_t_e



                                                                4





SC(1)                                                       SC(1)


              produces  a  file  for  people  to  look  at.   The
              optional range argument  writes  a  subset  of  the
              spreadsheet  to  the  output  file.   If you try to
              write to the last file used with  the  _p_u_t  or  _g_e_t
              commands, or the file specified on the command line
              when the program is invoked, you will be  asked  to
              confirm  that the (potentially) dangerous operation
              is really what you wanted.


       TT      Write a listing of the current database to a  file,
              but  put  ":"s between each field.  This  is useful
              for tables that will be further  formatted  by  the
              _t_b_l  preprocessor  of  _n_r_o_f_f_.   The  optional range
              argument writes a subset of the spreadsheet to  the
              output  file.  If you try to write to the last file
              used with the _p_u_t or  _g_e_t  commands,  or  the  file
              specified  on  the command line when the program is
              invoked, you will be  asked  to  confirm  that  the
              (potentially)  dangerous  operation  is really what
              you wanted.


       MM      Merges the database from the named  file  into  the
              current  database.   Values,  expressions and names
              defined in the named file are written into the cur-
              rent  file,  overwriting  the  existing  entries at
              those locations.


       RR      Run macros.  Since _s_c  files  are  saved  as  ascii
              files,  it  is  possible  to  use them as primitive
              macro definition files.  The _R command  makes  this
              easier  by  giving a saved a path name as the start
              of the file name in the merge command.  The  string
              to  use  is defined by the _D command below.  To use
              write macros, you must be familier  with  the  save
              file formats.  This facility is still primitive and
              could be much improved.


       DD      Define a path for the _R command to use.


       The three output operators, _p_u_t_, _w_r_i_t_e and  _t_b_l  can  pipe
       their (unencrypted only) output to a program.  To use this
       option, enter "| program" to the prompt asking for a  file
       name.   For  example,  to redirect the output of the write
       command to the printer, you could enter "| lpr -p".

       All file operations take a file name as the first argument
       to the prompt on the top line.  The prompt supplies a quo-
       tation mark to aid in typing in the file name.   The  file
       name  can  also be obtained from a cell from a label field



                                                                5





SC(1)                                                       SC(1)


       or a string expression.  In this case, the  leading  quote
       should  be deleted with the back space key and a cell name
       such as _a_2_2 entered instead.  If the string  in  the  cell
       starts with "|", the rest of the string is interpeted as a
       unix command, as above.


       Row and Column operations.  Members of this class of  com-
       mands  can  be used on either rows or columns.  The second
       letter of the command is either a column  designator  (one
       of  the  characters  c,  j, k, ^N, ^p) or a row designator
       (one of r, l, h, ^B, ^F).  Commands  which  move  or  copy
       cells also modify the variable references in affected cell
       expressions.  Variable references may be frozen  by  using
       the  _f_i_x_e_d operator or using the "$" character in the ref-
       erence to the cell.


       aarr,, aacc Creates a new row  (column)  immediately  following
              the  current row (column).  It is initialized to be
              a copy of the current one.


       ddrr,, ddcc Delete this row (column).


       pprr,, ppcc,, ppmm
              Pull deleted rows (columns) back  into  the  spread
              sheet.   The  last deleted set of cells is put back
              into the spread sheet at the current location.   _P_r
              inserts  enough  rows to hold the data.  _P_c inserts
              enough columns to hold the data.  _P_m  (merge)  does
              not insert rows or columns. It overwrites the cells
              beginning at the current cursor location.


       iirr,, iicc Insert a new row (column) by moving the  row  (col-
              umn) containing the cell cursor, and all following,
              down (right) one.  The new position will be  empty.


       zzrr,, zzcc Hide  ("zap") the current row (column).  This keeps
              a row or column from being displayed but  keeps  it
              in the data base.


       vvrr,, vvcc Removes   expressions   from   the   affected  rows
              (columns), leaving only the values  which  were  in
              the cells before the command was executed.


       ssrr,, sscc Show  hidden  rows  (columns).   Type in a range of
              rows  or  columns  to  be  revealed.   The  command
              default  is  the  first  range  of  rows or columns



                                                                6





SC(1)                                                       SC(1)


              currently hidden.


       ff      Sets the output format to be used for printing  the
              numbers  in  each cell in the current column.  Type
              in two numbers which will be the width  in  charac-
              ters  of  a  column  and the number of digits which
              will follow the decimal point.  Note that this com-
              mand  has only a column version and does not have a
              second letter.  A preceeding count can be  used  to
              specify that more than one column be formatted.


       Range  Operations:  Range  operations affect a rectangular
       region on the screen.  All of the commands in  this  class
       start with a slash; the second letter of the command indi-
       cates which command.  The program will prompt  for  needed
       parameters.   Phrases surrounded by square brackets in the
       prompt are informational only and may be erased  with  the
       backspace key.

       Prompts  requesting  variable  names may be satisfied with
       either an explicit variable name, such as _A_1_0  or  with  a
       variable  name  previously defined in a _/_d command.  Range
       name prompts require either  an  explicit  range  such  as
       _A_1_0_:_B_2_0  or a range name previously defined with a _/_d com-
       mand.  A default range shown in line  2  is  used  if  the
       range  is omitted from the command.  The default range can
       be changed by moving the cell cursor via the control  com-
       mands  (^N,  ^F,  ^N,  ^P) or the arrow keys.  The default
       range will be highlighted in standout mode on  the  termi-
       nal.


       /xx     Clear a range.  Cells cleared with this command may
              be recalled via any of the pull row or column  com-
              mands.


       /cc     Copy  a  source  range to a destination range.  The
              source and destination may be different sizes.  The
              result  is  always  one  or more full copies of the
              source.  Copying a row  to  a  row  yields  a  row.
              Copying  a  column  to  a  column  yields a column.
              Copying a range to anything yields a range.   Copy-
              ing a row to a column or a column to a row yields a
              range with as many copies of the  source  as  there
              are  cells in the destination.  This command can be
              used to dup a cell though  an  arbitrary  range  by
              making  the  source  a  single  cell  range such as
              _b_2_0_:_b_2_0_.


       /ff     Fill a range with constant values.  The  start  and



                                                                7





SC(1)                                                       SC(1)


              increment numbers may be positive or negative.


       /vv     Values  only.   This  command  removes the formulas
              from a range of cells, leaving just the  values  of
              the expressions.


       /dd     This command is used to assign a symbolic name to a
              single cell or a rectangular range of cells on  the
              screen.  The parameters are the name, surrounded by
              quotation marks, and either a single cell name such
              as  _A_1_0  or a range such as _A_1_0_:_B_2_0_.  Names defined
              in this fashion will be  used  by  the  program  in
              future  prompts,  may  be  entered  in  response to
              prompts requesting a cell or range name,  and  will
              be  saved when the spread sheet is saved with a _P_u_t
              command.  Names defined must be more than two alpha
              characters long to differentiate them from a column
              names, and must not have embedded  special  charac-
              ters.   Names  may  include  the  character  "_" or
              numerals as long as  they  occur  after  the  first
              three alpha characters.


       /ss     This  command  will  list  (show) the defined range
              names.


       /uu     This command is used to undefine a range name.  The
              range must have been previously defined.


       Miscellaneous commands:


       qq      Exit  from _s_c_.  If you were editing a file, and you
              modified it, then _s_c will ask about  saving  before
              exiting.   If you aren't editing a file and haven't
              saved the data you entered, you will get  a  chance
              to save the data before you exit.


       ^^CC     Alternate exit command.


       ??      Types a brief helpful message.


       ^GG oorr EESSCC
              Abort entry of the current command.






                                                                8





SC(1)                                                       SC(1)


       ^RR oorr ^^LL
              Redraw the screen.


       ^^VV     Types,  in  the  command line, the name of the cell
              referenced by the cell cursor.  This is  used  when
              typing in expressions which refer to entries in the
              table.


       ^^WW     Types, in the command line, the expression  of  the
              cell referenced by the cell cursor.


       ^^AA     Types,  in  the command line, the value of the cell
              referenced by the cell cursor.


       !!      Shell escape.  The program prompts for a shell com-
              mand to run.  The user should terminate the command
              with a <return> key.  No  command  will  start  the
              shell  in  interactive  mode.   A  second  "!" will
              repeat the last command.  If the environment  vari-
              ble "SHELL" is defined, that shell is run.  If not,
              /bin/sh is used.


       <TTAABB>  Starts highlight mode.  This  allows  the  user  to
              highlight  a  range of cells via the cursor control
              codes or the arrow  keys.   The  highlighted  range
              starts  at  the  cell  where the user typed tab and
              continues through the current cell cursor.  Hitting
              tab  again  causes  the  highlighted  range  to  be
              entered into the command line and the  highlighting
              to be turned off.  This is most useful for defining
              ranges to functions such as  @sum().   Hitting  ')'
              acts  just  like typing the tab key the second time
              and adds the closing ')'.


       Expressions that are used with the '='  and  'e'  commands
       have  a fairly conventional syntax.  Terms may be variable
       names, parenthesised expressions, negated terms, and  con-
       stants.   Ranges  may  be operated upon with '@' functions
       such as sum (@sum) and average (@avg).  Terms may be  com-
       bined  using  many  binary  operators.   Their precedences
       (from highest to lowest) are: ^; *,/; +,-; <,=,>,<=,>=; &;
       |; ?.


       e+e            Addition.


       e-e            Subtraction.



                                                                9





SC(1)                                                       SC(1)


       e*e            Multiplication.


       e/e            Division.


       e^e            Exponentiation.


       Variable Names Normally,  a variable name is just the name
                      of a cell, such as _K_2_0_.  The value  is  the
                      contents  of the cell.  When the formula is
                      copied to  another  location  via  copy  or
                      range  copy,  variable refernces are offset
                      by the  amount  the  formula  moved.   This
                      allows the new formula to work on new data.
                      If the cell reference is not to change, the
                      user  can  either  use  the  _f_i_x_e_d operator
                      below, or can  use  one  of  the  following
                      variations on the cell name: _K_2_0 references
                      cell K20; the reference  changes  when  the
                      formula  is copied.  _$_K_$_2_0 always refers to
                      K20; the reference  stays  fixed  when  the
                      formula  is  copied.  _$_K_2_0 keeps the column
                      fixed at column K, the row is free to vary.
                      Similarly,  _K_$_2_0  fixes  the row and allows
                      the column to vary.

                      These  conventions  also  hold  on  defined
                      ranges.   Range references vary when formu-
                      las containing them  are  copied.   If  the
                      range is defined with fixed variable refer-
                      ences, the references do not change.


       @sum(range)    Sum all valid  (nonblank)  entries  in  the
                      region whose two corners are defined by the
                      two variable (cell) names or the range name
                      given.


       @avg(range)    Average all valid (nonblank) entries in the
                      region whose two corners are defined by the
                      two variable (cell) names or the range name
                      given.


       @prod(range)   Multiply  together  all  valid   (nonblank)
                      entries in the region whose two corners are
                      defined by the two variable (cell) names or
                      the range name given.


       @max(range)    Return   the  maximum  value  in  specified



                                                               10





SC(1)                                                       SC(1)


                      region.


       @min(range)    Return the minimum value in  the  specified
                      region.


       @stddev(range) Return the sample standard deviation of the
                      specified region.


       e?e:e          Conditional: If  the  first  expression  is
                      true  then  the  value  of  the  second  is
                      returned, otherwise the value of the  third
                      is.


       <,=,>,<=,>=    Relationals:  true  iff the indicated rela-
                      tion holds.


       &,|            Boolean connectives.


       fixed          To make a variable not change automatically
                      when  a  cell  moves, put the word fixed in
                      front of the reference.  I.e.  B1*fixed C3.


       Assorted  math functions.  Most of these are standard sys-
       tem functions more fully described in _m_a_t_h_(_3_)_.

       All of them operate on floating point  numbers  (doubles);
       the trig functions operate with angles in radians.


       @exp(expr)     Returns exponential function of <expr>.


       @ln(expr)      Returns the natural logarithm of <expr>.


       @log(expr)     Returns the base 10 logarithm of <expr>.


       @pow(expr1,expr2)
                      Returns  <expr1>  raised  to  the  power of
                      <expr2>.


       @floor(expr)   Returns returns  the  largest  integer  not
                      greater than <expr>.





                                                               11





SC(1)                                                       SC(1)


       @ceil(expr)    Returns  the smallest integer not less than
                      <expr>.


       @rnd(expr)     Rounds <expr> to the nearest integer.


       @hypot(x,y)    Returns SQRT(x*x+y*y),  taking  precautions
                      against unwarranted overflows.


       @fabs(expr)    Returns the absolute value |expr|.


       @sin(expr), @cos(expr), @tan(expr)
                      Return  trigonometric  functions  of radian
                      arguments. The magnitude of  the  arguments
                      are   not   checked  to  assure  meaningful
                      results.


       @asin(expr)    Returns the arc sin in the range  -pi/2  to
                      pi/2


       @acos(expr)    Returns  the  arc  cosine in the range 0 to
                      pi.  }i(<|J

       @atan(expr)    Returns the arc tangent of  <expr>  in  the
                      range -pi/2 to pi/2.


       @dtr(expr)     Converts <expr> in degrees to radians.


       @rtd(expr)     Converts <expr> in radians to degrees.


       pi             A constant quite close to pi.


       @gamma(expr1)  Returns  the natural log of the gamma func-
                      tion.


       @ston(se)      Converts se from a string expression  to  a
                      number.


       @eqs(se1, se2) Returns  a one if se1 is the same string as
                      se2.


       Time and date functions:



                                                               12





SC(1)                                                       SC(1)


       Time for _s_c follows the system  standard:  the  number  of
       seconds since 1970.  The following functions take the time
       in seconds as an argument and return the specified  value.
       The  current  time  is available through _@_n_o_w_, below.  The
       functions all convert from GMT to local time.


       @month(seconds)
                      Returns the month, encoded from 1 (January)
                      to 12 (December).


       @day(seconds)  Returns the day, encoded from 1 to 31.


       @year(seconds) Returns  the  year.  Valid years begin with
                      1970.  The last legal year is system depen-
                      dent.


       @hour(seconds) Returns the number of hours since midnight.
                      Encoded as 0 to 23.


       @minute(seconds)
                      Returns the number  of  minutes  since  the
                      last full hour.  Encoded as 0 to 59.


       @second(seconds)
                      Returns  the  number  of  seconds since the
                      last full minute, encoded from 0 to 59.


       @now           Returns the current  time  encoded  as  the
                      number  of seconds since December 31, 1969,
                      Midnight, GMT.


       String expressions are made up of constant strings  (char-
       acters surrounded with double quotation marks), and string
       functions.  The most useful operator is the  concatenation
       operator, "#".  For example, the string expression "the"#"
       dog" displays the string "the dog"  in  the  cell.   Other
       string  operators  extract substrings and give the date in
       system standard format.  A cell name such  as  "A5"  in  a
       string  expression  will return the string associated with
       that cell.

       Valid string operators include:


       "characters"   Constant strings are characters  surrounded
                      by double quotation marks.



                                                               13





SC(1)                                                       SC(1)


       @substr(se, i1, i2)
                      Extract  the substring indexed by character
                      number _i_1 through character number _i_2  from
                      the  string  expression _s_e_.  As an example,
                      @substr("Nice jacket", 4,  7)  returns  the
                      string  "e  jac".   _S_e  can  be  any string
                      expression.  _I_1 and _i_2 can be  any  numeric
                      expressions.


       @fmt(se, e)    Fmt  converts  a  number  to a string.  The
                      argument _s_e should  be  a  valid  _p_r_i_n_t_f_(_3_)
                      format string.  _e is converted according to
                      the  standard  rules.    As   an   example,
                      _@_f_m_t_(_"_*_*_%_6_._3_f_*_*_"_,   _1_0_._5_)  will  yield  the
                      string _*_*_1_0_._5_0_0_*_*_.  The second argument, _e_,
                      is  a  double, so applicable formats are e,
                      E, f, g, and G.  Try  "%g"  as  a  starting
                      point.


       @date(e)       Date converts the time in seconds to a date
                      string 24 characters long in the  following
                      form:

                      _S_u_n _S_e_p _1_6 _0_1_:_0_3_:_5_2 _1_9_7_3


SSEEEE AALLSSOO
       bc(1), dc(1), crypt(1), psc(1)


BBUUGGSS
       Expression reevaluation is done in the same top-to-bottom,
       left-to-right manner as is done in other spread sheet cal-
       culators.   This  is  silly.   A  proper  following of the
       dependency graph with  (perhaps)  recourse  to  relaxation
       should be implemented.

       At most 200 rows and 40 columns.

















                                                               14


