home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd7.lzh / DOC / sc.doc < prev   
Text File  |  1990-04-01  |  48KB  |  1,387 lines

  1.  
  2.  
  3.  
  4.                                                             SC(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      sc - spreadsheet calculator
  10.  
  11. SYNOPSIS
  12.      sc [ -c ] [ -m ] [ -n ] [ -r ] [ -x ] [ file ]
  13.  
  14. DESCRIPTION
  15.      The spreadsheet calculator sc is based on rectangular
  16.      tables much like a financial spreadsheet.  When invoked it
  17.      presents you with a table organized as rows and columns of
  18.      cells.  If invoked without a file argument, the table is
  19.      initially empty.  Otherwise file is read in (see the Get
  20.      command below).  Each cell may have associated with it a
  21.      numeric value, a label string, and/or an expression (for-
  22.      mula) which evaluates to a numeric value or label string,
  23.      often based on other cell values.
  24.  
  25.      Options are:
  26.  
  27.      -c   Start the program with the recalculation being done in
  28.           column order.
  29.  
  30.      -m   Start the program with automatic recalculation dis-
  31.           abled.  The spreadsheet will be recalculated only when
  32.           the ``@'' command is used.
  33.  
  34.      -n   Start the program in quick numeric entry mode (see
  35.           below).
  36.  
  37.      -r   Start the program with the recalculation being done in
  38.           row order (default option).
  39.  
  40.      -x   Cause the Get and Put commands (see below) to encrypt
  41.           and decrypt data files.
  42.  
  43.      All of these options can be changed with the ^T and S com-
  44.      mands (see below) while sc is running.  Options specified
  45.      when sc is invoked override options saved in the data
  46.      file.
  47.  
  48.      General Information
  49.      The screen is divided into four regions.  The top line is
  50.      for entering commands and displaying cell values.  The
  51.      second line is for messages from sc.  The third line and
  52.      the first four columns show the column and row numbers, from
  53.      which are derived cell addresses, e.g.  A0 for the cell in
  54.      column A, row 0.  Note that column names are case-
  55.      insensitive: you can enter A0 or a0.
  56.  
  57.      The rest of the screen forms a window looking at a portion
  58.      of the table.  The total number of display rows and columns
  59.      available, hence the number of table rows and columns
  60.  
  61.  
  62.  
  63.                                                                 1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SC(1)   
  71.  
  72.  
  73.  
  74.      displayed, is set by curses(3) and may be overridden by set-
  75.      ting the LINES and COLUMNS environment variables, respec-
  76.      tively.
  77.  
  78.      The screen has two cursors: a cell cursor, indicated by a
  79.      highlighted cell and a ``<'' on the screen, and a character
  80.      cursor, indicated by the terminal's hardware cursor.  The
  81.      cell and character cursors are often the same.  They differ
  82.      when you type a command on the top line.
  83.  
  84.      If a cell's numeric value is wider than the column width
  85.      (see the f command), the cell is filled with asterisks.  If
  86.      a cell's label string is wider than the column width, it is
  87.      truncated at the start of the next non-blank cell in the
  88.      row, if any.
  89.  
  90.      Cursor control commands and row and column commands can be
  91.      prefixed by a numeric argument which indicates how many
  92.      times the command is to be executed.  You can type ^U before
  93.      a repeat count if quick numeric entry mode is enabled or if
  94.      the number is to be entered while the character cursor is on
  95.      the top line.
  96.  
  97.      Commands which use the terminal's control key, such as ^N,
  98.      work both when a command is being typed and when in normal
  99.      mode.
  100.  
  101.      Changing Options
  102.  
  103.      ^To  Toggle options.  This command allows you to switch the
  104.           state of one option selected by o.  A small menu lists
  105.           the choices for o when you type ^T.  The options
  106.           selected are saved when the data and formulas are saved
  107.           so that you will have the same setup next time you
  108.           enter the spreadsheet.
  109.  
  110.           a Automatic Recalculation.  When set, each change in
  111.             the spreadsheet causes the entire spreadsheet be
  112.             recalculated.  Normally this is not noticeable, but
  113.             for very large spreadsheets, it may be faster to
  114.             clear automatic recalculation mode and update the
  115.             spreadsheet via explicit ``@'' commands.  Default is
  116.             automatic recalculation on.
  117.  
  118.           c Current cell highlighting.  If enabled, the current
  119.             cell is highlighted (using the terminal's standout
  120.             mode, if available) in addition to being marked by
  121.             the cell cursor.
  122.  
  123.           e External function execution.  When disabled, external
  124.             functions (see @ext() below) are not called.  This
  125.             saves a lot of time at each screen update.  External
  126.  
  127.  
  128.  
  129. 2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                                                             SC(1)
  137.  
  138.  
  139.  
  140.             functions are disabled by default.  If disabled, and
  141.             external functions are used anywhere, a warning is
  142.             printed each time the screen is updated, and the
  143.             result of @ext() is the value from the previous call,
  144.             if any, or a null string.
  145.  
  146.           n Quick numeric entry.  If enabled, a typed digit is
  147.             assumed to be the start of a numeric value for the
  148.             current cell, not a repeat count, unless preceded by
  149.             ^U.
  150.  
  151.           t Top line display.  If enabled, the name and value of
  152.             the current cell is displayed on the top line.  If
  153.             there is an associated label string, the first char-
  154.             acter of the string value is ``<'' for a leftstring
  155.             or ``>'' for a rightstring (see below), followed by
  156.             "string" for a constant string or {expr} for a string
  157.             expression.  If the cell has a numeric value, it fol-
  158.             lows as [value], which may be a constant or expres-
  159.             sion.
  160.  
  161.           x Encryption.  See the -x option.
  162.  
  163.           $ Dollar prescale.  If enabled, all numeric constants
  164.             (not expressions) which you enter are multipled by
  165.             0.01 so you don't have to keep typing the decimal
  166.             point if you enter lots of dollar figures.
  167.  
  168.      S    Set options.  This command allows you to set various
  169.           options.  A small menu lists the options that cannot be
  170.           changed through ^T above.
  171.  
  172.           byrows/bycols
  173.             Specify the order cell evaluation when updating.
  174.             These options also affect the order in which cells
  175.             are filled (see /f) and whether a row or column is
  176.             cleared by an x command.
  177.  
  178.           iterations=n
  179.             Set the maximum number of recalculations before the
  180.             screen is displayed again. Iterations is set to 10 by
  181.             default.
  182.  
  183.           tblstyle=s
  184.             Control the output of the T command.  s can be: 0
  185.             (default) to give colon delimited fields, with no tbl
  186.             control lines; tbl to give colon delimited fields,
  187.             with tbl(1) control lines; latex to give a LaTeX
  188.             tabular environment; and tex to give a TeX simple
  189.             tabbed alignment with ampersands as delimiters.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                 3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SC(1)   
  203.  
  204.  
  205.  
  206.           Other Set options are normally used only in sc data
  207.           files since they are available through ^T.  You can
  208.           also use them interactively
  209.  
  210.           autocalc/!autocalc
  211.                Set/clear auto recalculation mode.
  212.  
  213.           numeric/!numeric
  214.                Set/clear numeric mode.
  215.  
  216.           prescale/!prescale
  217.                Set/clear numeric prescale mode.
  218.  
  219.           extfun/!extfun
  220.                Enable/disable external functions.
  221.  
  222.           cellcur/!cellcur
  223.                Set/clear current cell highlighting mode.
  224.  
  225.           toprow/!toprow
  226.                Set/clear top row display mode.
  227.  
  228.      Cursor Control Commands
  229.  
  230.      ^P   Move the cell cursor up to the previous row.
  231.  
  232.      ^N   Move the cell cursor down to the next row.
  233.  
  234.      ^B   Move the cell cursor backward one column.
  235.  
  236.      ^F   Move the cell cursor forward one column.
  237.  
  238.      h, j, k, l
  239.           If the character cursor is not on the top line, these
  240.           are alternate, vi-compatible cell cursor controls
  241.           (left, down, up, right).
  242.  
  243.      ^H   If the character cursor is not on the top line, ^H is
  244.           the same as ^B.
  245.  
  246.      SPACE
  247.           If the character cursor is not on the top line, the
  248.           space bar is the same as ^F.
  249.  
  250.      TAB  If the character cursor is on the top line, TAB starts
  251.           a range (see below).  Otherwise, it is the same as ^F.
  252.  
  253.      Arrow Keys
  254.           The terminal's arrow keys provide another alternate set
  255.           of cell cursor controls if they exist and are supported
  256.           in the appropriate termcap entry.  Some terminals have
  257.           arrow keys which conflict with other control key codes.
  258.  
  259.  
  260.  
  261. 4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                                                             SC(1)
  269.  
  270.  
  271.  
  272.           For example, a terminal might send ^H when the back
  273.           arrow key is pressed.  In these cases, the conflicting
  274.           arrow key performs the same function as the key combi-
  275.           nation it mimics.
  276.  
  277.      ^    Move the cell cursor up to row 0 of the current column.
  278.  
  279.      #    Move the cell cursor down to the last valid row of the
  280.           current column.
  281.  
  282.      0    Move the cell cursor backward to column A of the
  283.           current row.  This command must be prefixed with ^U if
  284.           quick numeric entry mode is enabled.
  285.  
  286.      $    Move the cell cursor forward to the last valid column
  287.           of the current row.
  288.  
  289.      b    Scan the cursor backward (left and up) to the previous
  290.           valid cell.
  291.  
  292.      w    Scan the cursor forward (right and down) to the next
  293.           valid cell.
  294.  
  295.      ^Ed  Go to end of range.  Follow ^E by a direction indicator
  296.           such as ^P or j.  If the cell cursor starts on a non-
  297.           blank cell, it goes in the indicated direction until
  298.           the last non-blank adjacent cell.  If the cell cursor
  299.           starts on a blank cell, it goes in the indicated direc-
  300.           tion until the first non-blank cell.  This command is
  301.           useful when specifying ranges of adjacent cells (see
  302.           below), especially when the range is bigger than the
  303.           visible window.
  304.  
  305.      g    Go to a cell.  sc prompts for a cell's name, a regu-
  306.           lar expression surrounded by quotes, or a number.  If a
  307.           cell's name such as ae122 or a the name of a defined
  308.           range is given, the cell cursor goes directly to that
  309.           cell.  If a quoted regular expression such as " Tax
  310.           Table " or " ^Jan [0-9]*$ " is given, sc searches
  311.           for a cell containing a string matching the regular
  312.           expression.  See regex(3) or ed(1) for more details on
  313.           the form of regular expressions.  If a number is given,
  314.           sc will search for a cell containing that number.
  315.           Searches for either strings or numbers proceed forward
  316.           from the current cell, wrapping back to a0 at the end
  317.           of the table, and terminate at the current cell if the
  318.           string or number is not found.  The last g command is
  319.           saved, and can be re-issued by entering g<return>.
  320.  
  321.      Cell Entry and Editing Commands
  322.      Cells can contain both a numeric value and a string value.
  323.      Either value can be the result of an expression, but not
  324.  
  325.  
  326.  
  327.                                                                 5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. SC(1)   
  335.  
  336.  
  337.  
  338.      both at once, i.e. each cell can have only one expression
  339.      associated with it.  Entering a valid numeric expression
  340.      alters the cell's previous numeric value, if any, and
  341.      replaces the cell's previous string expression, if any,
  342.      leaving only the previously computed constant label string.
  343.      Likewise, entering a valid string expression alters the
  344.      cell's the previous label string, if any, and replaces the
  345.      cell's previous numeric expression, if any, leaving only the
  346.      previously computed constant numeric value.
  347.  
  348.      =    Enter a numeric constant or expression into the current
  349.           cell.  sc prompts for the expression on the top
  350.           line.  The usual way to enter a number into a cell is
  351.           to type ``='', then enter the number in response to the
  352.           prompt on the top line.  The quick numeric entry
  353.           option, enabled through the -n option or ^T command,
  354.           shows the prompt when you enter the first digit of a
  355.           number (you can skip typing ``='').
  356.  
  357.      <    Enter a label string into the current cell to be
  358.           flushed left against the left edge of the cell.
  359.  
  360.      "
  361.      >    Enter a label string into the current cell to be
  362.           flushed right against the right edge of the cell.
  363.  
  364.      Strings you enter must start with ".  You can leave off the
  365.      trailing " and sc will add it for you.  You can also
  366.      enter a string expression by backspacing over the opening "
  367.      in the prompt.
  368.  
  369.      e    Edit the value associated with the current cell.  This
  370.           is identical to ``='' except that the command line
  371.           starts out containing the old numeric value or expres-
  372.           sion associated with the cell.
  373.  
  374.      E    Edit the string associated with the current cell.  This
  375.           is identical to ``<'', ``"'', or ``>'' except that the
  376.           command line starts out containing the old string value
  377.           or expression associated with the cell.
  378.  
  379.      To enter and edit a cell's number part, use the ``='' and e
  380.      commands.  To enter and edit a cell's string part, use the
  381.      ``<'', ``"'', ``>'', and E commands.  See the sections below
  382.      on numeric and string expressions for more information.
  383.  
  384.      x    Clear the current cell.  Deletes the numeric value,
  385.           label string, and/or numeric or string expression.  You
  386.           can prefix this command with a count of the number of
  387.           cells on the current row to clear.  The current column
  388.           is used if column recalculation order is set.  Cells
  389.           cleared with this command may be recalled with any of
  390.  
  391.  
  392.  
  393. 6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                                                             SC(1)
  401.  
  402.  
  403.  
  404.           the pull commands (see below).
  405.  
  406.      m    Mark a cell to be used as the source for the copy com-
  407.           mand.
  408.  
  409.      c    Copy the last marked cell to the current cell, updating
  410.           row and column references in its numeric or string
  411.           expression, if any.
  412.  
  413.      +    If not in numeric mode, add the current numeric argu-
  414.           ment (default 1) to the value of the current cell.  In
  415.           numeric mode, ``+'' introduces a new numeric expression
  416.           or value, the same as ``=''.
  417.  
  418.      -    If not in numeric mode, subtract the current numeric
  419.           argument (default 1) from the value of the current
  420.           cell.  In numeric mode, ``-'' introduces a new, nega-
  421.           tive, numeric expression or value, like ``=''.
  422.  
  423.      File Commands
  424.  
  425.      G    Get a new database from a file.  If encryption is
  426.           enabled, the file is decrypted before it is loaded into
  427.           the spreadsheet.
  428.  
  429.      P    Put the current database into a file.  If encryption is
  430.           enabled, the file is encrypted before it is saved.
  431.  
  432.      W    Write a listing of the current database into a file in
  433.           a form that matches its appearance on the screen.  This
  434.           differs from the Put command in that its files are
  435.           intended to be reloaded with Get, while Write produces
  436.           a file for people to look at.  Hidden rows or columns
  437.           are not shown when the data is printed.
  438.  
  439.      T    Write a listing of the current database to a file, but
  440.           include delimiters suitable for processing by the tbl,
  441.           LaTeX, or TeX table processors.  The delimiters are
  442.           controlled by the tblstyle option.  See Set above.  The
  443.           delimters are are a colon (:) for style 0ortbl and an
  444.           ampersand (&) for style latexortex.
  445.  
  446.      With the Put, Write, and Table commands, the optional range
  447.      argument writes a subset of the spreadsheet to the output
  448.      file.
  449.  
  450.      With the Write and Table commands, if you try to write to
  451.      the last file used with the Get or Put commands, or the file
  452.      specified on the command line when sc was invoked, you
  453.      are asked to confirm that the (potentially) dangerous opera-
  454.      tion is really what you want.
  455.  
  456.  
  457.  
  458.  
  459.                                                                 7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. SC(1)   
  467.  
  468.  
  469.  
  470.      The three output commands, Put, Write, and Table, can pipe
  471.      their (unencrypted only) output to a program.  To use this
  472.      feature, enter ``| program'' to the prompt asking for a
  473.      filename.  For example, to redirect the output of the Write
  474.      command to the printer, you might enter ``| lpr -p''.
  475.  
  476.      M    Merge the database from the named file into the current
  477.           database.  Values and expressions defined in the named
  478.           file are read into the current spreadsheet overwriting
  479.           the existing entries at matching cell locations.
  480.  
  481.      R    Run macros.  Since sc files are saved as ASCII
  482.           files, it is possible to use them as primitive macro
  483.           definition files.  The Run command makes this easier.
  484.           It's like the Merge command, but prints a saved path
  485.           name as the start of the filename to merge in.  The
  486.           string to use is set with the Define command.  To write
  487.           macros, you must be familiar with the file format writ-
  488.           ten by the Put command.  This facility is still primi-
  489.           tive and could be much improved.
  490.  
  491.      D    Define a path for the Run command to use.
  492.  
  493.      All file operations take a filename as the first argument to
  494.      the prompt on the top line.  The prompt supplies a " to aid
  495.      in typing in the filename.  The filename can also be
  496.      obtained from a cell's label string or string expression.
  497.      In this case, delete the leading " with the backspace key
  498.      and enter a cell name such as a22 instead.  If the resulting
  499.      string starts with ``|'', the rest of the string is inter-
  500.      preted as a UNIX command, as above.
  501.  
  502.      Row and Column Commands
  503.      These commands can be used on either rows or columns.  The
  504.      second letter of the command is either a row designator (one
  505.      of the characters r, ^B, ^F, h, l) or a column designator
  506.      (one of c, ^P, ^N, k, j).  A small menu lists the choices
  507.      for the second letter when you type the first letter of one
  508.      of these commands.  Commands which move or copy cells also
  509.      modify the row and column references in affected cell
  510.      expressions.  The references may be frozen by using the
  511.      fixed operator or using the $ character in the reference to
  512.      the cell (see below).
  513.  
  514.      ir, ic
  515.           Insert a new row (column) by moving the row (column)
  516.           containing the cell cursor, and all following rows
  517.           (columns), down (right) one row (column).  The new row
  518.           (column) is empty.
  519.  
  520.      ar, ac
  521.           Append a new row (column) immediately following the
  522.  
  523.  
  524.  
  525. 8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                                                             SC(1)
  533.  
  534.  
  535.  
  536.           current row (column).  It is initialized as a copy of
  537.           the current one.
  538.  
  539.      dr, dc
  540.           Delete the current row (column).
  541.  
  542.      pr, pc, pm
  543.           Pull deleted rows (columns) back into the spreadsheet.
  544.           The last deleted set of cells is put back into the
  545.           spreadsheet at the current location.  pr inserts enough
  546.           rows to hold the data.  pc inserts enough columns to
  547.           hold the data.  pm (merge) does not insert rows or
  548.           columns; it overwrites the cells beginning at the
  549.           current cell cursor location.
  550.  
  551.      vr, vc
  552.           Remove expressions from the affected rows (columns),
  553.           leaving only the values which were in the cells before
  554.           the command was executed.
  555.  
  556.      zr, zc
  557.           Hide (``zap'') the current row (column).  This keeps a
  558.           row (column) from being displayed but keeps it in the
  559.           data base.  The status of the rows and columns is saved
  560.           with the data base so hidden rows and columns will be
  561.           still be hidden when you reload the spreadsheet.  Hid-
  562.           den rows or columns are not printed by the W command.
  563.  
  564.      sr, sc
  565.           Show hidden rows (columns).  Enter a range of rows
  566.           (columns) to be revealed.  The default is the first
  567.           range of rows (columns) currently hidden.  This command
  568.           ignores the repeat count, if any.
  569.  
  570.      f    Set the output format to be used for printing the
  571.           numeric values in each cell in the current column.
  572.           Enter two numbers: the total width in characters of the
  573.           column, and the number of digits to follow decimal
  574.           points.  Values are rounded off to the least signifi-
  575.           cant digit displayed.  The total column width affects
  576.           displays of strings as well as numbers.  A preceding
  577.           count can be used to affect more than one column.  This
  578.           command has only a column version (no second letter).
  579.  
  580.      Range Commands
  581.      Range operations affect a rectangular region on the screen
  582.      defined by the upper left and lower right cells in the
  583.      region.  All of the commands in this class start with a
  584.      slash; the second letter of the command indicates which com-
  585.      mand.  A small menu lists the choices for the second letter
  586.      when you type ``/''.  sc prompts for needed parameters
  587.      for each command.  Phrases surrounded by square brackets in
  588.  
  589.  
  590.  
  591.                                                                 9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. SC(1)   
  599.  
  600.  
  601.  
  602.      the prompt are informational only and may be erased with the
  603.      backspace key.
  604.  
  605.      Prompts requesting variable names may be satisfied with
  606.      either an explicit variable name, such as A10, or with a
  607.      variable name previously defined in a /d command (see
  608.      below).  Range name prompts require either an explicit range
  609.      such as A10:B20, or a range name previously defined with a
  610.      /d command.  A default range shown in the second line is
  611.      used if you omit the range from the command or press the TAB
  612.      key (see below).  The default range can be changed by moving
  613.      the cell cursor via the control commands (^P, ^N, ^B, ^F) or
  614.      the arrow keys.  The cells in the default range are
  615.      highlighted (using the terminal's standout mode, if avail-
  616.      able).
  617.  
  618.      /x   Clear a range.  Cells cleared with this command may be
  619.           recalled with any of the pull commands.
  620.  
  621.      /v   Values only.  This command removes the expressions from
  622.           a range of cells, leaving just the values of the
  623.           expressions.
  624.  
  625.      /c   Copy a source range to a destination range.  The source
  626.           and destination may be different sizes.  The result is
  627.           always one or more full copies of the source.  Copying
  628.           a row to a row yields a row.  Copying a column to a
  629.           column yields a column.  Copying a range to anything
  630.           yields a range.  Copying a row to a column or a column
  631.           to a row yields a range with as many copies of the
  632.           source as there are cells in the destination.  This
  633.           command can be used to duplicate a cell through an
  634.           arbitrary range by making the source a single cell
  635.           range such as b20:b20.
  636.  
  637.      /f   Fill a range with constant values starting with a given
  638.           value and increasing by a given increment.  Each row is
  639.           filled before moving on to the next row if row order
  640.           recalculation is set.  Column order fills each column
  641.           in the range before moving on to the next column.  The
  642.           start and increment numbers may be positive or nega-
  643.           tive.  To fill all cells with the same value, give an
  644.           increment of zero.
  645.  
  646.      /d   Use this command to assign a symbolic name to a single
  647.           cell or a rectangular range of cells on the screen.
  648.           The parameters are the name, surrounded by "", and
  649.           either a single cell name such as A10 or a range such
  650.           as a1:b20.  Names defined in this fashion are used by
  651.           the program in future prompts, may be entered in
  652.           response to prompts requesting a cell or range name,
  653.           and are saved when the spreadsheet is saved with the
  654.  
  655.  
  656.  
  657. 10
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                                                             SC(1)
  665.  
  666.  
  667.  
  668.           Put command.  Names defined must be more than two alpha
  669.           characters long to differentiate them from a column
  670.           names, and must not have embedded special characters.
  671.           Names may include the character ``_'' or numerals as
  672.           long as they occur after the first three alpha charac-
  673.           ters.
  674.  
  675.      /s   This command lists (shows) the currently defined range
  676.           names.  If there are no defined range names, then a
  677.           message is given, otherwise it pipes output to sort,
  678.           then to less.  If the environment variable PAGER is
  679.           set, its value is used in place of less.
  680.  
  681.      /u   Use this command to undefine a previously defined range
  682.           name.
  683.  
  684.      Miscellaneous Commands
  685.  
  686.      Q
  687.      q
  688.      ^C   Exit from sc.  If you made any changes since the
  689.           last Get or Put, sc asks about saving your data
  690.           before exiting.
  691.  
  692.      ^G
  693.      ESC  Abort entry of the current command.
  694.  
  695.      ?    Enter an interactive help facility.  Lets you look up
  696.           brief summaries of the main features of the program.
  697.           The help facility is structured like this manual page
  698.           so it is easy to find more information on a particular
  699.           topic.
  700.  
  701.      !    Shell escape.  sc prompts for a shell command to
  702.           run.  End the command line with the RETURN key.  If the
  703.           environment variable SHELL is defined, that shell is
  704.           run.  If not, /bin/sh is used.  Giving a null command
  705.           line starts the shell in interactive mode.  A second
  706.           ``!'' repeats the previous command.
  707.  
  708.      ^L   Redraw the screen.
  709.  
  710.      ^R   Redraw the screen with special highlighting of cells to
  711.           be filled in.  This is useful for finding values you
  712.           need to provide or update in a form with which you
  713.           aren't familiar or of which you have forgotten the
  714.           details.
  715.  
  716.           It's also useful for checking a form you are creating.
  717.           All cells which contain constant numeric values (not
  718.           the result of a numeric expression) are highlighted
  719.           temporarily, until the next screen change, however
  720.  
  721.  
  722.  
  723.                                                                11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. SC(1)   
  731.  
  732.  
  733.  
  734.           minor.  To avoid ambiguity, the current range (if any)
  735.           and current cell are not highlighted.
  736.  
  737.      ^X   This command is similar to ^R, but highlights cells
  738.           which have expressions.  It also displays the expres-
  739.           sions in the highlighted cells as left-flushed strings,
  740.           instead of the numeric values and/or label strings of
  741.           those cells.  This command makes it easier to check
  742.           expressions, at least when they fit in their cells or
  743.           the following cell(s) are blank so the expressions can
  744.           slop over (like label strings).  In the latter case,
  745.           the slop over is not cleared on the next screen update,
  746.           so you may want to type ^L after the ^X in order to
  747.           clean up the screen.
  748.  
  749.      @    Recalculates the spreadsheet.
  750.  
  751.      ^V   Type, in the command line, the name of the current cell
  752.           (the one at the cell cursor).  This is useful when
  753.           entering expressions which refer to other cells in the
  754.           table.
  755.  
  756.      ^W   Type, in the command line, the expression attached to
  757.           the current cell.  If there is none, the result is
  758.           ``?''.
  759.  
  760.      ^A   Type, in the command line, the numeric value of the
  761.           current cell, if any.
  762.  
  763.      The ^V, ^W, and ^A commands only work when the character
  764.      cursor is on the command line and beyond the first charac-
  765.      ter.
  766.  
  767.      TAB  When the character cursor is on the top line, defines a
  768.           range of cells via the cursor control commands or the
  769.           arrow keys.  The range is highlighted, starts at the
  770.           cell where you typed TAB, and continues through the
  771.           current cell cursor.  Pressing TAB again causes the
  772.           highlighted range to be entered into the command line
  773.           and the highlighting to be turned off.  This is most
  774.           useful for defining ranges to functions such as @sum().
  775.           Pressing ``)'' acts just like typing the TAB key the
  776.           second time and adds the closing ``)''.  Note that when
  777.           you give a range command, you don't need to press the
  778.           first TAB to begin defining a range starting with the
  779.           current cell.
  780.  
  781.      Variable Names
  782.      Normally, a variable name is just the name of a cell, such
  783.      as K20.  The value is the numeric or string value of the
  784.      cell, according to context.
  785.  
  786.  
  787.  
  788.  
  789. 12
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                                                             SC(1)
  797.  
  798.  
  799.  
  800.      When a cell's expression (formula) is copied to another
  801.      location via copy or range-copy, variable references are by
  802.      default offset by the amount the formula moved.  This allows
  803.      the new formula to work on new data.  If cell references are
  804.      not to change, you can either use the fixed operator (see
  805.      below), or one of the following variations on the cell name.
  806.  
  807.      K20  References cell K20; the reference changes when the
  808.           formula is copied.
  809.  
  810.      $K$20
  811.           Always refers to cell K20; the reference stays fixed
  812.           when the formula is copied.
  813.  
  814.      $K20 Keeps the column fixed at column K; the row is free to
  815.           vary.
  816.  
  817.      K$20 Similarly, this fixes the row and allows the column to
  818.           vary.
  819.  
  820.      These conventions also hold on defined ranges.  Range refer-
  821.      ences vary when formulas containing them are copied.  If the
  822.      range is defined with fixed variable references, the refer-
  823.      ences do not change.
  824.  
  825.      fixed
  826.           To make a variable not change automatically when a cell
  827.           moves, put the word fixed in front of the reference,
  828.           for example: B1 * fixed C3.
  829.  
  830.      Numeric Expressions
  831.      Numeric expressions used with the ``='' and e commands have
  832.      a fairly conventional syntax.  Terms may be constants, vari-
  833.      able names, parenthesized expressions, and negated terms.
  834.      Ranges may be operated upon with range functions such as sum
  835.      (@sum()) and average (@avg()).  Terms may be combined using
  836.      binary operators.
  837.  
  838.      -e   Negation.
  839.  
  840.      e+e  Addition.
  841.  
  842.      e-e  Subtraction.
  843.  
  844.      e*e  Multiplication.
  845.  
  846.      e/e  Division.
  847.  
  848.      e1%e2
  849.           e1 mod e2.
  850.  
  851.      e^e  Exponentiation.
  852.  
  853.  
  854.  
  855.                                                                13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. SC(1)   
  863.  
  864.  
  865.  
  866.      e<e
  867.      e<=e
  868.      e=e
  869.      e!=e
  870.      e>=e
  871.      e>e  Relationals: true (1) if and only if the indicated
  872.           relation holds, else false (0).  Note that ``<='',
  873.           ``!='', and ``>='' are converted to their ``~()''
  874.           equivalents.
  875.  
  876.      ~e   Boolean operator NOT.
  877.  
  878.      e&e  Boolean operator AND.
  879.  
  880.      e|e  Boolean operator OR.
  881.  
  882.      e?e:e
  883.           Conditional: If the first expression is true then the
  884.           value of the second is returned, otherwise the value of
  885.           the third.
  886.  
  887.      Operator precedence from highest to lowest is:
  888.  
  889.           -, ~
  890.           ^
  891.           *, /
  892.           +, -
  893.           <, <=, =, !=, >=, >
  894.           &
  895.           |
  896.           ?:
  897.  
  898.      Built-in Range Functions
  899.      These functions return numeric values.
  900.  
  901.      @sum(r)           Sum all valid (nonblank) entries in the
  902.                        region whose two corners are defined by
  903.                        the two variable names (e.g.  c5:e14) or
  904.                        the range name specified.
  905.  
  906.      @prod(r)          Multiply together all valid (nonblank)
  907.                        entries in the specified region.
  908.  
  909.      @avg(r)           Average all valid (nonblank) entries in
  910.                        the specified region.
  911.  
  912.      @max(r)           Return the maximum value in the specified
  913.                        region.  See also the multi argument ver-
  914.                        sion of @max below.
  915.  
  916.      @min(r)           Return the minimum value in the specified
  917.                        region.  See also the multi argument
  918.  
  919.  
  920.  
  921. 14
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                                                             SC(1)
  929.  
  930.  
  931.  
  932.                        version of @min below.
  933.  
  934.      @stddev(r)        Return the sample standard deviation of
  935.                        the cells in the specified region.
  936.  
  937.      @lookup(e,r)
  938.      @lookup(se,r)     Evaluates the expression then searches
  939.                        through the range r for a matching value.
  940.                        The range should be either a single row or
  941.                        a single column.  The expression can be
  942.                        either a string expression or a numeric
  943.                        expression.  If it is a numeric expres-
  944.                        sion, the range is searched for the the
  945.                        last value less than or equal to e.  If
  946.                        the expression is a string expression, the
  947.                        string portions of the cells in the range
  948.                        are searched for an exact string match.
  949.                        The value returned is the numeric value
  950.                        from the next row and the same column as
  951.                        the match, if the range was a single row,
  952.                        or the value from the next column and the
  953.                        same row as the match if the range was a
  954.                        single column.
  955.  
  956.      @index(e,r)       Use the value of the expression e to index
  957.                        into the range r.  The numeric value at
  958.                        that position is returned. The value 1
  959.                        selects the first item in the range, 2
  960.                        selects the second item, etc.  R should be
  961.                        either a single row or a single column.
  962.  
  963.      @stindex(e,r)     Use the value of e to index into the range
  964.                        r.  The string value at that position is
  965.                        returned. The value 1 selects the first
  966.                        item in the range, 2 selects the second
  967.                        item, etc.  The range should be either a
  968.                        single row or a single column.
  969.  
  970.      Built-in Numeric Functions
  971.      All of these functions operate on floating point numbers
  972.      (doubles) and return numeric values.  Most of them are stan-
  973.      dard system functions more fully described in math(3).  The
  974.      trig functions operate with angles in radians.
  975.  
  976.      @sqrt(e)          Return the square root of e.
  977.  
  978.      @exp(e)           Return the exponential function of e.
  979.  
  980.      @ln(e)            Return the natural logarithm of e.
  981.  
  982.      @log(e)           Return the base 10 logarithm of e.
  983.  
  984.  
  985.  
  986.  
  987.                                                                15
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. SC(1)   
  995.  
  996.  
  997.  
  998.      @floor(e)         Return the largest integer not greater
  999.                        than e.
  1000.  
  1001.      @ceil(e)          Return the smallest integer not less than
  1002.                        e.
  1003.  
  1004.      @rnd(e)           Round e to the nearest integer.
  1005.  
  1006.      @fabs(e)          Return the absolute value of e.
  1007.  
  1008.      @pow(e1,e2)       Return e1 raised to the power of e2.
  1009.  
  1010.      @hypot(e1,e2)     Return sqrt(e1*e1+e2*e2), taking precau-
  1011.                        tions against unwarranted overflows.
  1012.  
  1013.      pi                A constant quite close to pi.
  1014.  
  1015.      @dtr(e)           Convert e in degrees to radians.
  1016.  
  1017.      @rtd(e)           Convert e in radians to degrees.
  1018.  
  1019.      @sin(e)
  1020.      @cos(e)
  1021.      @tan(e)           Return trigonometric functions of radian
  1022.                        arguments.  The magnitude of the arguments
  1023.                        are not checked to assure meaningful
  1024.                        results.
  1025.  
  1026.      @asin(e)          Return the arc sine of e in the range
  1027.                        -pi/2 to pi/2.
  1028.  
  1029.      @acos(e)          Return the arc cosine of e in the range 0
  1030.                        to pi.
  1031.  
  1032.      @atan(e)          Return the arc tangent of e in the range
  1033.                        -pi/2 to pi/2.
  1034.  
  1035.      @atan2(e1,e2)     Returns the arc tangent of e1/e2 in the
  1036.                        range -pi to pi.
  1037.  
  1038.      @max(e1,e2,...)   Return the maximum of the values of the
  1039.                        expressions.  Two or more expressions may
  1040.                        be specified.  See also the range version
  1041.                        of @max above.
  1042.  
  1043.      @min(e1,e2,...)   Return the minimum of the values of the
  1044.                        expressions.  Two or more expressions may
  1045.                        be specified.  See also the range version
  1046.                        of @min above.
  1047.  
  1048.      @ston(se)         Convert string expression se to a numeric
  1049.                        value.
  1050.  
  1051.  
  1052.  
  1053. 16
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                                                             SC(1)
  1061.  
  1062.  
  1063.  
  1064.      @eqs(se1,se2)     Return 1 if string expression se1 has the
  1065.                        same value as string expression se2, 0
  1066.                        otherwise.
  1067.  
  1068.      @nval(se,e)       Return the numeric value of a cell
  1069.                        selected by name.  String expression se
  1070.                        must evaluate to a column name (``A''-
  1071.                        ``AE'') and e must evaluate to a row
  1072.                        number (0-199). If se or e is out of
  1073.                        bounds, or the cell has no numeric value,
  1074.                        the result is 0.  You can use this for
  1075.                        simple table lookups.  Be sure the table
  1076.                        doesn't move unexpectedly!  See also
  1077.                        @sval() below.
  1078.  
  1079.      String Expressions
  1080.      String expressions are made up of constant strings (charac-
  1081.      ters surrounded by double quotation marks), variables (cell
  1082.      names, which refer to the cells's label strings or expres-
  1083.      sions), and string functions.  Note that string expressions
  1084.      are only allowed when entering a cell's label string, not
  1085.      its numeric part.  Also note that string expression results
  1086.      may be left or right flushed, according to the type of the
  1087.      cell's string label.
  1088.  
  1089.      #                 Concatenate strings.  For example, the
  1090.                        string expression
  1091.  
  1092.                             A0 # "zy dog"
  1093.  
  1094.                        displays the string ``the lazy dog'' in
  1095.                        the cell if the value of A0's string is
  1096.                        ``the la''.
  1097.  
  1098.      Built-in String Functions
  1099.  
  1100.      @substr(se,e1,e2) Extract and return from string expression
  1101.                        se the substring indexed by character
  1102.                        number e1 through character number e2
  1103.                        (defaults to the size of se if beyond the
  1104.                        end of it).  If e1 is less than 1 or
  1105.                        greater than e2, the result is the null
  1106.                        string.  For example,
  1107.  
  1108.                             @substr ("Nice jacket", 4, 7)
  1109.  
  1110.                        returns the string ``e jac''.
  1111.  
  1112.      @fmt(se,e)        Convert a number to a string.  The argu-
  1113.                        ment se must be a valid printf(3) format
  1114.                        string.  e is converted according to the
  1115.                        standard rules.  For example, the
  1116.  
  1117.  
  1118.  
  1119.                                                                17
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. SC(1)   
  1127.  
  1128.  
  1129.  
  1130.                        expression
  1131.  
  1132.                             @fmt ("**%6.3f**", 10.5)
  1133.  
  1134.                        yields the string ``**10.500**''.  e is a
  1135.                        double, so applicable formats are e, E, f,
  1136.                        g, and G.  Try ``%g'' as a starting point.
  1137.  
  1138.      @sval(se,e)       Return the string value of a cell selected
  1139.                        by name.  String expression se must evalu-
  1140.                        ate to a column name (``A''-``AE'') and e
  1141.                        must evaluate to a row number (0-199). If
  1142.                        se or e is out of bounds, or the cell has
  1143.                        no string value, the result is the null
  1144.                        string.  You can use this for simple table
  1145.                        lookups.  Be sure the table doesn't move
  1146.                        unexpectedly!
  1147.  
  1148.      @ext(se,e)        Call an external function (program or
  1149.                        script).  The purpose is to allow arbi-
  1150.                        trary functions on values, e.g. table
  1151.                        lookups and interpolations.  String
  1152.                        expression se is a command or command line
  1153.                        to call with popen(3).  The value of e is
  1154.                        converted to a string and appended to the
  1155.                        command line as an argument.  The result
  1156.                        of @ext() is a string: the first line
  1157.                        printed to standard output by the command.
  1158.                        The command should emit exactly one output
  1159.                        line.  Additional output, or output to
  1160.                        standard error, messes up the screen.
  1161.                        @ext() returns a null string and prints an
  1162.                        appropriate warning if external functions
  1163.                        are disabled, se is null, or the attempt
  1164.                        to run the command fails.
  1165.  
  1166.                        External functions can be slow to run, and
  1167.                        if enabled are called at each screen
  1168.                        update, so they are disabled by default.
  1169.                        You can enable them with ^T when you
  1170.                        really want them called.
  1171.  
  1172.                        A simple example:
  1173.  
  1174.                             @ext ("echo", a1)
  1175.  
  1176.                        You can use @ston() to convert the @ext()
  1177.                        result back to a number.  For example:
  1178.  
  1179.                             @ston (@ext ("form.sc.ext", a9 + b9))
  1180.  
  1181.                        Note that you can built a command line
  1182.  
  1183.  
  1184.  
  1185. 18
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                                                             SC(1)
  1193.  
  1194.  
  1195.  
  1196.                        (including more argument values) from a
  1197.                        string expression with concatenation.  You
  1198.                        can also "hide" the second argument by
  1199.                        ending the command line (first argument)
  1200.                        with `` #'' (shell comment).
  1201.  
  1202.      Built-in Financial Functions
  1203.      Financial functions compute the mortgage (or loan) payment,
  1204.      future value, and the present value functions.  Each accepts
  1205.      three arguments, an amount, a rate of interest (per period),
  1206.      and the number of periods.  These functions are the same as
  1207.      those commonly found in other spreadsheets and financial
  1208.      calculators
  1209.  
  1210.      @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly
  1211.                        payments for a $60000 mortgage at 12%
  1212.                        annual interest (.01 per month) for 30
  1213.                        years (360 months).
  1214.  
  1215.      @fv(e1,e2,e3)     @fv(100,.005,36) computes the future value
  1216.                        for of 36 monthly payments of $100 at 6%
  1217.                        interest (.005 per month).  It answers the
  1218.                        question: "How much will I have in 2 years
  1219.                        if I deposit $100 per month in a savings
  1220.                        account paying 6% interest compounded
  1221.                        monthly?"
  1222.  
  1223.      @pv(e1,e2,e3)     @pv(1000,.015,36) computes the present
  1224.                        value of an a ordinary annuity of 36
  1225.                        monthly payments of $1000 at 18% annual
  1226.                        interest.  It answers the question: "How
  1227.                        much can I borrow at 18% for 30 years if I
  1228.                        pay $1000 per month?"
  1229.  
  1230.      Built-in Date and Time Functions
  1231.      Time for sc follows the system standard: the number of
  1232.      seconds since 1970.  All date and time functions except
  1233.      @date() return numbers, not strings.
  1234.  
  1235.      @now              Return the current time encoded as the
  1236.                        number of seconds since December 31, 1969,
  1237.                        midnight, GMT.
  1238.  
  1239.      The following functions take the time in seconds (e.g. from
  1240.      @now) as an argument and return the specified value.  The
  1241.      functions all convert from GMT to local time.
  1242.  
  1243.      @date(e)          Convert the time in seconds to a date
  1244.                        string 24 characters long in the following
  1245.                        form:
  1246.  
  1247.                             Sun Sep 16 01:03:52 1973
  1248.  
  1249.  
  1250.  
  1251.                                                                19
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. SC(1)   
  1259.  
  1260.  
  1261.  
  1262.                        Note that you can extract parts of this
  1263.                        fixed-format string with @substr().
  1264.  
  1265.      @year(e)          Return the year.  Valid years begin with
  1266.                        1970.  The last legal year is system
  1267.                        dependent.
  1268.  
  1269.      @month(e)         Return the month, encoded as 1 (January)
  1270.                        to 12 (December).
  1271.  
  1272.      @day(e)           Return the day of the month, encoded as 1
  1273.                        to 31.
  1274.  
  1275.      @hour(e)          Return the number of hours since midnight,
  1276.                        encoded as 0 to 23.
  1277.  
  1278.      @minute(e)        Return the number of minutes since the
  1279.                        last full hour, encoded as 0 to 59.
  1280.  
  1281.      @second(e)        Return the number of seconds since the
  1282.                        last full minute, encoded as 0 to 59.
  1283.  
  1284.      Spreadsheet Update
  1285.      Re-evaluation of spreadsheet expressions is done by row or
  1286.      by column depending on the selected calculation order.
  1287.      Evaluation is repeated up to iterations times for each
  1288.      update if necessary, so forward references usually work as
  1289.      expected.  See set above.  If stability is not reached after
  1290.      ten iterations, a warning is printed.  This is usually due
  1291.      to a long series of forward references, or to unstable
  1292.      cyclic references (for example, set A0's expression to
  1293.      ``A0+1'').
  1294.  
  1295. SEE ALSO
  1296.      psc(1)
  1297.  
  1298. BUGS
  1299.      Top-to-bottom, left-to-right evaluation of expressions is
  1300.      silly.  A proper following of the dependency graph with
  1301.      (perhaps) recourse to relaxation should be implemented.
  1302.  
  1303.      Supports at most 200 rows and 40 columns.
  1304.  
  1305.      Editing is crude.  All you can do is backspace over and
  1306.      retype text to be altered.  There is no easy way to switch a
  1307.      leftstring to a rightstring or vice versa.  Of course, you
  1308.      can always write the spreadsheet to a file with Put, edit it
  1309.      by calling an editor on the file with ``!'', and read it
  1310.      back with Get -- if you are comfortable editing spreadsheet
  1311.      files.
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317. 20
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                                                             SC(1)
  1325.  
  1326.  
  1327.  
  1328.      Only one previous value is saved from any call of @ext().
  1329.      If it is used more than once in a spreadsheet and external
  1330.      functions are enabled and later disabled, the last returned
  1331.      value pops up in several places.
  1332.  
  1333.      On some systems, if the cell cursor is in column 0 with top-
  1334.      line enabled (so the current cell is highlighted), or if any
  1335.      cell in column 0 is highlighted, the corresponding row
  1336.      number gets displayed and then blanked during a screen
  1337.      refresh.  This looks like a bug in curses.
  1338.  
  1339.      Many commands give no indication (a message or beep) if they
  1340.      have null effect.  Some should give confirmation of their
  1341.      action, but they don't.
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                                                21
  1384.  
  1385.  
  1386.  
  1387.