home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / interpre / bwbasic / bwbasic.doc next >
Text File  |  1992-10-27  |  17KB  |  442 lines

  1.  
  2.  
  3.  
  4.  
  5.                Bywater BASIC Interpreter/Shell, version 1.10
  6.                ---------------------------------------------
  7.  
  8.                     Copyright (c) 1992, Ted A. Campbell
  9.                  for bwBASIC version 1.10, 1 November 1992
  10.  
  11.  
  12. CONTENTS:
  13.  
  14.    1. DESCRIPTION
  15.    2. TERMS OF USE
  16.    3. COMMANDS AND FUNCTIONS IMPLEMENTED
  17.    4. SOME NOTES ON USAGE
  18.    5. UNIMPLEMENTED COMMANDS AND FUNCTIONS
  19.    6. SOME NOTES ON COMPILATION
  20.    7. THE STORY OF BYWATER BASIC
  21.    8. COMMUNICATIONS
  22.  
  23.  
  24. 1. DESCRIPTION
  25.  
  26.    The Bywater BASIC Interpreter (bwBASIC) implements a large
  27.    superset of the ANSI Standard for Minimal BASIC (X3.60-1978)
  28.    in ANSI C and offers shell program facilities as an extension
  29.    of BASIC.
  30.  
  31.    The set of BASIC commands and functions implemented is fairly
  32.    limited (see section three below), although more commands and
  33.    functions are implemented than appear in the specification
  34.    for Minimal BASIC. There are no commands that are terminal- or
  35.    hardware specific. (Seriously -- CLS may work under bwBASIC
  36.    on your DOS-based pc, but that is because bwBASIC shells
  37.    out to DOS when it does not recognize CLS and executes CLS there.)
  38.  
  39.    The interpreter is slow.  Whenever faced with a choice between 
  40.    conceptual clarity and speed, I have consistently chosen
  41.    the former.  The interpreter is the simplest design available,
  42.    and utilizes no system of intermediate code, which would speed
  43.    up considerably its operation.  As it is, each line is interpreted
  44.    afresh as the interpreter comes to it. 
  45.  
  46.    bwBASIC implements one feature not available in previous BASIC
  47.    interpreters: a shell command can be entered interactively at the
  48.    bwBASIC prompt, and the interpreter will execute it under a
  49.    command shell.  For instance, the command "dir *.bas" can be
  50.    entered in bwBASIC (under DOS, or "ls -l *.bas" under UNIX) and
  51.    it will be executed as from the operating system command line.
  52.    Shell commands can also be given on numbered lines in a bwBASIC
  53.    program, so that bwBASIC can be used as a shell programming
  54.    language. bwBASIC's implementation of the RMDIR, CHDIR, MKDIR,
  55.    NAME, KILL, ENVIRON, and ENVIRON$() commands and functions
  56.    offer further shell-processing capabilities.
  57.  
  58.  
  59. 2. TERMS OF USE:
  60.  
  61.    The bwBASIC source code and executables produced from it can be
  62.    used subject to the following statement which is included in
  63.    the header to all the source code files:
  64.  
  65.         All U.S. and international copyrights are claimed by the
  66.         author. The author grants permission to use this code
  67.         and software based on it under the following conditions:
  68.         (a) in general, the code and software based upon it may be
  69.         used by individuals and by non-profit organizations; (b) it
  70.         may also be utilized by governmental agencies in any country,
  71.         with the exception of military agencies; (c) the code and/or
  72.         software based upon it may not be sold for a profit without
  73.         an explicit and specific permission from the author, except
  74.         that a minimal fee may be charged for media on which it is
  75.         copied, and for copying and handling; (d) the code must be
  76.         distributed in the form in which it has been released by the
  77.         author; and (e) the code and software based upon it may not
  78.         be used for illegal activities.
  79.  
  80.  
  81. 3. BASIC COMMANDS AND FUNCTIONS IMPLEMENTED:
  82.  
  83.    ABS( number )
  84.    ASC( string$ )
  85.    ATN( number )
  86.    CHAIN [MERGE] file-name [, line-number] [, ALL]
  87.    CHR$( number )
  88.    CINT( number )
  89.    CLEAR
  90.    CLOSE [[#]file-number]...
  91.    COMMON variable [, variable...]
  92.    COS( number )
  93.    CSNG( number )
  94.    CVD( string$ )
  95.    CVI( string$ )
  96.    CVS( string$ )
  97.    DATA constant[,constant]...
  98.    DATE$
  99.    DEF FNname(arg...)] = expression
  100.    DEFDBL letter[-letter](, letter[-letter])...
  101.    DEFINT letter[-letter](, letter[-letter])...
  102.    DEFSNG letter[-letter](, letter[-letter])...
  103.    DEFSTR letter[-letter](, letter[-letter])...
  104.    DELETE line[-line]
  105.    DIM variable(elements...)[variable(elements...)]...
  106.    END
  107.    ENVIRON variable-string = string
  108.    ENVIRON$( variable-string )
  109.    EOF( device-number )
  110.    ERASE variable[, variable]...
  111.    ERL
  112.    ERR
  113.    ERROR number
  114.    EXP( number )
  115.    FIELD [#] device-number, number AS string-variable [, number AS string-variable...]
  116.    FOR counter = start TO finish [STEP increment]
  117.    GET [#] device-number [, record-number]
  118.    GOSUB line
  119.    GOTO line
  120.    HEX$( number )
  121.    IF expression THEN statement [ELSE statement]
  122.    INPUT [# device-number]|[;]["prompt string";]list of variables
  123.    INSTR( [start-position,] string-searched$, string-pattern$ )
  124.    INT( number )
  125.    KILL file-name
  126.    LEFT$( string$, number-of-spaces )
  127.    LEN( string$ )
  128.    LET variable = expression
  129.    LINE INPUT [[#] device-number,]["prompt string";] string-variable$
  130.    LIST line[-line]
  131.    LOAD file-name
  132.    LOC( device-number )
  133.    LOF( device-number )
  134.    LOG( number )
  135.    LSET string-variable$ = expression
  136.    MERGE file-name
  137.    MID$( string$, start-position-in-string[, number-of-spaces ] )
  138.    MKD$( double-value# )
  139.    MKI$( integer-value% )
  140.    MKS$( single-value! )
  141.    NAME old-file-name AS new-file-name
  142.    NEW
  143.    NEXT counter
  144.    OCT$( number )
  145.    ON variable GOTO|GOSUB line[,line,line,...]
  146.    ON ERROR GOSUB line
  147.    OPEN O|I|R, [#]device-number, file-name [,record length]
  148.         file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length]
  149.    OPTION BASE number
  150.    POS
  151.    PRINT [# device-number,][USING format-string$;] expressions...
  152.    PUT [#] device-number [, record-number]
  153.    RANDOMIZE number
  154.    READ variable[, variable]...
  155.    REM string
  156.    RESTORE line
  157.    RETURN
  158.    RIGHT$( string$, number-of-spaces )
  159.    RND( number )
  160.    RSET string-variable$ = expression
  161.    RUN [line][file-name]
  162.    SAVE file-name
  163.    SGN( number )
  164.    SIN( number )
  165.    SPACE$( number )
  166.    SPC( number )
  167.    SQR( number )
  168.    STOP
  169.    STR$( number )
  170.    STRING$( number, ascii-value|string$ )
  171.    SWAP variable, variable
  172.    SYSTEM
  173.    TAB( number )
  174.    TAN( number )
  175.    TIME$
  176.    TIMER
  177.    TROFF
  178.    TRON
  179.    VAL( string$ )
  180.    WEND
  181.    WHILE expression
  182.    WIDTH [# device-number,] number
  183.    WRITE [# device-number,] element [, element ].... 
  184.  
  185.    If DIRECTORY_CMDS is set to TRUE when the program is compiled,
  186.    then the following commands will be available:
  187.  
  188.    CHDIR pathname
  189.    MKDIR pathname
  190.    RMDIR pathname
  191.  
  192.    If DEBUG is set to TRUE when the program is compiled then
  193.    the following debugging commands (unique to bwBASIC) will
  194.    be available:
  195.  
  196.    VARS            (prints a list of all variables)
  197.    CMDS            (prints a list of all commands)
  198.    FNCS            (prints a list of all functions)
  199.  
  200.    If COMMAND_SHELL is set to TRUE when the program is compiled,
  201.    then the user may enter a shell command at the bwBASIC prompt.
  202.  
  203.  
  204. 4. SOME NOTES ON USAGE:
  205.  
  206.    An interactive environment is provided, so that a line with a
  207.    line number can be entered at the bwBASIC prompt and it will be
  208.    added to the program in memory.
  209.  
  210.    Line numbers are not strictly required, but are useful if the
  211.    interactive enviroment is used for programming.  For longer
  212.    program entry one might prefer to use an ASCII text editor, and
  213.    in this case lines can be entered without numbers. In this case,
  214.    however, one will not be able to alter the numberless lines
  215.    within the interactive environment.
  216.  
  217.    Command names and function names are not case sensitive,
  218.    so that "Run" and "RUN" and "run" are equivalent and "abs()"
  219.    and "ABS()" and "Abs()" are equivalent. HOWEVER: variable
  220.    names ARE case sensitive in bwbASIC, so that "d$" and "D$"
  221.    are different variables.  This differs from some BASIC
  222.    implementations where variable names are not case sensitive.
  223.  
  224.    A filename can be specified on the command line and will be
  225.    LOADed and RUN immediately, so that the command line
  226.  
  227.       bwbasic prog.bas
  228.  
  229.    will load and execute "prog.bas".
  230.  
  231.    All programs are stored as ASCII text files.
  232.  
  233.    TRUE is defined as -1 and FALSE is defined as 0 in the default
  234.    distribution of bwBASIC. These definitions can be changed by
  235.    those compiling bwBASIC (see file BWBASIC.H).
  236.  
  237.    Assignment must be made to variables.  This differs from some
  238.    implementations of BASIC where assignment can be made to a
  239.    function.  Implication: "INSTR( 3, x$, y$ ) = z$" will not
  240.    work under bwBASIC.
  241.  
  242.    Notes on the implementation of specific commands:
  243.  
  244.    CVI(), CVD(), CVS(), MKI$(), MKD$(), MKS$(): These functions
  245.    are implemented, but are dependent on a) the sizes for integer,
  246.    float, and double values on particular systems, and b) how
  247.    particular versions of C store these numerical values. The
  248.    implication is that data files created using these functions
  249.    on a DOS-based microcomputer may not be translated correctly
  250.    by bwBASIC running on a Unix-based computer.  Similarly, data
  251.    files created by bwBASIC compiled by one version of C may not be
  252.    readable by bwBASIC compiled by another version of C (even under
  253.    the same operating system). So be careful with these.
  254.  
  255.    ENVIRON:  The ENVIRON command requires BASIC strings on either
  256.    side of the equals sign.  Thus: 
  257.  
  258.       environ "PATH" = "/usr/bin"
  259.  
  260.    It might be noted that this differs from the implementation
  261.    of ENVIRON in some versions of BASIC, but bwBASIC's ENVIRON
  262.    allows BASIC variables to be used on either side of the equals
  263.    sign.  Note that the function ENVIRON$() is different from the
  264.    command, and be aware of the fact that in some operating systems
  265.    an environment variable set within a program will not be passed
  266.    to its parent shell.
  267.  
  268.    ERR: Note that if PROG_ERRORS has been defined when bwBASIC is
  269.    compiled, the ERR variable will not be set correctly upon
  270.    errors.  It only works when standard error messages are used.
  271.  
  272.    FOR and NEXT:  In this implementation of bwBASIC, a NEXT
  273.    statement must appear in the first position in a program
  274.    line; it cannot appear in a line segment beyond a colon.
  275.  
  276.    INPUT: bwBASIC cannot support the optional feature of INPUT
  277.    that suppresses the carriage-return and line-feed at the end
  278.    of the input.  This is because ANSI C does not provide for any
  279.    means of input other than CR-LF-terminated strings.
  280.  
  281.  
  282. 5. UNIMPLEMENTED COMMANDS AND FUNCTIONS
  283.  
  284.    There are a few items not implemented that have been so long
  285.    a part of standard BASICs that their absence will seem surprising.
  286.    In each case, though, their implementation would require opera-
  287.    ting-system-specific functions or terminal-specific functions
  288.    that ANSI C cannot provide. Some specific examples:
  289.  
  290.    CALL        In some versions of BASIC, CALL is used to call a
  291.         machine language subroutine, but machine language
  292.         routines are highly system-specific.  In other
  293.         BASICs (conforming to the more complete ANSI
  294.         definition of BASIC), CALL is used to call a
  295.         named subroutine.  Although it's possible that
  296.         bwBASIC could develop as a numberless BASIC
  297.         with named subroutine calls, these features
  298.         are not implemented in this earliest released
  299.         version.
  300.  
  301.    CLOAD    See CALL above (machine language subroutines).
  302.  
  303.    CONT        See RESUME below (programmer ignorance?).
  304.  
  305.    DEF USR    See CALL above (machine language subroutines).
  306.  
  307.    EDIT        EDIT would be especially nice, but requires some
  308.            specific knowledge of how particular computers
  309.            handle interaction between the screen and the
  310.            keyboard.  This knowledge isn't available within
  311.            the bounds of ANSI C alone ("innerhalb die Grenzen
  312.         der reinen Vernunft," with apologies to Immanuel
  313.         Kant).
  314.  
  315.    FRE()    The ability to report the amount of free memory
  316.         remaining is system-specific due to varying patterns
  317.         of memory allocation and access; consequently this
  318.         ability is not present in ANSI C and this function
  319.         is not available in bwBASIC.
  320.  
  321.    FILES    The FILES command requires a list of files conforming
  322.            to a specifier; ANSI C does not provide this. When
  323.            COMMAND_SHELL is defined as TRUE, users might want
  324.            to issue operating-system commands such as "DIR"
  325.            (DOS) or "ls -l" (Unix) to get a list of files.
  326.  
  327.    INKEY$    This function requires a keyboard scan to indicate
  328.         whether a key is pending. Although this facility
  329.         is easily available on microcomputers (it is part
  330.         of the minimal CP/M Operating System), it is not
  331.         easily available on some more complex systems. 
  332.         Consequently, it's not part of the C standard and
  333.         bwBASIC has not implemented INKEY$.
  334.  
  335.    INPUT$()    Similar to INKEY$ above, ANSI C by itself is not
  336.            able to read unechoed keyboard input, and can read
  337.            keyboard input only after a Carriage-Return has
  338.            been entered. 
  339.  
  340.    INP        Calls to hardware ports, like machine-language
  341.            routines, are highly system-specific and cannot
  342.            be implemented in ANSI C alone.
  343.  
  344.    LLIST    See LPRINT below.
  345.  
  346.    LPOS        See LPRINT below.
  347.  
  348.    LPRINT    and LLIST, etc., require access to a printer device,
  349.            and this varies from one system to another. Users
  350.            might try OPENing the printer device on their own
  351.            operating system (e.g., "/dev/lp" on Unix systems,
  352.            or "PRN" under DOS) and see if printing can be done
  353.            from bwBASIC in this way.
  354.  
  355.    NULL        In this case, I am convinced that NULL is no longer
  356.         necessary, since very few printers now require NULLs
  357.         at the end of lines.
  358.  
  359.    OUT        See INP above (calls to hardware ports).
  360.  
  361.    PEEK()    PEEK and POKE enabled earlier BASICs to address
  362.            particular memory locations. Although bwBASIC
  363.            could possibly implement this command (POKE) and
  364.            this function (PEEK()), the limitation would be
  365.            highly limited by the different systems for
  366.            memory access in different systems.
  367.  
  368.    POKE        see PEEK() above.
  369.  
  370.    RENUM    Since unnumbered lines can be entered and
  371.            executed under bwBASIC, it would not be
  372.            possible to implement a RENUM routine.
  373.  
  374.    RESUME    Is this possible under ANSI C? If so, I
  375.            simply have failed to figure it out yet.
  376.            Mea culpa (but not maxima).
  377.  
  378.    USR        See CALL and DEF USR above (machine language
  379.            subroutines).
  380.  
  381.    VARPTR    See PEEK and POKE above.
  382.  
  383.    WAIT        See INP and OUT above.
  384.  
  385.            
  386. 6. SOME NOTES ON COMPILATION
  387.  
  388.    bwBASIC is written in ANSI C and takes advantage of some of the
  389.    enhancements of ANSI C over the older K&R standard.  The program
  390.    expects to find standard ANSI C include files (such as <stddef.h>).
  391.    Because there is nothing terminal- or hardware-specific about it,
  392.    I should hope that it would compile correctly under any ANSI C
  393.    compiler, but you may have to construct your own makefile.
  394.  
  395.    Two makefiles are currently provided: "makefile.qcl" will compile
  396.    the program utilizing the Microsoft QuickC (tm) line-oriented 
  397.    compiler on DOS-based p.c.'s, and "makefile.gcc" will compile 
  398.    the program utilizing the ANSI option of Gnu C++. I have also 
  399.    compiled the program utilizing Borland's Turbo C++ (tm) on DOS-
  400.    based machines.
  401.  
  402.    No alterations to flags are necessary for varied environments,
  403.    but the beginning of file <bwbasic.h> allows the user to set
  404.    some debugging flags and to control some program defaults.
  405.    The file <bwb_mes.h> has a number of language-specific message
  406.    sets that can be controlled by setting the appropriate language
  407.    flag.
  408.  
  409.  
  410. 7. THE STORY OF BYWATER BASIC
  411.  
  412.    This program was originally begun in 1982 by my grandmother, Mrs.
  413.    Verda Spell of Beaumont, TX.  She was writing the program using
  414.    an ANSI C compiler on an Osborne I CP/M computer and although my
  415.    grandfather (Lockwood Spell) had bought an IBM PC with 256k of
  416.    RAM my grandmother would not use it, paraphrasing George Herbert
  417.    to the effect that "He who cannot in 64k program, cannot in 512k."
  418.    She had used Microsoft BASIC and although she had nothing against
  419.    it she said repeatedly that she didn't understand why Digital
  420.    Research didn't "sue the socks off of Microsoft" for version 1.0
  421.    of MSDOS and so I reckon that she hoped to undercut Microsoft's
  422.    entire market and eventually build a new software empire on
  423.    the North End of Beaumont. Her programming efforts were cut
  424.    tragically short when she was thrown from a Beaumont to Port
  425.    Arthur commuter train in the summer of 1986. I found the source
  426.    code to bwBASIC on a single-density Osborne diskette in her knitting
  427.    bag and eventually managed to have it all copied over to a PC
  428.    diskette. I have revised it slightly prior to this release. You
  429.    should know, though, that I myself am an historian, not a programmer.
  430.  
  431.    
  432. 8. COMMUNICATIONS:
  433.  
  434.    Ted A. Campbell
  435.    Bywater Software
  436.    P.O. Box 4023
  437.    Duke Station
  438.    Durham, NC  27706
  439.    USA
  440.  
  441.    email:  tcamp@acpub.duke.edu
  442.