home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 200_01 / user.man < prev   
Text File  |  1979-12-31  |  101KB  |  3,403 lines

  1.  
  2.  
  3.  
  4.  
  5.        Introduction                             1
  6.  
  7.  
  8.        1.  IIIInnnnttttrrrroooodddduuuuccccttttiiiioooonnnn
  9.  
  10.        SCI is a    C language interpreter that supports a very  usable
  11.        subset  of  C.    It  is a fully interactive interpreter that
  12.        includes    a powerful full    screen editor and a  program  trace
  13.        facility.   SCI    was  meant  to    be a stepping stone for    the
  14.        experienced BASIC programmer who    is ready  to  venture  into
  15.        the exciting world of C!
  16.  
  17.        SCI will    run on any MS-DOS or PC-DOS  computer  that  has  a
  18.        minimum     of   64Kbytes     of   RAM,  although  128Kbytes     is
  19.        recommended.  The available free     memory     (that    portion     of
  20.        memory  not used    by the interpreter's code and data storage)
  21.        is automatically    divided    among "user progam code", "variable
  22.        table",    "function  table"  and "stack" memory segments.     If
  23.        necessary, the sizes of these segments  may  be    changed     at
  24.        program     startup,   however  their  total  may    not  exceed
  25.        64Kbytes.
  26.  
  27.        The integrated full-screen  editor  does     require  that    the
  28.        terminal     emulation  firmware in    your computer be capable of
  29.        recognizing certain  terminal  control  character  sequences
  30.        (also  known  as     "escape  sequences")  that  perform cursor
  31.        positioning and erasing of portions of the screen.  See    the
  32.        installation  instructions  in  the "Editor" section of this
  33.        manual.
  34.  
  35.        The SCI interpreter is very  similar  to     BASIC    internally.
  36.        Each  line  of  input  is  first     scanned and "tokenized", a
  37.        process in  which  language  elements  (numbers,     variables,
  38.        keywords, etc.) are converted to    "tokens".  These tokens    are
  39.        easier  to  handle  by  a  computer  than  arbitrarily  long
  40.        character  sequences.  Unlike BASIC however, SCI    programs do
  41.        not require line    numbers    - the program flow is  directed     by
  42.        SCI  purely  through  the  structured programming constructs
  43.        inherent    in  the     C  language.    This  tokenization  process
  44.        allows  SCI  to run much    faster than other interpreters that
  45.        deal with the raw program text.    However, the C language    was
  46.        never  designed    to  be    an interpreted programming language
  47.        like BASIC was, and the price that must    be  paid  for  this
  48.        advantage  is in    the form of incompatibilities with standard
  49.  
  50.  
  51.        __________
  52.  
  53.     0. "The    C Programming Language"    by Brian W. Kernighan &
  54.        Dennis M. Ritchie, published    by Prentice-Hall, Inc.
  55.  
  56.  
  57.  
  58.  
  59.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.        2                          Introduction
  69.  
  70.  
  71.        C as defined by Kernighan and Ritchie[0].
  72.  
  73.        1.1  SSSSttttaaaarrrrttttiiiinnnngggg OOOOuuuutttt
  74.  
  75.        The files contained on the distribution diskette    are:
  76.  
  77.            SCI.EXE           the interpreter program
  78.            SHELL.SCI       the command shell, written in SCI's
  79.                    dialect of C
  80.            CALC.SCI           a sample    calculator program, also
  81.                    written in "SCI C"
  82.            USER.MAN           User's Manual
  83.            PROG.MAN           Programmer's Manual
  84.  
  85.        As always, it is    a good idea to make  a    working     copy,    and
  86.        then store your distribution diskette in    a safe place.
  87.  
  88.        To start    up SCI,    make sure that the file     SHELL.SCI  resides
  89.        on   the     current  drive     and  then  execute  SCI.EXE.    The
  90.        interpreter will    then read and  execute    the  C    program     it
  91.        finds  in  SHELL.SCI.   The program provided for    you in this
  92.        file contains several items of  information  needed  by    the
  93.        built  in  editor,  as  well as some other useful functions.
  94.        The  program  in     SHELL.SCI  that  gets    executed   by    the
  95.        interpreter is simply an    endless    loop that prompts you for a
  96.        line of input from the console  and  hands  it  off  to    the
  97.        interpreter  for     execution.   Actually    this function could
  98.        have been performed  by    the  SCI  program  itself,  but     by
  99.        placing    this routine outside of    the executable program,    you
  100.        have the    option of customizing the interpreter to suit  your
  101.        tastes.    The shell will be discussed in more detail later.
  102.  
  103.        You may also specify a different    program     file  for  SCI     to
  104.        execute    on  startup.   By  typing  the    following operating
  105.        system command line, for    example:
  106.  
  107.            A>SCI B:STARTUP
  108.  
  109.        the interpreter will  search  disk  B:  for  a  file  called
  110.        STARTUP    and  execute  it  in  lieu of the default SHELL.SCI
  111.        file.  Be aware,    however, that the standard  SHELL.SCI  file
  112.        contains      many     often-used   operating      system  interface
  113.        functions that  must  be     copied     over  to  your     customized
  114.        startup    program     if  they  are    going  to  be  used by that
  115.        program.     See the section on Library Functions for a list of
  116.        these functions.
  117.  
  118.  
  119.  
  120.  
  121.  
  122.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.        Introduction                             3
  132.  
  133.  
  134.        1.2  MMMMeeeemmmmoooorrrryyyy AAAAllllllllooooccccaaaattttiiiioooonnnn
  135.  
  136.        The  interpreter     automatically    divides     up  whatever  free
  137.        memory  is  available  (after  SCI  is  loaded)    among  four
  138.        segments    for use    by your    programs and data.  These  segments
  139.        are:  the  Program  Code, Variable Table, Function Table    and
  140.        Stack.  The Program  Code  segment  contains  the  tokenized
  141.        version    of  your program code.    The Variable Table contains
  142.        information about all  "active"    variables.   Each  function
  143.        takes  up exactly one entry in the Function Table.  Finally,
  144.        memory requirement for  the  Stack  segment  will  grow    and
  145.        shrink as your program executes.     The stack is used only    for
  146.        temporary storage when expressions are evaluated.
  147.  
  148.        If the interpreter complains about  "out     of  memory",  "too
  149.        many  variables",  "too many functions" or "stack overflow",
  150.        you may be able to circumvent the problem by telling SCI    how
  151.        much  memory  to    assign to each of these    four segments using
  152.        the following MS-DOS command line options:
  153.  
  154.            -P nnnn - assign    "nnnn" decimal bytes for program storage.
  155.            -V nn   - allow space for a maximum of "nn" variables.
  156.            -F nn   - allow space for a maximum of "nn" functions.
  157.            -S nn   - set the stack size to "nn".
  158.  
  159.  
  160.        For example the command line:
  161.  
  162.            A>SCI -P    8000 -V    30 -F 80 -S 40
  163.  
  164.        will reserve 8000 bytes for program storage, allow a maximum
  165.        of 30 variables to be active at one time, allow a maximum of
  166.        80 function declarations    and leave 40 stack entries.  Please
  167.        be aware    that each stack    entry requires 5 bytes of RAM, each
  168.        variable    table entry 14 bytes and each function table  entry
  169.        8  bytes     of  RAM.   Thus,  in  the example above, the total
  170.        amount of RAM required by SCI's tables are 8000    +  14x30  +
  171.        8x80  +    4x40  =    9260 bytes; The    total amount of    RAM for    all
  172.        SCI tables may not exceed 65,535    (64K) bytes.
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.        4                             The Shell
  195.  
  196.  
  197.        2.  TTTThhhheeee SSSShhhheeeellllllll
  198.  
  199.        The stock version of the    shell program in  SHELL.SCI  simply
  200.        displays    a prompt on the    console, reads a line of input,    and
  201.        attempts    to execute the input line.  When SCI is    started    up,
  202.        it  reads  the  shell  file and executes    it.  The shell file
  203.        will then print an identification banner, like so:
  204.  
  205.            SCI V1.5    20Oct86    Copyright (C) 1986 Bob Brodt
  206.            SCI shell V1.5 20Oct86 Copyright    (C) 1986 Bob Brodt
  207.            sci>
  208.  
  209.        The prompt "sci>" tells you  that  the  shell  is  ready     to
  210.        accept commands.
  211.  
  212.        The shell maintains your    program    in its "program    buffer"     in
  213.        memory.     Initially, this buffer    is empty so you    must either
  214.        create a    program    using SCI's editor or retrieve a previously
  215.        created    program    from disk.  Before you exit from the shell,
  216.        be sure to save your program on disk or the contents of    the
  217.        program buffer will be lost.
  218.  
  219.        The standard shell recognizes four commands: "edit", "list",
  220.        "load",    "save",     "dir"    and "exit".  These are functionally
  221.        similar to  the    BASIC  commands:  "EDIT",  "LIST",  "LOAD",
  222.        "SAVE",    "FILES"     and  "SYSTEM"    respectively.  Later as    you
  223.        become more familiar with the C language, you  may  wish     to
  224.        modify the shell    program    and add    your own commands.
  225.  
  226.        Anything    else typed at the shell    prompt is assumed to  be  a
  227.        valid C statement and is    handed off to the interpreter to be
  228.        executed.
  229.  
  230.        2.1  SSSShhhheeeellllllll CCCCoooommmmmmmmaaaannnnddddssss
  231.  
  232.        Listed here are the shell  commands.   In  the  descriptions
  233.        below,  anything     enclosed  in  square brackets ([ and ]) is
  234.        optional    and anything enclosed in angle brackets    (<  and     >)
  235.        is  a  verbose  description  of    the  item  required  by    the
  236.        command.
  237.  
  238.        _e_d_i_t [<_l_i_n_e#>]
  239.  
  240.        The "edit" command invokes SCI's    built-in screen    editor (see
  241.        the "Editor" section in the User's Manual for more details).
  242.        If the word "edit" is  followed    with  a     line  number,    the
  243.        editor  will  start up by displaying the    page of    the program
  244.        that contains the line number, and move the cursor  to  that
  245.  
  246.  
  247.  
  248.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.        The Shell                             5
  258.  
  259.  
  260.        line.   If  the    requested  line     number    is greater than    the
  261.        number of lines in the program buffer, the last page of    the
  262.        program is displayed.
  263.  
  264.        list [<from_line#>] [<to_line#>]
  265.  
  266.        This command lists the  program    currently  in  the  program
  267.        buffer  on  the    screen in its entirety.     The listing may be
  268.        stoped by pressing any key.  If the word    "list" is  followed
  269.        by one number, the listing starts at that line number in    the
  270.        program.     If two    numbers    separated by  one  or  more  spaces
  271.        follow "list", the program listing will start with the first
  272.        and end with the    second line number in the program.
  273.  
  274.        _l_o_a_d <_f_i_l_e_n_a_m_e>
  275.  
  276.        The "load" command will load the     program  buffer  from    the
  277.        given disk file name.  This command will    destroy    the current
  278.        contents    of the program buffer.    If the file name is omitted
  279.        or  the    file  is not found, SCI    will display a "file error"
  280.        message and erase the program buffer.  This command  can     be
  281.        used  to     intentionally    erase  the program buffer by simply
  282.        omitting    the <filename>.
  283.  
  284.        _s_a_v_e <_f_i_l_e_n_a_m_e>
  285.  
  286.        This will write the contents of the program  buffer  out     to
  287.        the  named  disk     file.     If the    file name is omitted or    the
  288.        file  can't  be    created,  SCI  displays     the  "file  error"
  289.        message.      This command does not    alter the program buffer in
  290.        memory.
  291.  
  292.        NOTE: Programs that are "save"d by  SCI    are  ordinary  text
  293.        files, suitable for editing with    your favourite text editor.
  294.  
  295.        _d_i_r [<_f_i_l_e_s_p_e_c>]
  296.  
  297.        The "dir" command is exactly the    same as    in MS-DOS with    the
  298.        exception that no file attribute    information (size, creation
  299.        date, etc) is displayed,    only the file name.
  300.  
  301.        _e_x_i_t
  302.  
  303.        This command returns you    to the MS-DOS  command    level.     If
  304.        anything     was left in the shell's program buffer, it will be
  305.        lost unless you have previously "save"ed    it in a    disk file.
  306.  
  307.  
  308.  
  309.  
  310.  
  311.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.        6                             The Shell
  321.  
  322.  
  323.        2.2  RRRRuuuunnnnnnnniiiinnnngggg YYYYoooouuuurrrr PPPPrrrrooooggggrrrraaaammmm
  324.  
  325.        A C program is simply  a     collection  of     "functions"  which
  326.        (hopefully) all participate to successfully perform a single
  327.        task.  In "standard" C, every program must have one and only
  328.        one  function called "main".  This is where the program will
  329.        start executing from.  In SCI's    C,  you     need  not  have  a
  330.        "main"  function     because SCI allows you    to run any function
  331.        in the program buffer by    simply typing its name at  the    SCI
  332.        input  prompt.    Suppose    for example that our program buffer
  333.        contained only the following two    functions:
  334.  
  335.            hex(n)
  336.            {
  337.                printf("%d = %x Hexadecimal\n",n,n);
  338.            }
  339.  
  340.            oct(n)
  341.            {
  342.                printf("%d = %o Octal\n",n,n);
  343.            }
  344.  
  345.        We could    execute    any of these functions from  the  shell     by
  346.        simply typing, for example:
  347.  
  348.            sci> hex(256)
  349.            256 = 100 Hexadecimal
  350.            sci>
  351.  
  352.        Note that we showed the    shell's     prompt     (sci>)     above    for
  353.        demonstration purposes only; don't type "sci>"!
  354.  
  355.        From the    above example, you can see that    an SCI    program     is
  356.        simply  a  collection  of  not necessarily related functions
  357.        that can    be run and debuged individually    or  in    combination
  358.        with  other  functions  in  the program buffer.    Thus if    you
  359.        plan to transport your program to a standard C compiler,     be
  360.        sure to include a "main"    function in the    final product.
  361.  
  362.        2.3  PPPPrrrrooooggggrrrraaaammmm VVVVaaaarrrriiiiaaaabbbblllleeeessss
  363.  
  364.        The interpreter always clears to    zero all program  variables
  365.        before    each  shell  statement    is  executed.    So  if    you
  366.        initialize a variable from the shell, the same variable will
  367.        be  set    to  zero  again     before    the very next "c" statement
  368.        entered from the    shell.
  369.  
  370.  
  371.  
  372.  
  373.  
  374.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.        The Shell                             7
  384.  
  385.  
  386.        To illustrate, assume we    have the following program  in    the
  387.        program buffer:
  388.  
  389.            int total;
  390.  
  391.            sum(n)
  392.            {
  393.                total = total + n;
  394.            }
  395.  
  396.        This program uses the variable "total"  to  keep     a  running
  397.        total  of  numbers.  However, repeated calls to "sum()" from
  398.        the shell would be futile since the interpreter would always
  399.        set "total" to zero before each call.
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.        8                            The    Editor
  447.  
  448.  
  449.        3.  TTTThhhheeee EEEEddddiiiittttoooorrrr
  450.  
  451.        SCI's built in editor is    screen oriented    and is    similar     to
  452.        the  "standard"    set by the popular WORDSTAR word processor.
  453.        The editor can be modified to work with almost any  personal
  454.        computer,  by  simply  changing    some variables in the shell
  455.        file  (SHELL.SCI).    This   section   will   describe    the
  456.        installation  procedure and give    needed information for some
  457.        of the more common personal computers.
  458.  
  459.        3.1  KKKKeeeeyyyyssss
  460.  
  461.        The alphabetic character    keys  on  your    PC's  keyboard    are
  462.        probably     arranged in a typewriter keyboard pattern as shown
  463.        below.    All  editing  commands    (cursor     motion,  deleting,
  464.        inserting,  etc.)  are  control-key combinations    (i.e. press
  465.        and hold    the CONTROL key    and then press a letter     key).     In
  466.        this  manual,  we  will    use  an    up arrow, or circumflex    (^)
  467.        followed    by a letter to indicate    that  the  keystroke  is  a
  468.        control-key  combination.   In  the  keyboard diagram below,
  469.        only the    letter keys marked  with  a  circumflex     are  valid
  470.        editing    command     control-keys.    What each of these control-
  471.        keys does will be explained in detail later.
  472.  
  473.        ----------------------------------------------
  474.        |                        |
  475.        | -----------------------------------------  |
  476.        | | ^Q| ^W| ^E| ^R| T | ^Y| U | I | O | P |  |
  477.        | -----------------------------------------  |
  478.        |   | ^A| ^S| ^D| ^F| ^G| ^H| J | ^K| ^L|    |
  479.        |   -------------------------------------    |
  480.        |      |    ^Z| ^X|    ^C| ^V|    ^B| N |    M |        |
  481.        |      -----------------------------        |
  482.        |                        |
  483.        ----------------------------------------------
  484.  
  485.        3.2  SSSSccccrrrreeeeeeeennnn LLLLaaaayyyyoooouuuutttt
  486.  
  487.        The editor uses all of the screen, except for the last line,
  488.        as  a  window  into  your  program.  The    last screen line is
  489.        reserved    for status and prompts.     The status line is divided
  490.        into several fields as shown below.  The     current  line    and
  491.        column numbers are updated only if you haven't pressed a    key
  492.        within the last two seconds or so.  This    lets you enter text
  493.        or commands at typamatic    speeds without slowing you down.
  494.  
  495.        If an error should occur    while you are editing your program,
  496.        the  status  line  will    be  erased  and     the  error message
  497.  
  498.  
  499.  
  500.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.        The Editor                             9
  510.  
  511.  
  512.            L:nnnn C:nn  Insert  Mark:nnnn:nnnn
  513.          |    |     |         |
  514.          |    |     |        line numbers of start and
  515.          |    |     |        end    of a marked block
  516.          |    |     |
  517.          |    |   insert/replace mode    indicator
  518.          |    |
  519.          |    current column number
  520.          |
  521.            current line number
  522.  
  523.        displayed in its    place.    You must then hit the <ESCAPE>    key
  524.        to  acknowledge    that you have seen the error message before
  525.        you  may     continue  editing.   Also,  if     the  editor  needs
  526.        information  from  you  (such  as  search strings, etc.)    the
  527.        appropriate prompts will    appear in the status line.
  528.  
  529.        3.3  SSSSccccrrrreeeeeeeennnn CCCCuuuussssttttoooommmmiiiizzzzaaaattttiiiioooonnnn
  530.  
  531.        Modern computer terminals allow a programmer  to     manipulate
  532.        the  cursor  and     text  displayed  on the screen    by means of
  533.        specific    character sequences sent to  the  terminal.   These
  534.        character  sequences  are  known     interchangably    as "control
  535.        codes" or "escape sequences".
  536.  
  537.        Most personal computers have a program in ROM that  emulates
  538.        a  specific terminal's control codes. In    the case of the    IBM
  539.        PC, this    emulation program is a "device driver"    program     on
  540.        disk,  known as "ANSI.SYS", and must be loaded into RAM when
  541.        PC-DOS is first booted up.  See your IBM    PC-DOS    manual    for
  542.        installation procedures of this device driver.
  543.  
  544.        Your personal computer must have    as a minimum, control codes
  545.        to  directly position the cursor    anywhere on the    screen,    and
  546.        either an "erase    to end of line"    or "erase to end of screen"
  547.        control code.  The "erase to end    of line" code must clear to
  548.        spaces all character locations to the right of and including
  549.        the  cursor  postion.  The  "erase to end of screen" control
  550.        code performs an    "erase to end of line"    function  and  then
  551.        erases  all lines below the current line    to spaces.  If your
  552.        terminal    recognizes both    of these erase control    codes,    use
  553.        "erase  to  end of screen" instead of "erase to end of line"
  554.        because it is slightly faster.
  555.  
  556.        If your computer    does  not  provide  these  minimal  control
  557.        codes, SCI's built in editor can    not be used.  In this case,
  558.        you must    resort to using    your own text editor to     write    and
  559.        modify your programs.
  560.  
  561.  
  562.  
  563.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.        10                             The Editor
  573.  
  574.  
  575.        Your PC may  also  have    control     codes    that  perform  more
  576.        complicated   functions     such  as  inserting  and  deleting
  577.        characters and  lines.    These  are  not     really     necessary,
  578.        however    the editor is designed to take advantage of them if
  579.        they exist.  You    may need  to  do  some    experimenting  with
  580.        different combinations of escape    sequence to achieve optimum
  581.        speed performance from the editor.
  582.  
  583.        A Terminal's control codes are made known to the    SCI  editor
  584.        by  way    of  system global program variables.  These program
  585.        variables must  be  declared  in     your  shell  program  file
  586.        (normally  SHELL.SCI) before the    "entry"    keyword    and must be
  587.        assigned    values in the mainline shell program (the  function
  588.        "main"  in  SHELL.SCI).     There    is  one     variable  for each
  589.        control code. If    your PC    does not have a    particular  control
  590.        code,  that  corresponding  variable should not be declared.
  591.        All variables must be declared as character  pointers  (i.e.
  592.        "char  *")  with    the exception of "_nr",    "_nc", "_ro", "_co"
  593.        and _mhz, which are all "char's".  The  variable     names    and
  594.        their corresponding control code    function are listed below:
  595.  
  596.        _cp     cursor postion.
  597.  
  598.        _el     erase to    end of line.
  599.  
  600.        _es     erase to    end of screen.
  601.  
  602.        _dc     delete the character under the cursor and move  left
  603.            all characters to the right of the cursor.
  604.  
  605.        _dl     delete the line the cursor is on     and  move  up    all
  606.            lines below it.
  607.  
  608.        _ic     insert a    character before the one under    the  cursor
  609.            and  move  all  characters  to the right. The cursor
  610.            must remain  at    the  same  position  (i.e.  at    the
  611.            inserted    character).
  612.  
  613.        _il     insert a    line before the    one the    cursor    is  on    and
  614.            move all    lines below it down. The cursor    must remain
  615.            at the same position  (i.e.  on    the  newly  created
  616.            blank line).
  617.  
  618.        _bl     rings  the  console  bell.   If    this  variable     is
  619.            omitted,     the  standard    ASCII BEL character will be
  620.            used (octal 007).  You may also wish  to     flash    the
  621.            screen  momentarily  to a different color if your PC
  622.            has color or reverse video capabilities.
  623.  
  624.  
  625.  
  626.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.        The Editor                             11
  636.  
  637.  
  638.        _nr     number of rows (lines)  on  the    screen.     Typically,
  639.            this is set to 24 (use 25 for the IBM PC).
  640.  
  641.        _nc     number of columns, usually 80 but may be    set  to     40
  642.            on the IBM PC if    you are    in 40 column mode.
  643.  
  644.        _ro     row offset. The cursor position control code assumes
  645.            that  the  screen  "home" position (top left corner)
  646.            starts at 0,0.  If this is not the case for your     PC
  647.            you   can  add  this  offset,  otherwise     omit  this
  648.            variable.
  649.  
  650.        _co     column offset, same as above.
  651.  
  652.        _mhz    CPU speed (in Megahertz)    of your    PC.  This  variable
  653.            controls     the frequency at which    the editor's status
  654.            line is updated.
  655.  
  656.        As mentioned earlier, the above variables  are  pointers     to
  657.        characters  which  should be assigned in    your shell mainline
  658.        program.     The assigned character    strings    may contain any     of
  659.        the data    conversion codes recognized by the Library Function
  660.        "printf()".  See    the section on Sample Configurations  below
  661.        for examples.
  662.  
  663.        3.4  KKKKeeeeyyyybbbbooooaaaarrrrdddd CCCCuuuussssttttoooommmmiiiizzzzaaaattttiiiioooonnnn
  664.  
  665.        In addition, if    any  of     the  character     pointer  variables
  666.        "_ka",  "_kb", ... "_kz"    are declared, the string pointed at
  667.        by these    variables is assumed to    be the    character  sequence
  668.        sent  by     a  function  key  on  your  keyboard  and  will be
  669.        recognized as an    alias of the  corresponding  control-letter
  670.        key combination.
  671.  
  672.        For  example,  The  VT-100  terminals  send  the      character
  673.        sequence:  "ESCAPE  [  A",  "ESCAPE  [  B", "ESCAPE [ C"    and
  674.        "ESCAPE [ D" for    the up,    down  right  and  left    arrow  keys
  675.        respectively.  So,  instead  of    typing ^E, ^X, ^D and ^S to
  676.        move the    cursor    around,     we  could  declare  the  following
  677.        variables:
  678.  
  679.        char *_ke, *_kx,    *_kd, *_ks;
  680.  
  681.        _ke="\033[A";  #    alias for ^E
  682.        _kx="\033[B";  #    alias for ^X
  683.        _kd="\033[C";  #    alias for ^D
  684.        _ks="\033[D";  #    alias for ^S
  685.  
  686.  
  687.  
  688.  
  689.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.        12                             The Editor
  699.  
  700.  
  701.        and then    use the    VT-100's arrow    keys  instead.     Similarly,
  702.        other   keyboard      function   keys  that     transmit  multiple
  703.        characters or single  control  characters  can  be  used     to
  704.        perform other editor functions.
  705.  
  706.        3.5  SSSSaaaammmmpppplllleeee CCCCoooonnnnffffiiiigggguuuurrrraaaattttiiiioooonnnnssss
  707.  
  708.        This section contains the data declarations and    assignments
  709.        required    by some    of the more common personal computers.    The
  710.        data declarations must be made before the "entry" keyword in
  711.        SHELL.SCI,  and the variable assignments    must be    done within
  712.        the function immediately    following the "entry" keyword.    For
  713.        example,     the  figure  below shows the configuration for    the
  714.        IBM PC in the distribution version of the SHELL.SCI file.
  715.  
  716.        char _nr,_nc,_ro,_co,*_cp,*_el;    <--editor variable declarations
  717.            .
  718.            .
  719.        <Library    Function declarations>
  720.            .
  721.            .
  722.        entry               <--Note the "entry" keyword here!
  723.        main()
  724.        {
  725.            .
  726.            .
  727.            _nr=25;           <--editor variable assignments
  728.            _nc=80;
  729.            _ro=1;
  730.            _co=1;
  731.            _cp="\033[%d;%dH";
  732.            _el="\033[0K";
  733.  
  734.            for (;;)    {
  735.                .
  736.                .
  737.            <main program loop>
  738.                .
  739.                .
  740.            }
  741.        }
  742.  
  743.        Only a skeleton of the file is shown here so  that  you    can
  744.        see   the   relative  locations    of  the     editor     variables'
  745.        declarations and    assignments.  Note  that  the  declarations
  746.        must  appear  somewhere    before the "entry" keyword, and    the
  747.        control    character  strings  must  be  assignmed     to   these
  748.        variables  somewhere  before  the  start    of the main program
  749.  
  750.  
  751.  
  752.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.        The Editor                             13
  762.  
  763.  
  764.        loop.
  765.  
  766.        In the sample configuration listings that follow,  only    the
  767.        control character string    assignments are    shown for brevity.
  768.  
  769.        3.5.1  _I_B_M__P_C
  770.  
  771.        The IBM PC is  probably    the  most  common.  Note  that    the
  772.        ANSI.SYS     device    driver must be installed for the SCI editor
  773.        to work.
  774.  
  775.        _nr=25;          # the    PC has 25 lines
  776.        _nc=80;          # of 80 columns each
  777.        _ro=_co=1;      # row/column numbering starts    at 1
  778.        _cp="\033[%d;%dH"; # esc. seq. to position cursor
  779.        _el="\033[0K";      # esc. seq. to erase to end of line
  780.  
  781.        3.5.2  _D_E_C__R_a_i_n_b_o_w__1_0_0
  782.  
  783.        Digital Equipment Corp.s' Rainbow 100 recognizes    a subset of
  784.        the  American  National    Standards  Institute (ANSI) Control
  785.        Sequences for Video Terminals (X3.64).
  786.  
  787.        _nr=24;
  788.        _nc=80;
  789.        _ro=1;
  790.        _co=1;
  791.        _cp="\033[%d;%dH"; # position cursor
  792.        _es="\033[J";   # erase to end of screen
  793.        _il="\033[M";   # insert    a line
  794.        _ic="\033[4h%c\033[4l"; # insert    a character
  795.        _dc="\033[P";   # delete    a character
  796.        _bl="\033[?5h\033[?5l"; # bell flashes screen momentarily
  797.        _ke="\033[A";   # up-arrow key
  798.        _kx="\033[B";   # down-arrow key
  799.        _kd="\033[C";   # right-arrow key
  800.        _ks="\033[D";   # left-arrow key
  801.  
  802.        3.5.3  _H_e_a_t_h__H_1_9
  803.  
  804.        _nr=24;
  805.        _nc=80;
  806.        _ro=' ';
  807.        _co=' ';
  808.        _cp="\033Y%c%c";    # position cursor
  809.        _es="\033E";    # erase    to end of screen
  810.  
  811.  
  812.  
  813.  
  814.  
  815.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.        14                             The Editor
  825.  
  826.  
  827.        3.5.4  _Z_e_n_i_t_h__P_C
  828.  
  829.        _nr=24;
  830.        _nc=80;
  831.        _ro=' ';
  832.        _co=' ';
  833.        _cp="\033Y%c%c";    # position cursor
  834.        _es="\033E";    # erase    to end of screen
  835.        _il="\033L";    # insert line
  836.        _dl="\033M";    # delete line
  837.  
  838.        3.5.5  _T_e_l_e_v_i_d_e_o__9_1_0
  839.  
  840.        _nr=24;
  841.        _nc=80;
  842.        _ro=' ';
  843.        _co=' ';
  844.        _cp="\033=%c%c";    # position cursor
  845.        _el="\033T";    # erase    to end of line
  846.  
  847.        3.6  EEEEddddiiiittttoooorrrr CCCCoooommmmmmmmaaaannnnddddssss
  848.  
  849.        Now that    you have  modified  the     file  SHELL.SCI  for  your
  850.        particular  terminal,  you are ready to use the editor. This
  851.        section describes all of    the editor's commands in detail.
  852.  
  853.        All of the  editor  commands  are  control-key  combinations
  854.        (press  and  hold  the  CONTROL    key while pressing a letter
  855.        key).  We will use an up    arrow, or circumflex  (^)  followed
  856.        by  a letter to indicate    that the keystroke is a    control-key
  857.        combination.  All  other     non-printing  keys,  such  as    the
  858.        <RETURN>    and <BACKSPACE>    keys, will be in UPPERCASE.
  859.  
  860.        3.6.1  _E_x_i_t_i_n_g__f_r_o_m__t_h_e__E_d_i_t_o_r
  861.  
  862.        To exit the editor and return to    the SCI    shell, type a ^Z.
  863.  
  864.        3.6.2  _C_u_r_s_o_r__M_o_v_e_m_e_n_t
  865.  
  866.        ^E      move cursor up to previous line.    Screen scrolls down
  867.            if cursor is at the top of the screen.
  868.  
  869.        ^X      move cursor down    to next    line. Screen scrolls up     if
  870.            cursor is at the    bottom of the screen.
  871.  
  872.        ^S      move cursor  left  one  character  position.  Cursor
  873.            stops at    left margin.
  874.  
  875.  
  876.  
  877.  
  878.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.        The Editor                             15
  888.  
  889.  
  890.        ^D      move cursor right  one  character  position.  Cursor
  891.            stops at    right margin.
  892.  
  893.        ^A      move cursor  to    beginning  of  previous     "word".  A
  894.            "word"  is  defined  as    a  continuous  sequence     of
  895.            alphanumeric characters (i.e. letters and numbers  -
  896.            no punctuation).
  897.  
  898.        ^F      move cursor to beginning    of next    word.
  899.  
  900.        ^R      move cursor one page (the height    of the display)     up
  901.            towards the beginning of    the program.
  902.  
  903.        ^C      move cursor one page down, towards the  end  of    the
  904.            program.
  905.  
  906.        <RETURN>    or <LINEFEED> if the status  line  shows  "Replace"
  907.            mode  instead  of "Insert", these keys will move    the
  908.            cursor down to the beginning of the next    line.
  909.  
  910.        3.6.3  _I_n_s_e_r_t_i_n_g__a_n_d__D_e_l_e_t_i_n_g
  911.  
  912.        ^V      toggles Insert/Replace mode. The    status line at    the
  913.            bottom of the screen will indicate the current mode.
  914.            In Insert mode, any  characters    you  type  will     be
  915.            inserted     before     the  current  cursor position.     In
  916.            Replace mode, old characters on a  line    are  simply
  917.            overwritten as you enter    text.
  918.  
  919.        ^G      delete the character under the  cursor.    The  cursor
  920.            stays in    the same position.
  921.  
  922.        ^H or <BACKSPACE> delete    the character to the  left  of    the
  923.            cursor and move the cursor left one character.
  924.  
  925.        ^Y      delete the current line.    The  cursor  stays  at    the
  926.            same  line.   Note that the <EOF> mark at the end of
  927.            the program can not be deleted.
  928.  
  929.        ^L      restore the original line if the    cursor has not been
  930.            moved off the line.
  931.  
  932.        <RETURN>    or <LINEFEED> if the  status  line  shows  "Insert"
  933.            mode,  these  keys  will     insert    a new blank line as
  934.            follows:     If the    cursor is at line one,    column    one
  935.            (top,   left-most   column)   when   a  <RETURN>     or
  936.            <LINEFEED> is pressed, a    new blank line is  inserted
  937.            above  the  current  line;  everywhere else, the    new
  938.  
  939.  
  940.  
  941.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.        16                             The Editor
  951.  
  952.  
  953.            line is inserted    below the current line.     The cursor
  954.            will  rest  on  the newly inserted line and directly
  955.            below the first non-space character in the  previous
  956.            line.
  957.  
  958.        3.6.4  _E_x_t_e_n_d_e_d__M_o_v_e_m_e_n_t
  959.  
  960.        The extended cursor motion commands require two    control-key
  961.        keystrokes.   The first is always a ^Q (mnemonic    for Quickly
  962.        move somewhere),    and the    second can be one of the following:
  963.  
  964.        ^F      find a character    sequence.  The cursor will move     to
  965.            the status line's prompt/error message field and    you
  966.            will be prompted    for the    character  sequence  to     be
  967.            searched      for.     The  search  starts  at  the  next
  968.            character position to the right of the cursor on    the
  969.            current line.  When the character sequence is found,
  970.            the cursor will rest on the first character  of    the
  971.            sequence.
  972.  
  973.        ^A      find  and  replace  character  sequence.      You    are
  974.            prompted     for  the character sequence to    be searched
  975.            for,  as     above.     Next  you  are     prompted  for    the
  976.            character  sequence  that  will    replace     the search
  977.            string.    Finally, you have the option of     performing
  978.            the  search/replace  "globally"    that  is  for every
  979.            occurance in the    program.
  980.  
  981.        ^L      find  next   occurence    of   previously      specified
  982.            character  sequence.   You  will    not be prompted    for
  983.            the sequence to be searched for.
  984.  
  985.        ^G      go to a specified line.    You are     prompted  for    the
  986.            line  number  to    be displayed.  The cursor will rest
  987.            on the requested    line usually in    the center  of    the
  988.            screen.
  989.  
  990.        ^S      move cursor to beginning    of current line.
  991.  
  992.        ^D      move cursor to end of current line.
  993.  
  994.        ^E      move cursor to top of screen.
  995.  
  996.        ^X      move cursor to bottom of    screen.
  997.  
  998.        ^R      move cursor to first line of program.
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.        The Editor                             17
  1014.  
  1015.  
  1016.        ^C      move cursor so that the last page of the    program     is
  1017.            displayed.
  1018.  
  1019.        ^B      move cursor to the beginning of a marked    block.
  1020.  
  1021.        ^K      move cursor to the end of a marked block.
  1022.  
  1023.        3.6.5  _B_l_o_c_k__a_n_d__M_i_s_c_e_l_l_a_n_e_o_u_s__C_o_m_m_a_n_d_s
  1024.  
  1025.        These commands also require two control-key  keystrokes    and
  1026.        include block marking, inserting/deleting and some "too late
  1027.        to classify" commands.
  1028.  
  1029.        Unlike the popular WORDSTAR  word  processor,  SCI's  editor
  1030.        treats  blocks  as  groups  of  lines  instead  of groups of
  1031.        characters.  That is, a block starts at the beginning  of  a
  1032.        line and    includes all characters    up to the end of a line.
  1033.  
  1034.        The first of these two-keystroke    block commands must be a ^K
  1035.        (mnemonic for blocK (?))    and the    second may be one of:
  1036.  
  1037.        ^B      mark beginning of a block. The status line will show
  1038.            the line    number of the beginning    of the block.
  1039.  
  1040.        ^K      mark end    of a block. The    status line is    updated     to
  1041.            show the    line number of the end of the block.
  1042.  
  1043.        ^V      make a copy of a    marked block and insert     it  before
  1044.            the  current  line.  You     may  not  copy     a block to
  1045.            itself: for example if the block    starts    at  line  3
  1046.            and  ends  at  line  10    and the    cursor is currently
  1047.            resting on line 5, you will be severely beeped at by
  1048.            the editor.
  1049.  
  1050.        ^Y      delete the marked block.
  1051.  
  1052.        ^U      "unmark"    the block. The block markers (if  any)    are
  1053.            removed from the    status line display.
  1054.  
  1055.        ^R      read a file from    disk and insert    its contents before
  1056.            the  current  line  in  the  program.   You  will be
  1057.            prompted    for the    file name.
  1058.  
  1059.        ^W      write the marked    block to a disk    file.  You will     be
  1060.            prompted    for the    file name.
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.        18                             The Editor
  1077.  
  1078.  
  1079.        3.6.6  _T_a_b_s
  1080.  
  1081.        Tabs are    set at every 3 columns.    A ^I (or the <TAB>  key     on
  1082.        your  keyboard if you have one) will either insert spaces or
  1083.        replace with spaces, depending on the current Insert/Replace
  1084.        mode parameter, up to the next tab stop.
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.        Language    Summary                             19
  1140.  
  1141.  
  1142.        4.  LLLLaaaannnngggguuuuaaaaggggeeee SSSSuuuummmmmmmmaaaarrrryyyy
  1143.  
  1144.        Although    SCI implements only a subset of    the C language,     it
  1145.        is  powerful  enough to teach you the major principles of C.
  1146.        This section is meant to    be used    in conjunction with a  good
  1147.        C tutorial textbook to highlight    the differences    between    the
  1148.        SCI C subset and    standard C.  It    also serves as a  reference
  1149.        for  the     experienced C programmer that wants to    get started
  1150.        with SCI    quickly.
  1151.  
  1152.        4.1  LLLLiiiinnnneeee TTTTeeeerrrrmmmmiiiinnnnaaaattttoooorrrrssss
  1153.  
  1154.        In standard C, a    statement is terminated     with  a  semicolon
  1155.        (;).   In  SCI,    all statements are terminated by either    the
  1156.        end of the line or by a semicolon, although the semicolon is
  1157.        optional.   This    means that an expression MUST be completely
  1158.        contained on one    line.
  1159.  
  1160.        An SCI program line may be a maximum of 79 characters  long.
  1161.        The  built-in  editor  will  not     allow    you to create lines
  1162.        longer than 79 columns.
  1163.  
  1164.        4.2  CCCCoooommmmmmmmeeeennnnttttssss
  1165.  
  1166.        Comments    start with a number symbol (#) and end at  the    end
  1167.        of  the    current     program  line.      The  standard     C  comment
  1168.        delimiters, /* and */ are not recognized    and  will  cause  a
  1169.        "syntax error" message.
  1170.  
  1171.        4.3  IIIIddddeeeennnnttttiiiiffffiiiieeeerrrrssss
  1172.  
  1173.        Identifiers are any sequence of    characters,  the  first     of
  1174.        which  must  be an uppercase or lowercase letter    ("a-z",    "A-
  1175.        Z") or an underscore ("_").  The     remaining  characters    may
  1176.        include digits ("0-9").
  1177.  
  1178.        The following are all examples of valid identifiers:
  1179.  
  1180.            this_is_an_identifier
  1181.            _0123
  1182.            XYZ
  1183.  
  1184.        Note that there is no limit to  the  number  of    significant
  1185.        characters  in an identifier, except the    maximum    line length
  1186.        limit of    79 characters.
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.        20                           Language    Summary
  1203.  
  1204.  
  1205.        4.4  KKKKeeeeyyyywwwwoooorrrrddddssss
  1206.  
  1207.        The following words are reserved    by SCI and may not be  used
  1208.        as variable names:
  1209.  
  1210.            break           entry           return
  1211.            char           for           switch
  1212.            case           if           sys
  1213.            else           int           while
  1214.  
  1215.        Most of these keywords are the  standard     language  elements
  1216.        and are described in any    C text book.
  1217.  
  1218.        The "entry" keyword is used to tell  the     interpreter  which
  1219.        function     in  the  startup  program  (normally  in  the file
  1220.        SHELL.SCI) is to    be executed first  after  the  program    has
  1221.        been  loaded.   There  may  be  only  one  "entry"  within a
  1222.        program.     Any functions    or  variables  that  were  declared
  1223.        before  the  "entry" keyword are    considered "system globals"
  1224.        and are globally    known to all functions.     Among    the  system
  1225.        globals in the standard shell file are the Library Functions
  1226.        and the editor's    control    variables.
  1227.  
  1228.        Functions and variables declared    after the  "entry"  keyword
  1229.        are  hidden  from user-written functions.  These    include    the
  1230.        standard    shell's    control    program    (main) and  its     associated
  1231.        variables (the program and input    line buffer).
  1232.  
  1233.        The keyword "sys" is an interface function  to  some  useful
  1234.        interpreter  functions,    such  as the program editor.  These
  1235.        are described in    the Library Functions section.
  1236.  
  1237.        4.5  NNNNuuuummmmeeeerrrriiiicccc CCCCoooonnnnssssttttaaaannnnttttssss
  1238.  
  1239.        SCI supports decimal integer constants in the  range  -32768
  1240.        to  32767.   SCI     also  supports    the standard C notation    for
  1241.        integer hexadecimal and octal notation.
  1242.  
  1243.        4.6  CCCChhhhaaaarrrraaaacccctttteeeerrrr CCCCoooonnnnssssttttaaaannnnttttssss
  1244.  
  1245.        A character constant must be surrounded by  apostrophes    (')
  1246.        and may be one of the following:
  1247.  
  1248.        1. a  single  ASCII  alphanumeric   or    punctuation   (i.e.
  1249.       printable) character
  1250.  
  1251.        2. a backslash (\) character  followed  by  3  octal  digits
  1252.       which    may be used to represent any one byte value
  1253.  
  1254.  
  1255.  
  1256.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.        Language    Summary                             21
  1266.  
  1267.  
  1268.        3. a backslash followed by one of the characters    n, r, b     or
  1269.       t  which  represent  the  <LINEFEED>    (a.k.a.    "newline"),
  1270.       <RETURN>  (carriage  return),      <BACKSPACE>    and   <TAB>
  1271.       characters respectively
  1272.  
  1273.        The following are examples of valid character constants:
  1274.  
  1275.            'A'     the ASCII character "A"
  1276.            '\177'  octal character
  1277.            '\n'    newline
  1278.            '\r'    carriage    return
  1279.            '\b'    backspace
  1280.            '\t'    horizontal tab
  1281.            '\\'    the backslash character
  1282.            '\''    the apostrophe character
  1283.  
  1284.        4.7  SSSSttttrrrriiiinnnngggg CCCCoooonnnnssssttttaaaannnnttttssss
  1285.  
  1286.        Strings may include any of the character    constants mentioned
  1287.        above, as for example:
  1288.  
  1289.            "this is    a string\007\n"
  1290.  
  1291.        Strings always include a    null (zero) byte, marking  the    end
  1292.        of  the    string.     A zero-length string may be written as    two
  1293.        consecutive quotes, thus: "".  A    string is always terminated
  1294.        by  either  the matching    right quote or end of line; strings
  1295.        may not be continued on the next    line as    in standard C.
  1296.  
  1297.        4.8  DDDDaaaattttaaaa TTTTyyyyppppeeeessss
  1298.  
  1299.        Only  the  "char"  and  "int"  data  types  are     supported.
  1300.        Characters  (char's) are    1 byte and integers (int's) 2 bytes
  1301.        in length.  Both    are treated as signed quantities. Chars    may
  1302.        range  in value from -128 to +127, ints range from -32768 to
  1303.        32767.
  1304.  
  1305.        SCI also    supports pointers and single dimensioned arrays     of
  1306.        both char and int.  Pointers require 2 bytes of storage.
  1307.  
  1308.            char *cp;
  1309.            int ip[];
  1310.            int array[10];
  1311.  
  1312.        Pointers    to pointers (to    pointers, to  pointers,     etc.)    and
  1313.        single  dimension arrays    of pointers (to    pointers, etc.)    are
  1314.        also supported:
  1315.  
  1316.  
  1317.  
  1318.  
  1319.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.        22                           Language    Summary
  1329.  
  1330.  
  1331.            char **argv;
  1332.            char ***etc;
  1333.            int *array_of_ptr_to_ints[20];
  1334.            char **vec[20];
  1335.  
  1336.        4.9  OOOOppppeeeerrrraaaattttoooorrrrssss
  1337.  
  1338.        The following operators are supported.    The  operators    are
  1339.        listed from highest to lowest precedence.
  1340.  
  1341.                    Operator    Summary    (Part 1)
  1342.            _______________________________________________________
  1343.            operator           meaning           examples
  1344.            _______________________________________________________
  1345.            []      subscripting           pointer[expr]
  1346.            ()      function    call           expr(expr_list)
  1347.            ()      resolve precedence      ( expr )
  1348.            associativity:  left to right
  1349.            ________________________________________________________
  1350.            !       not               !expr
  1351.            ~       complement           ~expr
  1352.            ++      pre/post    increment      ++lvalue        lvalue++
  1353.            --      pre/post    decrement      --lvalue        lvalue--
  1354.            *       pointer dereference     *expr
  1355.            &       address of           &lvalue
  1356.            associativity:  right to    left
  1357.            _________________________________________________________
  1358.            *       multiplication           expr * expr
  1359.            /       division               expr / expr
  1360.            %       modulo (remainder)      expr % expr
  1361.  
  1362.            associativity:  left to right
  1363.            _________________________________________________________
  1364.            +       addition               expr + expr
  1365.            -       subtraction           expr - expr
  1366.            associativity:  left to right
  1367.            _______________________________________________________
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.        Language    Summary                             23
  1392.  
  1393.  
  1394.                    Operator    Summary    (Part 2)
  1395.            _______________________________________________________
  1396.            operator           meaning           examples
  1397.            _________________________________________________________
  1398.            <<      shift left           expr << expr
  1399.            >>      shift right           expr >> expr
  1400.            associativity:  left to right
  1401.            _________________________________________________________
  1402.            <       less than           expr < expr
  1403.            <=      less than or equal      expr <= expr
  1404.            >       greater than           expr > expr
  1405.            >=      greater than or equal   expr >= expr
  1406.            associativity:  left to right
  1407.            _________________________________________________________
  1408.            ==      equal               expr == expr
  1409.            !=      not equal           expr != expr
  1410.            associativity:  left to right
  1411.            _________________________________________________________
  1412.            &       bitwise AND           expr & expr
  1413.            associativity:  left to right
  1414.            _________________________________________________________
  1415.            ^       bitwise exclusive OR    expr ^ expr
  1416.            associativity:  left to right
  1417.            _________________________________________________________
  1418.            |       bitwise inclusive OR    expr | expr
  1419.            associativity:  left to right
  1420.            _________________________________________________________
  1421.            &&      logical AND           expr && expr
  1422.            associativity:  left to right
  1423.            _________________________________________________________
  1424.            ||      logical OR           expr || expr
  1425.            associativity:  left to right
  1426.            _________________________________________________________
  1427.            =       assignment           lvalue =    expr
  1428.            associativity:  right to    left
  1429.            _________________________________________________________
  1430.  
  1431.        4.10  CCCCoooommmmmmmmaaaa OOOOppppeeeerrrraaaattttoooorrrr
  1432.  
  1433.        The Comma Operator (,) as used by SCI is    not an operator    per
  1434.        se,  but     rather    a function argument and    variable seperator.
  1435.        Trying to use a comma anywhere other than in function calls,
  1436.        or data declarations will cause a "syntax error".
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.        24                           Language    Summary
  1455.  
  1456.  
  1457.        4.11  PPPPrrrrooooggggrrrraaaammmm CCCCoooonnnnttttrrrroooollll FFFFlllloooowwww CCCCoooonnnnssssttttrrrruuuuccccttttssss
  1458.  
  1459.        SCI supports the    following programming constructs:
  1460.  
  1461.            if ( <expression> ) <statement>
  1462.  
  1463.            if ( <expression> ) <statement> else <statement>
  1464.  
  1465.            while ( <expression> ) <statement>
  1466.  
  1467.            for ( <expression> ; <expression> ; <expression>    ) <statement>
  1468.  
  1469.            switch (    <expression> )
  1470.            {
  1471.            case <constant expression> : <statement>
  1472.            case <constant expression> : <statement>
  1473.            case <constant expression> : <statement>
  1474.                .
  1475.                .
  1476.                .
  1477.            default : <statement>
  1478.            }
  1479.  
  1480.        All of these constructs    require     that  the  keyword  ("if",
  1481.        "while",     etc.)    and  its  associated "(    <expression> )"    all
  1482.        appear on the same line of text.      The  <statement>  portion
  1483.        may appear on the same or on a separate line of text.
  1484.  
  1485.        SCI's "switch" statement     works    slightly  differently  than
  1486.        usual:  The <expression>    part following the "switch" keyword
  1487.        is first    evaluated.  Then, reading from top to bottom,  each
  1488.        of the <constant    expressions> are evaluated.  If    a "default"
  1489.        is encountered before any <constant expressions>     are  found
  1490.        that  match  <expression>, then execution continues with    the
  1491.        <statement> following the  "default"  keyword  and  all    the
  1492.        other  "cases" are ignored.  This is in contrast    to standard
  1493.        C that only  executes  the  "default"  statement     after    all
  1494.        <constant expressions> have been    tested.
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.        Library Functions                         25
  1518.  
  1519.  
  1520.        5.  LLLLiiiibbbbrrrraaaarrrryyyy FFFFuuuunnnnccccttttiiiioooonnnnssss
  1521.  
  1522.        The "sys" keyword has been reserved by SCI  as  a  means     of
  1523.        communicating  between a    user's program and the interpreter.
  1524.        It is treated exactly as    a (pre-defined)    function  that    may
  1525.        be referenced by    a user program.
  1526.  
  1527.        A "sys" call may    have several arguments,    the number and type
  1528.        of  which depends upon the integer value    of the last (right-
  1529.        most) argument. This right-most argument    is called the  "sys
  1530.        number" and defines the actual function performed by a "sys"
  1531.        call.  To make life easier and to provide  a  more  or  less
  1532.        "standard"  programming environment, higher- level functions
  1533.        have been wrapped around    these "sys" calls - these are known
  1534.        as  the "Library    Functions" and may be found in the standard
  1535.        command shell included in the distribution disk.      The  "sys
  1536.        numbers"     and  their  corresponding mnemonic name are listed
  1537.        below.
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.        26                          Library Functions
  1581.  
  1582.  
  1583.            0       version
  1584.            1       fputc
  1585.            2       fgetc
  1586.            3       fputs
  1587.            4       fgets
  1588.            5       sprintf
  1589.            6       sscanf
  1590.            7       fopen
  1591.            8       fread
  1592.            9       fwrite
  1593.            10      fclose
  1594.            11      fseek
  1595.            12      ftell
  1596.            13      bdos
  1597.            14      system
  1598.            15      exit
  1599.            16      stmt
  1600.            17      totok
  1601.            18      untok
  1602.            19      edit
  1603.            20      strcmp and strncmp
  1604.            21      strcpy and strncpy
  1605.            22      strlen
  1606.            23      malloc
  1607.            24      free
  1608.            25      load
  1609.            26      save
  1610.            27      list
  1611.            28      debug
  1612.            29      dirscan
  1613.            30      int86
  1614.            31      memleft
  1615.  
  1616.        The Library Functions are described below  in  more  detail.
  1617.        Some  of     the  "sys"  functions    do not have a corresponding
  1618.        Library Function    interface in SHELL.SCI,    but  are  described
  1619.        here anyway for completeness.
  1620.  
  1621.        5.1  aaaattttooooiiii
  1622.  
  1623.        atoi( str )
  1624.        char *str;
  1625.  
  1626.        Converts      the    string     "str"     containing    the    ASCII
  1627.        representation of a decimal number to an    integer. The string
  1628.        consists    of optional leading spaces  or    tabs,  an  optional
  1629.        plus  or    minus sign (+ or -) followed by    one or more decimal
  1630.        digits.    Returns    the  integer  value  of     the  ASCII  number
  1631.  
  1632.  
  1633.  
  1634.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.        Library Functions                         27
  1644.  
  1645.  
  1646.        string.
  1647.  
  1648.        This function does not have a "sys" call     number     equivalent
  1649.        but rather it uses the "sscanf" Library Function.
  1650.  
  1651.        5.2  bbbbddddoooossss
  1652.  
  1653.        bdos( cx, dx )
  1654.        int cx, dx;
  1655.  
  1656.        Performs     a  call  on  the  operating  system's    BDOS.    The
  1657.        arguments  "cx"    and "dx" will be copied    to the machine's CX
  1658.        and DX registers    respectively before  the  BDOS    call.    The
  1659.        function     returns  the  value of    the CPU's AX register after
  1660.        the call.  See your  MS-DOS  programmer's  manual  for  more
  1661.        details on BDOS calls.
  1662.  
  1663.        5.3  ddddeeeebbbbuuuugggg
  1664.  
  1665.        debug( level, check )
  1666.        int level, check;
  1667.  
  1668.        Allows a    program    to enable  or  disable    the  SCI  debugger.
  1669.        There are three levels of debug mode:
  1670.  
  1671.        0.  If "level" is zero the  debugger  is     disabled  and    the
  1672.        program runs    normally.
  1673.  
  1674.        1.  At level 1 a    running    program    may be halted at  any  time
  1675.        by  pressing     the  <ESCAPE>    key.   At  this     point    the
  1676.        debugger enters level 2 debug mode.
  1677.  
  1678.        2.  In level 2  mode  every  statement  is  first  displayed
  1679.        before it is    executed, and the debugger is invoked.    See
  1680.        the "Debugger" section for more details.
  1681.  
  1682.        The argument "check" is _o_p_t_i_o_n_a_l    and allows you to enable or
  1683.        disable    memory    access    range  checks  and  language syntax
  1684.        compatability checks:
  1685.  
  1686.        1.  If "check" is one, SCI performs range checks    on all data
  1687.        fetch  and  store  operations to ensure that    the program
  1688.        boundaries are not being exceeded.  This is    useful    for
  1689.        finding  "bent  pointers".  However,    if you are going to
  1690.        intentionally peek and  poke     around     in  the  operating
  1691.        system,  you     will  want  to     disable this feature.    The
  1692.        default setting at program startup is "enabled".
  1693.  
  1694.  
  1695.  
  1696.  
  1697.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.        28                          Library Functions
  1707.  
  1708.  
  1709.        2.  If "check" is two, SCI  points  out    missing     semicolons
  1710.        which,  if  you recall, are optional    in SCI's dialect of
  1711.        C.  Also, attempts to multiply or divide a pointer by  a
  1712.        constant  or     another pointer, or to    add two    pointers is
  1713.        not allowed.
  1714.  
  1715.        3.  If "check" is  three,  both    of  the     above    checks    are
  1716.        enabled.
  1717.  
  1718.        5.4  ddddiiiirrrrssssccccaaaannnn
  1719.  
  1720.        dirscan(    afn, file )
  1721.        char *afn, file[20];
  1722.  
  1723.        This function will scan the disk    directory  for    file  names
  1724.        that  match  the     "ambiguous  file name"    given by the string
  1725.        "afn".    Ambiguous  file     names    may  contain  "*"  and    "?"
  1726.        wildcard    characters as explained    in your    MS-DOS manual.    The
  1727.        first file name found in    the directory that matches will     be
  1728.        copied into the buffer at "file".  To continue the directory
  1729.        scan and    search for the next matching file name,     set  "afn"
  1730.        equal  to  zero.     Dirscan will return a 1 if a matching file
  1731.        name was    found, zero if not.
  1732.  
  1733.        5.5  eeeeddddiiiitttt
  1734.  
  1735.        edit( line_num, program )
  1736.        int line_num
  1737.        char *program
  1738.  
  1739.        Invokes the built-in program editor, starting  at  the  line
  1740.        given   by   "line_num"    on  the     tokenized  program  buffer
  1741.        "program".  Returns the new size    of the program buffer after
  1742.        the  editing  session.    This  function    is  not    included in
  1743.        SHELL.SCI
  1744.  
  1745.        5.6  eeeexxxxiiiitttt
  1746.  
  1747.        exit( value )
  1748.        int value
  1749.  
  1750.        Causes the currently executing program to return    control     to
  1751.        the operating system.  The number "value" is returned to    the
  1752.        operating system    shell (usually COMMAND.COM in MS-DOS).
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.        Library Functions                         29
  1770.  
  1771.  
  1772.        5.7  ffffcccclllloooosssseeee
  1773.  
  1774.        fclose( channel )
  1775.        int channel;
  1776.  
  1777.        Closes a    disk file previously opened by the Library Function
  1778.        "fopen".     Returns zero if successful, -1    on error.
  1779.  
  1780.        5.8  ffffggggeeeettttcccc
  1781.  
  1782.        fgetc( channel )
  1783.  
  1784.        Reads a single character    from the  given     channel.   Returns
  1785.        the character read, or a    -1 on error or end of file.
  1786.  
  1787.        5.9  ffffggggeeeettttssss
  1788.  
  1789.        fgets( buffer, length, channel )
  1790.        char *buffer;
  1791.        int length;
  1792.        int channel;
  1793.  
  1794.        Reads characters    from the file  associated  with     "channel".
  1795.        Characters  are read from the file until    either a newline is
  1796.        encountered, length minus 1 characters have been    read, or an
  1797.        end of file is found.  Returns the address of "buffer", or a
  1798.        zero on end of file.
  1799.  
  1800.        5.10  ffffooooppppeeeennnn
  1801.  
  1802.        fopen( file_name, mode )
  1803.        char *file_name,    *mode;
  1804.  
  1805.        Opens a    disk  file  whose  name     is  given  by    the  string
  1806.        "file_name".  The string    "mode" determines how the file will
  1807.        be opened:
  1808.  
  1809.        r   open    for ASCII read.      The  file  MUST  exist  or  fopen
  1810.        returns an error code.
  1811.  
  1812.        rw  open    for ASCII read/write.  The file    MUST exist.
  1813.  
  1814.        w   open    for ASCII write.  If the file exists, it  is  first
  1815.        deleted.
  1816.  
  1817.        wr  open    for ASCII read/write. If the file  already  exists,
  1818.        it is first deleted.
  1819.  
  1820.  
  1821.  
  1822.  
  1823.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.        30                          Library Functions
  1833.  
  1834.  
  1835.        a   open    for ASCII write     append.   If  the  file  does    not
  1836.        exist,  it  is  created.  If     it  does  exist,  the file
  1837.        position pointer is positioned to the end of    the file.
  1838.  
  1839.        ar  open    for ASCII read/write append.  If the file does    not
  1840.        exist  it is    created. If it DOES exist, it is opened    and
  1841.        the file pointer positioned to the end of the file.    The
  1842.        file    may then be read or written.
  1843.  
  1844.        By appending a "b" to any of the    modes above,  the  file     is
  1845.        opened in BINARY    mode instead of    ASCII.
  1846.  
  1847.        When a file is opened in    ASCII mode, all    <LINEFEED>s  ("\n")
  1848.        are  converted  to  <RETURN> <LINEFEED> character pairs when
  1849.        writing to the file.  Similarly,    <RETURN>  <LINEFEED>  pairs
  1850.        are converted to    a single <LINEFEED> character on input from
  1851.        the file.
  1852.  
  1853.        In  BINARY  read/write  mode,  no   such      conversions    are
  1854.        performed.
  1855.  
  1856.        Returns an integer value    known as a "channel".  The  special
  1857.        channels     1,  2    and 3 refer to the standard input, standard
  1858.        output and standard error files,    and are    initially  set    for
  1859.        I/O  on the console.  The channel number    must be    used in    all
  1860.        Library calls that perform file I/O functions.  A  value     of
  1861.        zero is returned    if the file could not be opened.
  1862.  
  1863.        5.11  ffffppppuuuuttttcccc
  1864.  
  1865.        fputc( c, channel )
  1866.        char c;
  1867.        int channel;
  1868.  
  1869.        Writes the character "c"     to  the  specified  file  channel.
  1870.        Returns the character written, or a -1 on error.
  1871.  
  1872.        5.12  ffffppppuuuuttttssss
  1873.  
  1874.        fputs( string, channel )
  1875.        char *string;
  1876.        int channel;
  1877.  
  1878.        Writes the string to the    specified  file     channel.   Returns
  1879.        zero, or    a -1 on    error.
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.        Library Functions                         31
  1896.  
  1897.  
  1898.        5.13  ffffrrrreeeeaaaadddd
  1899.  
  1900.        fread( buffer, length, channel )
  1901.        char *buffer;
  1902.        int length;
  1903.        int channel;
  1904.  
  1905.        Reads a maximum of "length" bytes into memory at    the address
  1906.        pointed    to  by    "buffer" from the open file, "channel".     If
  1907.        the file    was  opened  in     ASCII    read  or  read/write  mode,
  1908.        "fread"    only reads up to and including a newline character.
  1909.        If the file was opened in binary    read mode, "length"  number
  1910.        of  characters  are  read  if they are available.  Note that
  1911.        "channel" must be the value returned from a previous "fopen"
  1912.        Library    Function  call,     and  the  file    must still be open.
  1913.        Returns the number of characters    that were actually read, or
  1914.        0 on EOF.
  1915.  
  1916.        5.14  ffffrrrreeeeeeee
  1917.  
  1918.        free( memory )
  1919.        char *memory
  1920.  
  1921.        Returns to the memory pool the block of memory pointed to by
  1922.        "memory"     that was previously gotten from a "malloc" Library
  1923.        Function    call.
  1924.  
  1925.        5.15  ffffsssseeeeeeeekkkk aaaannnndddd fffftttteeeellllllll
  1926.  
  1927.        fseek( channel, offset, whence )
  1928.        int channel, offset, whence;
  1929.  
  1930.        ftell( channel )
  1931.  
  1932.        These functions manipulate a file's position  pointer.    The
  1933.        file  position pointer determines where in the file the next
  1934.        byte of data will be read from or written to.  The  argument
  1935.        "channel"  is  the  file     channel number; "offset" is a byte
  1936.        position    offset;    "whence" determines how    the  "offset"  will
  1937.        be  applied  to    the  current  file  position  pointer.     If
  1938.        "whence"    is  zero,  "fseek"  will  move    the  file  position
  1939.        pointer    to  "offset"  bytes from the _b_e_g_i_n_n_i_n_g of the file.
  1940.        If "whence" is one, "fseek"  will  move    the  file  position
  1941.        pointer    to "offset" bytes from its _c_u_r_r_e_n_t _l_o_c_a_t_i_o_n, either
  1942.        forward ("offset" is  positive)    or  backward  ("offset"     is
  1943.        negative)  in the file If "whence" is two, "fseek" will move
  1944.        the file    position pointer to "offset" bytes from    the _e_n_d     of
  1945.        the  file.   In this case, "offset" must    be negative to move
  1946.  
  1947.  
  1948.  
  1949.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.        32                          Library Functions
  1959.  
  1960.  
  1961.        the file    position pointer towards the beginning of the file.
  1962.  
  1963.        Ftell simply returns the    current    file position.
  1964.  
  1965.  
  1966.  
  1967.                    NOTE
  1968.  
  1969.        Because SCI supports only integer variables, these functions
  1970.        may  only  be  used  on    files  that  are smaller than 32767
  1971.        characters.  Standard C allows you to manipulate    much larger
  1972.        files.
  1973.  
  1974.        5.16  ffffwwwwrrrriiiitttteeee
  1975.  
  1976.        fwrite( buffer, length, channel )
  1977.        char *buffer;
  1978.        int length;
  1979.        int channel;
  1980.  
  1981.        Writes "length" number of  characters  from  memory  at    the
  1982.        address    pointed     to by "buffer"    to the file associated with
  1983.        "channel".  Note    that "channel" must be the  value  returned
  1984.        from  a previous    "fopen"    Library    Function call, and the file
  1985.        must still  be  open.   Returns    the  number  of     characters
  1986.        actually    written    if successful, or a -1 on error.
  1987.  
  1988.        5.17  iiiinnnntttt88886666
  1989.  
  1990.        int86( interrupt_num, in_regs, out_regs ) int interrupt_num,
  1991.        in_regs[8], out_regs[8]
  1992.  
  1993.        Performs    an 8086    interrupt.  The    argument "interrupt_num" is
  1994.        the  interrupt  number.    Before the interrupt is    issued,    the
  1995.        machine registers AX, BX, CX, DX, SI,  DI,  DS  and  ES    are
  1996.        loaded  with  the  8 integers pointed to    by "in_regs".  When
  1997.        the interrupt routine returns to    the program, the values     of
  1998.        the  registers  will  be     found at the address pointed to by
  1999.        "out_regs" in the same order as "in_regs".
  2000.  
  2001.        5.18  llllooooaaaadddd
  2002.  
  2003.        load( file, program )
  2004.        char *file, *program
  2005.  
  2006.        Loads a program from the    file whose name    is  pointed  at     by
  2007.        "file",    tokenizes  the    statements  therein  and places    the
  2008.        tokenized program at "program".    Returns     the  size  of    the
  2009.  
  2010.  
  2011.  
  2012.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.        Library Functions                         33
  2022.  
  2023.  
  2024.        resulting  tokenized  program.    If  the     file  could not be
  2025.        found, an error message is printed  on  the  console.   This
  2026.        function    is not included    in SHELL.SCI
  2027.  
  2028.        5.19  mmmmaaaalllllllloooocccc
  2029.  
  2030.        malloc( size )
  2031.        int size
  2032.  
  2033.        Main memory allocator.  This  function  is  responsible    for
  2034.        handing    out  (to programs) chunks of free memory to be used
  2035.        by the program as it sees fit.
  2036.  
  2037.  
  2038.                  WARNING
  2039.  
  2040.        wreckless programs that write data beyond the  size  of    the
  2041.        allocated  chunk    of memory will cause the allocator to loose
  2042.        its mind    and dole out "rotten" chunks of    memory.     This  will
  2043.        almost  surely  cause  SCI  to  crash  and  burn.  Returns a
  2044.        pointer to a block of memory "size" bytes long.    Be sure     to
  2045.        de-allocate the block using the Library Function    "free" when
  2046.        you're done with    it, or it will be lost forever...  Also, do
  2047.        not  use     malloc    to allocate memory for SCI program buffers,
  2048.        or you will surely crash    the system.
  2049.  
  2050.        5.20  mmmmeeeemmmmlllleeeefffftttt
  2051.  
  2052.        memleft()
  2053.  
  2054.        Returns the  amount  of    memory    remaining  in  the  program
  2055.        buffer.     Note  that  the program buffer    is unrelated to    the
  2056.        memory pool accessed by malloc()    and free().
  2057.  
  2058.        5.21  pppprrrriiiinnnnttttffff
  2059.  
  2060.        printf( format, arg1, arg2, ... arg8 )
  2061.        char *format;
  2062.        int arg1, arg2, ... arg8;
  2063.  
  2064.        Prints a    formatted string to the    standard output    file.    The
  2065.        characters in the string    "format" are copied to the standard
  2066.        output file.  If    a percent character ("%") is encountered in
  2067.        the  format  string,  it     is  assumed  to  be  a     conversion
  2068.        specification.    Each  conversion   specification   converts
  2069.        exactly one argument in the list    "arg1",    "arg2",    ... "arg8".
  2070.        Once an argument     has  been  converted  and  output,  it     is
  2071.        skipped    over  the  next     time a    conversion specification is
  2072.  
  2073.  
  2074.  
  2075.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.        34                          Library Functions
  2085.  
  2086.  
  2087.        encountered. Therefore, you need    just as    many  arguments     as
  2088.        you have    conversion specifications (%-somethings).
  2089.  
  2090.        The character(s)    that follow a conversion specification    may
  2091.        be one or more of the following:
  2092.  
  2093.        minus  sign  (-)    Indicates  that     output     should      be   left
  2094.            justified instead of right justified.
  2095.  
  2096.        zero fill character (0) The field will be padded    on the left
  2097.            with zeros.
  2098.  
  2099.        field width (number other than 0) This is the minimum  #     of
  2100.            characters  output.  The     field    will be    padded with
  2101.            zeros or    blanks    depending  on  the  fill  character
  2102.            (above).
  2103.  
  2104.        precision (. followed by    a number) For numeric fields,  this
  2105.            is  the    #  of  decimal    places    to the right of    the
  2106.            decimal point. For string fields, at most that  many
  2107.            characters of the string    will be    output.
  2108.  
  2109.        conversion code (the letter  d,    u,  x,    o,  b,    s  or  c) A
  2110.            conversion  code     indicates  the     type of conversion
  2111.            that is to be done on the argument as follows:
  2112.  
  2113.                d - convert to a    decimal    (base 10) number
  2114.                u - unsigned decimal number
  2115.                x - hexadecimal (base 16) number
  2116.                o - octal (base 8) number
  2117.                b - binary (base    2) number
  2118.                s - string constant
  2119.                c - single ASCII    character
  2120.  
  2121.        5.22  ssssaaaavvvveeee
  2122.  
  2123.        save( file, program )
  2124.        char *file, *program
  2125.  
  2126.        Saves a program in its tokenized    form at     "program"  to    the
  2127.        file whose name is in the string    "file".     Returns the number
  2128.        of bytes    written    to the file.  If  the  file  could  not     be
  2129.        created,     an  error message is printed on the console.  This
  2130.        function    is not included    in SHELL.SCI
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.        Library Functions                         35
  2148.  
  2149.  
  2150.        5.23  ssssccccaaaannnnffff
  2151.  
  2152.        scanf( format, arg1, arg2, ... arg8 )
  2153.        char *format
  2154.        int arg1, arg2, ... arg8
  2155.  
  2156.        Reads characters    from the standard input    file  and  converts
  2157.        them  using  the     conversion  string  "format"  (same as    for
  2158.        Library Function    "printf").  The    arguments  "arg1",  "arg2",
  2159.        ... "arg8" must be pointers to the appropriate data types.
  2160.  
  2161.        5.24  sssspppprrrriiiinnnnttttffff
  2162.  
  2163.        sprintf(    buffer,    format,    arg1, arg2, ...    arg8 )
  2164.        char *buffer, *format
  2165.        int arg1, arg2, ... arg8
  2166.  
  2167.        Performs    formated conversion of the arguments, exactly  like
  2168.        the  Library  Function  "printf()", but writes its output to
  2169.        the "buffer" instead of the standard output file.
  2170.  
  2171.        5.25  ssssssssccccaaaannnnffff
  2172.  
  2173.        sscanf( buffer, format, arg1, arg2, ... arg8 )
  2174.        char *buffer, *format
  2175.        int arg1, arg2, ... arg8
  2176.  
  2177.        Performs    formated input conversion of the arguments, exactly
  2178.        like the    Library    Function "scanf()" but reads its input from
  2179.        the "buffer" instead of the standard input file.
  2180.  
  2181.        5.26  ssssttttmmmmtttt
  2182.  
  2183.        stmt( line, program )
  2184.        char *line, *program
  2185.  
  2186.        Hands a C statement off to the  interpreter  for     execution.
  2187.        The  statement  is  in  its untokenized form at "line".    The
  2188.        program,    also in    tokenized form,    at "program" is    used by    the
  2189.        interpreter  to    satisfy     any  global  variable    or function
  2190.        references made by the  statement.   This  function  is    not
  2191.        included    in SHELL.SCI
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.        36                          Library Functions
  2211.  
  2212.  
  2213.        5.27  ssssttttrrrrccccmmmmpppp,,,, ssssttttrrrrnnnnccccmmmmpppp
  2214.  
  2215.        strcmp( string_1, string_2 )
  2216.        char *string_1, *string_2
  2217.  
  2218.            or
  2219.  
  2220.        strncmp(    string_1, string_2, limit )
  2221.        char *string_1, *string_2
  2222.        int limit
  2223.  
  2224.        Compares     (character-by-character)  the    two  strings.    The
  2225.        comparison stops    when a zero is encountered in either of    the
  2226.        two strings.  "strncmp" does the    same  thing,  but  at  most
  2227.        "limit"    number    of  bytes are compared.     Returns a 0 if    the
  2228.        two strings are identical, non- zero if they differ.
  2229.  
  2230.        5.28  ssssttttrrrrccccppppyyyy,,,, ssssttttrrrrnnnnccccppppyyyy
  2231.  
  2232.        strcpy( string_1, string_2 )
  2233.        char *string_1, *string_2
  2234.  
  2235.            or
  2236.  
  2237.        strncpy(    string_1, string_2, limit )
  2238.        char *string_1, *string_2
  2239.        int limit
  2240.  
  2241.        Copies (character-by-character) "string_2" into    "string_1".
  2242.        The  functions  stops  after  the  first     null  character is
  2243.        encountered in "string_2".  "strncpy" does the  same  thing,
  2244.        but  at    most  "limit"  number of bytes are copied.  Returns
  2245.        nothing interesting.
  2246.  
  2247.        5.29  ssssttttrrrrlllleeeennnn
  2248.  
  2249.        strlen( string )
  2250.        char *string;
  2251.  
  2252.        Returns the  number  of    characters  in    the  given  string,
  2253.        excluding the string's trailing zero byte.
  2254.  
  2255.        5.30  ssssyyyysssstttteeeemmmm
  2256.  
  2257.        system( command_string )
  2258.        char *command_string;
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.        Library Functions                         37
  2274.  
  2275.  
  2276.        Executes    the MS-DOS command interpreter (usually    the program
  2277.        in  COMMAND.COM)     and  passes it    the MS-DOS command found in
  2278.        "command_string".  SCI remains suspended    in  memory  in    its
  2279.        current    state  and will    continue execution when    the command
  2280.        has completed.    The  return  value  from  "system"  is    the
  2281.        completion  status  of the MS-DOS program, which    may be used
  2282.        to test for success or failure.
  2283.  
  2284.        5.31  ttttoooottttooookkkk
  2285.  
  2286.        totok( sourcebuf, tokenbuf )
  2287.        char *sourcebuf,    *tokenbuf
  2288.  
  2289.        Converts    the C statement    at  "sourcebuf"     to  its  tokenized
  2290.        equivalent and places the result    at "tokenbuf".    Returns    the
  2291.        length of "tokenbuf".  This  function  is  not  included     in
  2292.        SHELL.SCI
  2293.  
  2294.        5.32  uuuunnnnttttooookkkk
  2295.  
  2296.        untok( tokenbuf,    sourcebuf )
  2297.        char *tokenbuf, *sourcebuf
  2298.  
  2299.        Converts     the  tokenized     statement  at    "tokenbuf"  to    its
  2300.        printable  form    at  "sourcebuf".   Returns  the     length     of
  2301.        "tokenbuf"  (not     "sourcebuf"!).      This    function   is    the
  2302.        opposite     of  the  "totok"  function.   This function is    not
  2303.        included    in SHELL.SCI
  2304.  
  2305.        5.33  vvvveeeerrrrssssiiiioooonnnn
  2306.  
  2307.        version()
  2308.  
  2309.        Returns a  character  string  that  contains  SCI's  program
  2310.        identification  and  copyright  notice,    and  the  program's
  2311.        current version number, namely the string:
  2312.        Small C Interpreter Vr.l    ddmmmyy    Copyright (C) 1986 Bob Brodt
  2313.  
  2314.        where  "r.l"  is     the  version  number  (release.level)    and
  2315.        ddmmmyy    is  the     date of the release.  This function is    not
  2316.        included    in SHELL.SCI
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.        38                            The    Debuger
  2337.  
  2338.  
  2339.        6.  TTTThhhheeee DDDDeeeebbbbuuuuggggeeeerrrr
  2340.  
  2341.        The Library Function  "debug()"    allows    you  to     enable     or
  2342.        disable    the  SCI  debuger.   When the debuger is enabled in
  2343.        mode 2, you can set  and     remove     breakpoints,  examine    and
  2344.        modify  program    variables and control the execution of your
  2345.        program.
  2346.  
  2347.        When the    debuger    is enabled, it first displays each line     of
  2348.        the  program  on    the console before it is executed, followed
  2349.        by its "debug>" prompt.    At this    point, you may either enter
  2350.        another    valid  C  statement  (to  display the contents of a
  2351.        variable     for  example),     or  enter  one     of  the  following
  2352.        commands     (NOTE:    all of these commands must start with a    dot
  2353.        (.) immediately following the "debug>" prompt to    distinguish
  2354.        them from a valid C statement):
  2355.  
  2356.        .b#     sets a breakpoint at a given line in  your  program.
  2357.            The  "#"     symbol    represents the line number at which
  2358.            the program will    be halted.
  2359.  
  2360.        .B      displays    all breakpoints    set in the program.
  2361.  
  2362.        .c      continues   program   execution     until     the   next
  2363.            breakpoint is encountered.
  2364.  
  2365.        .d#     deletes the breakpoint  at  line     number     "#".    The
  2366.            breakpoint must have been previously set    with a ".b"
  2367.            command.
  2368.  
  2369.        .D      deletes all breakpoints.
  2370.  
  2371.        .e#     lets  you  examine  the    program     with  the  program
  2372.            editor.     Editor    commands that would normally modify
  2373.            the program are disabled.  The editor's status  line
  2374.            indicates   "Readonly"    mode   where   "Insert"     or
  2375.            "Replace" would normally    be displayed.
  2376.  
  2377.        .g      displays    all of the program's global  variables    and
  2378.            their  values.    If  the     variable  is an array,    its
  2379.            address is printed followed by the first    10 elements
  2380.            of the array.
  2381.  
  2382.        .G      same as ".g" but    also displays  the  first  line     of
  2383.            every  function    in  the    program    along with its line
  2384.            number.    This is    useful for locating a function in a
  2385.            long program.
  2386.  
  2387.  
  2388.  
  2389.  
  2390.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.        The Debuger                             39
  2400.  
  2401.  
  2402.        .q      quits program execution and  returns  to     the  shell
  2403.            program.
  2404.  
  2405.        .s#     steps through the program  without  displaying  each
  2406.            line  as     it  is    executed.  The "#" is the number of
  2407.            lines to    be executed before control returns  to    the
  2408.            debuger.
  2409.  
  2410.        .t      displays    the  list  of  active  functions  with    the
  2411.            current    one  at    the top    of the list.  This is handy
  2412.            for finding out "how did    I get here?".
  2413.  
  2414.        .T      same as ".t" but    also displays each function's local
  2415.            variables and their values.
  2416.  
  2417.        <RETURN>    same as    a ".s1".
  2418.  
  2419.        <ESCAPE>    is used    to interrupt a program while it    is  running
  2420.            and  enable the debuger.     This key is active only in
  2421.            debug mode 1 or 2.
  2422.  
  2423.        If the SCI interpreter finds an error in     your  program,     it
  2424.        will  automatically  enable the debuger and halt    the program
  2425.        at the line where the error occurred.  This can be a  little
  2426.        confusing  if  you are already in the debuger and you happen
  2427.        to make a mistake while typing a    statement for  the  debuger
  2428.        to  execute,  because  the  resulting  error message and    the
  2429.        "debug>>" prompt     will  refer  to  the  statement  you  just
  2430.        entered.      If this happens, just    hit a <RETURN> and you will
  2431.        be returned to the program debug    session.
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.        40                               APPENDIX
  2463.  
  2464.  
  2465.        A.  SSSSCCCCIIII LLLLaaaannnngggguuuuaaaaggggeeee    SSSSyyyynnnnttttaaaaxxxx
  2466.  
  2467.        This appendix contains what is  known  as  the  "Backus-Naur
  2468.        Form",  or  "BNF"  of  the  SCI    language.  Named  after    its
  2469.        inventors, BNF is a very    precise    description of    a  language
  2470.        and  is useful as a reference for proper    syntax.     The BNF of
  2471.        a language may at first be  a  little  confusing,  but  with
  2472.        practice     it  can  be  a     very natural way of expressing    the
  2473.        syntax structure    of any language.
  2474.  
  2475.        The following rules  apply  to  the  BNF     notation  in  this
  2476.        appendix:
  2477.  
  2478.        1.  words that appear in    UPPER CASE represent  key  elements
  2479.        of  the  language like the "if" and "while" keywords, or
  2480.        like    the symbol for multiplication (*). These  types     of
  2481.        words  are known as "TERMINALS" and can be considered to
  2482.        be similar to atoms;    the  basic  building  blocks  of  a
  2483.        language.
  2484.  
  2485.        2.  Words in "lower case" represent what     are  called  "non-
  2486.        terminals".     Just  as  a molecule may consist of one or
  2487.        more    atoms, non-terminals may consist  of  one  or  more
  2488.        TERMINALS.
  2489.  
  2490.        3.  the word to be defined will appear on a line    by  itself,
  2491.        followed  by     a  colon  (:)    followed by its    definitions
  2492.        indented below it.
  2493.  
  2494.        4.  within a definition,    language elements are separated     by
  2495.        a space.
  2496.  
  2497.        5.  depending upon its context, a language element  may    not
  2498.        appear  at all and its definition is    the special "empty"
  2499.        definition.
  2500.  
  2501.        6.  the SCI-style comment mark (#) is used only to clarify a
  2502.        definition and is not part of the definition
  2503.  
  2504.        We have always been taught  never  to  use  a  word  we    are
  2505.        defining    in its definition, that    "recursive definitions"    are
  2506.        blasphemous!  However when defining language  syntax  it     is
  2507.        often   desirable,   indeed   necessary,     to  use  recursive
  2508.        definitions. Take for example the BNF description of a  word
  2509.        in  the    english    language: a word may be    one or more letters
  2510.        strung together.    More formally,
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.        APPENDIX                                 41
  2526.  
  2527.  
  2528.        a "word"    may be either:
  2529.            1. a "letter", or
  2530.            2. a "word" followed by a "letter"
  2531.  
  2532.        Here we can deduce definition number  2    because     the  first
  2533.        letter  of  a  word qualifies as    a word itself, according to
  2534.        our definition 1.  Even more formally,
  2535.  
  2536.        word:
  2537.            LETTER        # for example the word "a"
  2538.            word LETTER  # for example the word "as"
  2539.  
  2540.        We have written "LETTER"    in upper case to  indicate  that  a
  2541.        letter  can  not     be  broken down any further, i.e.  it is a
  2542.        "TERMINAL". Similarly, "word" appears in    lower case  because
  2543.        it  can    be  broken  down  into smaller parts; it is a "non-
  2544.        terminal".
  2545.  
  2546.        Here then, is the BNF of    the SCI    language. Assume  that    you
  2547.        already    know  what the terminals LETTER    (one of: a b c...z,
  2548.        or A B C...Z, or    _), NUMBER (one    of: 0 1     2...9),  HEXDIGITS
  2549.        (0 1 2...9 A B...F) and OCTALDIGITS (0 1    2...7) are.
  2550.  
  2551.        id-list:          # identifier (variable) list
  2552.            empty         # may be non-existent
  2553.            id         # or a single identifier
  2554.            id-list , id  # or two or more id's separated by    a comma
  2555.  
  2556.        id:          # an identifier (variable)
  2557.            LETTER
  2558.            id LETTER
  2559.            id NUMBER
  2560.  
  2561.        hex-constant:      # hexadecimal    constant
  2562.            0 X HEXDIGITS
  2563.  
  2564.        oct-constant:      # octal constant
  2565.            0 OCTALDIGITS
  2566.  
  2567.        dec-constant:      # decimal constant
  2568.            NUMBER
  2569.            dec-constant NUMBER
  2570.  
  2571.        chr-constant:      # character constant
  2572.            ' CHARACTER '
  2573.  
  2574.        str-constant:      # string constant
  2575.            " CHARACTER-LIST    "
  2576.  
  2577.  
  2578.  
  2579.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.        42                               APPENDIX
  2589.  
  2590.  
  2591.        constant:      # constants are all of the above
  2592.            dec-constant
  2593.            hex-constant
  2594.            oct-constant
  2595.            chr-constant
  2596.            str-constant
  2597.  
  2598.        expression-list:
  2599.            empty
  2600.            expression
  2601.            expression-list , expression
  2602.  
  2603.        expression:
  2604.            primary
  2605.            * expression
  2606.            & lvalue
  2607.            ++ lvalue
  2608.            -- lvalue
  2609.            lvalue ++
  2610.            lvalue --
  2611.            - primary
  2612.            + primary
  2613.            ! expression
  2614.            ~ expression
  2615.            expression binop    expression
  2616.            lvalue =    expression
  2617.  
  2618.        primary:
  2619.            id               # a variable
  2620.            constant               # a constant
  2621.            ( expression )           # a parenthesized expression
  2622.            id ( expression-list )  # a function call
  2623.            id [ expression ]       # an array element
  2624.  
  2625.        lvalue:
  2626.            id               # a simple variable
  2627.            id [ expression ]       # an array element
  2628.            * expression           # a pointer expression
  2629.  
  2630.        binop:          # the    binary operators:
  2631.            *      # multiplication
  2632.            /      # division
  2633.            %      # modulo
  2634.            +      # addition
  2635.            -      # subtraction
  2636.            <<      # aritmetic shift left
  2637.            >>      # aritmetic shift right
  2638.            <      # "is    less than"
  2639.  
  2640.  
  2641.  
  2642.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.        APPENDIX                                 43
  2652.  
  2653.  
  2654.            <=      # "is    less than or equal to"
  2655.            >      # "is    greater    than"
  2656.            >=      # "is    greater    than or    equal to"
  2657.            ==      # "is    equal to"
  2658.            !=      # "is    not equal to"
  2659.            &      # bit-wise AND
  2660.            ^      # bit-wise XOR
  2661.            |      # bit-wise OR
  2662.            &&      # logical AND
  2663.            ||      # logical OR
  2664.  
  2665.        declaration-list:
  2666.            empty
  2667.            declaration
  2668.            declaration-list    declaration
  2669.  
  2670.        declaration:
  2671.            type-spec declarator-list ;
  2672.  
  2673.        type-spec:
  2674.            CHAR
  2675.            INT
  2676.  
  2677.        declarator-list:
  2678.            declarator
  2679.            declarator-list , declarator
  2680.  
  2681.        declarator:
  2682.            ptr id
  2683.            ptr id [    constant ]
  2684.  
  2685.        ptr:          # pointer operators
  2686.            empty      # this just means that SCI supports
  2687.            *      # simple pointers, or
  2688.            ptr *      # pointers to    pointers (to pointers, etc.)
  2689.  
  2690.        statement-list:
  2691.            statement
  2692.            statement-list statement
  2693.  
  2694.        compound-statement:
  2695.            { declaration-list statement-list }
  2696.  
  2697.        statement:
  2698.            ;          # a no-op statement
  2699.            compound-statement
  2700.            expression ;
  2701.            IF ( expression ) statement
  2702.  
  2703.  
  2704.  
  2705.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.        44                               APPENDIX
  2715.  
  2716.  
  2717.            IF ( expression ) statement ELSE    statement
  2718.            SWITCH (    expression ) statement
  2719.            CASE constant : statement
  2720.            DEFAULT : statement
  2721.            BREAK ;
  2722.            WHILE ( expression ) statement
  2723.            FOR ( expression    ; expression ; expression ) statement ;
  2724.            RETURN ;
  2725.            RETURN expression ;
  2726.  
  2727.        function:
  2728.            id ( id-list ) declaration-list statement
  2729.  
  2730.        function-list:
  2731.            empty
  2732.            function
  2733.            function-list function
  2734.  
  2735.        program:
  2736.            empty
  2737.            declaration-list
  2738.            function-list
  2739.            program declaration-list
  2740.            program function-list
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.        APPENDIX                                 45
  2778.  
  2779.  
  2780.        B.  EEEEddddiiiittttoooorrrr CCCCoooommmmmmmmaaaannnndddd SSSSuuuummmmmmmmaaaarrrryyyy
  2781.  
  2782.        This is a quick reference guide for the SCI screen editor.
  2783.  
  2784.        ^Z      exit
  2785.  
  2786.        ^E      cursor up
  2787.  
  2788.        ^X      cursor down
  2789.  
  2790.        ^S      cursor left
  2791.  
  2792.        ^D      cursor right
  2793.  
  2794.        ^A      cursor to end of    previous word
  2795.  
  2796.        ^F      cursor to beginning of next word.
  2797.  
  2798.        ^R      page up
  2799.  
  2800.        ^C      page down
  2801.  
  2802.        <RETURN>    or <LINEFEED> Replace Mode: cursor to beginning     of
  2803.            next  line  Insert  Mode:  append  blank     line after
  2804.            current line
  2805.  
  2806.        ^V      toggle Insert/Replace Mode
  2807.  
  2808.        ^G      delete character    under cursor
  2809.  
  2810.        ^H or <BACKSPACE> delete    character to left of cursor
  2811.  
  2812.        ^Y      delete line
  2813.  
  2814.        ^L      restore line
  2815.  
  2816.        ^Q^F    find string
  2817.  
  2818.        ^Q^A    find and    replace    string
  2819.  
  2820.        ^Q^L    find next occurance of string
  2821.  
  2822.        ^Q^G    go to line
  2823.  
  2824.        ^Q^S    cursor to beginning of line
  2825.  
  2826.        ^Q^D    cursor to end of    line
  2827.  
  2828.  
  2829.  
  2830.  
  2831.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.        46                               APPENDIX
  2841.  
  2842.  
  2843.        ^Q^E    cursor to top of    screen
  2844.  
  2845.        ^Q^X    cursor to bottom    of screen
  2846.  
  2847.        ^Q^R    cursor to top of    program
  2848.  
  2849.        ^Q^C    cursor to end of    program
  2850.  
  2851.        ^Q^B    cursor to beginning of block
  2852.  
  2853.        ^Q^K    cursor to end of    block
  2854.  
  2855.        ^K^B    mark beginning of block
  2856.  
  2857.        ^K^K    mark end    of block
  2858.  
  2859.        ^K^V    insert block
  2860.  
  2861.        ^K^Y    delete block
  2862.  
  2863.        ^K^U    unmark block
  2864.  
  2865.        ^K^R    read from disk file
  2866.  
  2867.        ^K^W    write block to disk file
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.        APPENDIX                                 47
  2904.  
  2905.  
  2906.        C.  DDDDeeeebbbbuuuuggggeeeerrrr CCCCoooommmmmmmmaaaannnndddd SSSSuuuummmmmmmmaaaarrrryyyy
  2907.  
  2908.        This is a quick reference guide to  the    SCI  debuger.    All
  2909.        debuger commands    start with a dot (.) as    the first character
  2910.        in the command to distinguish them from valid C statements.
  2911.  
  2912.        .b#     set a breakpoint    at line    number "#".
  2913.  
  2914.        .B      display all breakpoints set.
  2915.  
  2916.        .c      continue    program    execution to next breakpoint.
  2917.  
  2918.        .d#     delete breakpoint at line number    "#".
  2919.  
  2920.        .D      delete all breakpoints.
  2921.  
  2922.        .e#     examine program with the    SCI editor.
  2923.  
  2924.        .g      display global variables    and their contents.
  2925.  
  2926.        .G      same as ".g" but    also  display  the  first  line     of
  2927.            every function in the program.
  2928.  
  2929.        .q      quit and    return to shell.
  2930.  
  2931.        .s#     step "#"    lines without displaying each line.
  2932.  
  2933.        .t      display function    call trace back.
  2934.  
  2935.        .T      same as ".t" but    also displays each function's local
  2936.            variables and contents.
  2937.  
  2938.        <RETURN>    same as    ".s 1".
  2939.  
  2940.        <ESCAPE>    interrupts  an    executing   program   and   enables
  2941.            debuger.
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.        48                               APPENDIX
  2967.  
  2968.  
  2969.        D.  DDDDiiiiffffffffeeeerrrreeeennnncccceeeessss FFFFrrrroooommmm SSSSttttaaaannnnddddaaaarrrrdddd CCCC
  2970.  
  2971.        SCI supports  a    subset    of  the     C  language.    There  are,
  2972.        however,     some  minor differences that have been    dictated in
  2973.        part by the fact    that this is an    interpreter. These are:
  2974.  
  2975.        1.  Program source lines    are limited to 79 characters,  just
  2976.        to  keep things simple.  The    editor will complain if    you
  2977.        try to create a line    longer than 79 characters.
  2978.  
  2979.        2.  There are no     #define  or  #include    statements,  simply
  2980.        because there is no pre-processor!
  2981.  
  2982.        3.  Comments are    introduced by the number symbol    (#) and    are
  2983.        terminated  by  the    end of the line.  The "/*" and "*/"
  2984.        combinations    will only be barfed at by SCI.
  2985.  
  2986.        4.  Statements in general are terminated    by  the     end  of  a
  2987.        line     -  the    semicolon required by the C language at    the
  2988.        end of a  statement    is  superfluous.  This    restriction
  2989.        imposes  that  an  expression  be completely    on one line
  2990.        (boooo, hissss!), however you no  longer  get  penalized
  2991.        for    forgeting  a  semicolon     (hurray, yay!).  This also
  2992.        implies  that  string  and    character   constants    are
  2993.        terminated  by  the    end  of     the line.  In fact, if    you
  2994.        forget  to  add  the     terminating  quote  or     apostrophe
  2995.        delimiter, SCI will append one for you, whether you like
  2996.        it or not.
  2997.  
  2998.        5.  Data    variable initialization    is not supported by SCI.
  2999.  
  3000.        6.  Local  data    variables  declared   inside   a   compound
  3001.        statement  within  a    function may not have the same name
  3002.        as a    previously declared local  variable.   A  "variable
  3003.        already  declared"  error  will result.  All    other scope
  3004.        rules apply.
  3005.  
  3006.        7.  The logical AND and OR operators (&&     and  ||)  evaluate
  3007.        both     of  their  operands, unlike standard C    which stops
  3008.        evaluation once the truth or    falsehood of an     expression
  3009.        is  known.    Watch  out  for     subtle    errors,    like in    the
  3010.        following example:
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.        APPENDIX                                 49
  3030.  
  3031.  
  3032.            var = 0;
  3033.            if (    var && func() )
  3034.                .
  3035.                .
  3036.                .
  3037.  
  3038.        here    the function "func()"  would  never  be     called     in
  3039.        standard C, but in SCI's dialect, it    is called.
  3040.  
  3041.        8.  The comma operator  is  recognized  only  when  used     in
  3042.        function  calls and data declarations.  For instance, it
  3043.        would be illegal to say:
  3044.  
  3045.            while ( argv++, argc-- );
  3046.  
  3047.        9.  The "default" statement inside a "switch" is    executed as
  3048.        soon    as it is encountered (when scanning from the top to
  3049.        the bottom of the "switch").     SCI is    too lazy to  do     an
  3050.        exhaustive  test  of     all  "case"s  before executing    the
  3051.        "default", so be sure to place  all    "default"s  as    the
  3052.        last    statement in the "switch".
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.        50                               APPENDIX
  3093.  
  3094.  
  3095.        E.  EEEErrrrrrrroooorrrr MMMMeeeessssssssaaaaggggeeeessss
  3096.  
  3097.        When SCI    detects    an error in  your  program,  it     will  stop
  3098.        execution, display an error message and then the    line number
  3099.        and program text    of the offending line.    The SCI    debuger     is
  3100.        then automatically enabled.  The    possible error messages    are
  3101.        listed below:
  3102.  
  3103.        no entry    point -     You forgot to specify    an  entry  function
  3104.            with the    "entry"    keyword    in your    shell file.
  3105.  
  3106.        out  of    memory    -   There  was    insufficient  free   memory
  3107.            available  for the shell    program, variable, function
  3108.            and stack segments.  Specify a smaller -P, -V, -F or
  3109.            -S value.
  3110.  
  3111.        file error -   The  specified  program  file  could  not     be
  3112.            loaded,    or  SHELL.SCI does not exist on    the default
  3113.            disk drive, or the specified file could not be  save
  3114.            on disk because of an operating system error.
  3115.  
  3116.        missing '}' -  The interpreter wandered off the edge of your
  3117.            program because you forgot a closing brace.
  3118.  
  3119.        missing operator    -  The interpreter  found  two    consecutive
  3120.            operands    as for example the statement:  var  3;
  3121.  
  3122.        missing ')' or ']' -  Mismatched    left and right    parentheses
  3123.            or brackets were    detected.
  3124.  
  3125.        not a pointer -    A simple "char"     or  "int"  variable  or  a
  3126.            constant    expression was used as an array    or pointer.
  3127.  
  3128.        syntax error -  An error    was detected in    the structure of  a
  3129.            statement or function.
  3130.  
  3131.        lexical error  -      An  illegal  character  was  found  in  a
  3132.            statement.
  3133.  
  3134.        need an lvalue -     An attempt was    made to    assign a value to a
  3135.            constant    or an array variable.
  3136.  
  3137.        stack underflow -  Something is wrong! Contact the author.
  3138.  
  3139.        stack overflow -     The expression    is too complex or  function
  3140.            calls  are  nested  too    deeply.      Try  specifying a
  3141.            larger -S value when starting up    SCI.
  3142.  
  3143.  
  3144.  
  3145.  
  3146.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.        APPENDIX                                 51
  3156.  
  3157.  
  3158.        too many    functions -  The interpreter ran  out  of  Function
  3159.            Table  space.  Try specifying a larger -F value when
  3160.            starting    up SCI.
  3161.  
  3162.        too many    variables -  The interpreter ran  out  of  Variable
  3163.            Table  space.  Try specifying a larger -V value when
  3164.            starting    up SCI.
  3165.  
  3166.        stmt outside of function    -  There is  something    wrong  with
  3167.            the  structure  of  your     program.   Typically  this
  3168.            results from a statement    appearing  outside  of    any
  3169.            function    body, or mismatched curly braces (}).
  3170.  
  3171.        missing '{' -  The left brace  that  introduces    a  function
  3172.            body was    missing.
  3173.  
  3174.        bad sys call -  The number of arguments passed  to  a  "sys"
  3175.            call is incorrect for the specified "sys" number, or
  3176.            an invalid "sys"    number was given.
  3177.  
  3178.        undeclared variable -  A    variable has been used without ever
  3179.            having been declared.
  3180.  
  3181.        variable    already    declared -  An    attempt     was  made  to    re-
  3182.            declare    a  variable  name  within  the    program     or
  3183.            function.
  3184.  
  3185.        interrupt -  The    program    was  interrupted  by  pressing    the
  3186.            <ESCAPE>    key.
  3187.  
  3188.        multidimension arrays not supported -  Just what    it says: we
  3189.            don't do    multi dimensional arrays.
  3190.  
  3191.        illegal pointer operation -  A mathematical operation  other
  3192.            than  addition  or  subtraction was attempted on    two
  3193.            pointers    or a pointer and an integer.
  3194.  
  3195.        invalid data address -    The  program  attempted     to  access
  3196.            memory  outside    of  the     program, variable or stack
  3197.            space and the debug level was 1 or greater.  If    you
  3198.            have  confidence     that your program will    not corrupt
  3199.            the operating system by wanton POKEs  of     data,    you
  3200.            may  set     the  debug  level  to zero to disable this
  3201.            error checking.
  3202.  
  3203.        not a structure or union    -  A variable that was not declared
  3204.            as  a  structure    or union was used in a structure or
  3205.            union reference.
  3206.  
  3207.  
  3208.  
  3209.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.        52                               APPENDIX
  3219.  
  3220.  
  3221.        compatability error -  A    semicolon was omitted, or a similar
  3222.            type   of   error  was  detected     that  would  cause
  3223.            compatability problems with standard C.
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.        SCI Users Manual             Copyright (C) 1986, Bob Brodt
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.                  CONTENTS
  3285.  
  3286.  
  3287.        1.  Introduction........................................      1
  3288.        1.1     Starting Out..................................      2
  3289.        1.2     Memory    Allocation.............................      3
  3290.  
  3291.        2.  The Shell...........................................      4
  3292.        2.1     Shell Commands................................      4
  3293.        2.2     Running Your Program..........................      6
  3294.        2.3     Program Variables.............................      6
  3295.  
  3296.        3.  The Editor..........................................      8
  3297.        3.1     Keys..........................................      8
  3298.        3.2     Screen    Layout.................................      8
  3299.        3.3     Screen    Customization..........................      9
  3300.        3.4     Keyboard Customization........................     11
  3301.        3.5     Sample    Configurations.........................     12
  3302.        3.6     Editor    Commands...............................     14
  3303.  
  3304.        4.  Language Summary....................................     19
  3305.        4.1     Line Terminators..............................     19
  3306.        4.2     Comments......................................     19
  3307.        4.3     Identifiers...................................     19
  3308.        4.4     Keywords......................................     20
  3309.        4.5     Numeric Constants.............................     20
  3310.        4.6     Character Constants...........................     20
  3311.        4.7     String    Constants..............................     21
  3312.        4.8     Data Types....................................     21
  3313.        4.9     Operators.....................................     22
  3314.        4.10     Comma Operator................................     23
  3315.        4.11     Program Control Flow Constructs...............     24
  3316.  
  3317.        5.  Library Functions...................................     25
  3318.        5.1     atoi..........................................     26
  3319.        5.2     bdos..........................................     27
  3320.        5.3     debug.........................................     27
  3321.        5.4     dirscan.......................................     28
  3322.        5.5     edit..........................................     28
  3323.        5.6     exit..........................................     28
  3324.        5.7     fclose........................................     29
  3325.        5.8     fgetc.........................................     29
  3326.        5.9     fgets.........................................     29
  3327.        5.10     fopen.........................................     29
  3328.        5.11     fputc.........................................     30
  3329.        5.12     fputs.........................................     30
  3330.        5.13     fread.........................................     31
  3331.        5.14     free..........................................     31
  3332.  
  3333.  
  3334.  
  3335.                   - i -
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.        5.15     fseek and ftell...............................     31
  3348.        5.16     fwrite........................................     32
  3349.        5.17     int86.........................................     32
  3350.        5.18     load..........................................     32
  3351.        5.19     malloc........................................     33
  3352.        5.20     memleft.......................................     33
  3353.        5.21     printf........................................     33
  3354.        5.22     save..........................................     34
  3355.        5.23     scanf.........................................     35
  3356.        5.24     sprintf.......................................     35
  3357.        5.25     sscanf........................................     35
  3358.        5.26     stmt..........................................     35
  3359.        5.27     strcmp, strncmp...............................     36
  3360.        5.28     strcpy, strncpy...............................     36
  3361.        5.29     strlen........................................     36
  3362.        5.30     system........................................     36
  3363.        5.31     totok.........................................     37
  3364.        5.32     untok.........................................     37
  3365.        5.33     version.......................................     37
  3366.  
  3367.        6.  The Debuger.........................................     38
  3368.  
  3369.        A.  SCI Language    Syntax.................................     40
  3370.  
  3371.        B.  Editor Command Summary..............................     45
  3372.  
  3373.        C.  Debuger Command Summary.............................     47
  3374.  
  3375.        D.  Differences From Standard C.........................     48
  3376.  
  3377.        E.  Error Messages......................................     50
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383.  
  3384.  
  3385.  
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.                   - ii -
  3399.  
  3400.  
  3401.  
  3402.  
  3403.