home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-29 | 74.6 KB | 2,312 lines |
- Newsgroups: comp.sources.misc
- From: tcamp@delphi.com (Ted A. Campbell)
- Subject: v40i052: bwbasic - Bywater BASIC interpreter version 2.10, Part01/15
- Message-ID: <csm-v40i052=bwbasic.112142@sparky.Sterling.COM>
- X-Md4-Signature: 1ad90d355a4a15c007f2afe7e2595499
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Fri, 29 Oct 1993 16:22:50 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: tcamp@delphi.com (Ted A. Campbell)
- Posting-number: Volume 40, Issue 52
- Archive-name: bwbasic/part01
- Environment: UNIX, DOS
- Supersedes: bwbasic: Volume 33, Issue 37-47
-
- Bywater Software Announces
-
- Bywater BASIC Interpreter/Shell, version 2.10
- ---------------------------------------------
-
- Copyright (c) 1993, Ted A. Campbell
- for bwBASIC version 2.10, 11 October 1993
-
- DESCRIPTION:
-
- The Bywater BASIC Interpreter (bwBASIC) implements a large
- superset of the ANSI Standard for Minimal BASIC (X3.60-1978)
- and a significant subset of the ANSI Standard for Full BASIC
- (X3.113-1987) in C. It also offers shell programming facilities
- as an extension of BASIC. bwBASIC seeks to be as portable
- as possible.
-
- This version of Bywater BASIC is released under the terms of the
- GNU General Public License (GPL), which is distributed with this
- software in the file "COPYING". The GPL specifies the terms
- under which users may copy and use the software in this distribution.
-
- A separate license is available for commercial distribution,
- for information on which you should contact the author.
-
- IMPROVEMENTS OVER PREVIOUS VERSION (1.11):
-
- * now compilable on "stock" (older K&R specification) C compilers;
-
- * implements ANSI-BASIC-style structured programming, with
- called subroutines, multi-line functions, multi-line IF-THEN
- ELSE statements, SELECT CASE statements, etc.;
-
- * new enhancements to the interactive environment, such as DO NUM
- and DO UNNUM to number or unnumber all program lines;
-
- * addition of some hardware-specific commands such as CLS, LOCATE,
- and INKEY$ (at present for IBM PC and compatibles, using the
- Microsoft QuickC compiler), opening the way for more hardware-
- specific commands and functions in the future;
-
- * general improvements to reliability and portability, including
- more extensive testing than previous versions;
-
- COMMUNICATIONS:
-
- email: tcamp@delphi.com
-
- A LIST OF BASIC COMMANDS AND FUNCTIONS IMPLEMENTED in bwBASIC 2.10:
-
- Be aware that many of these commands and functions will not be
- available unless you have set certain flags in the header files.
-
- ABS( number )
- ASC( string$ )
- ATN( number )
- CALL subroutine-name
- CASE constant | IF partial-expression | ELSE
- CHAIN file-name
- CHDIR pathname
- CHR$( number )
- CINT( number )
- CLEAR
- CLOSE [[#]file-number]...
- CLS
- COMMON variable [, variable...]
- COS( number )
- CSNG( number )
- CVD( string$ )
- CVI( string$ )
- CVS( string$ )
- DATA constant[,constant]...
- DATE$
- DEF FNname(arg...)] = expression
- DEFDBL letter[-letter](, letter[-letter])...
- DEFINT letter[-letter](, letter[-letter])...
- DEFSNG letter[-letter](, letter[-letter])...
- DEFSTR letter[-letter](, letter[-letter])...
- DELETE line[-line]
- DIM variable(elements...)[variable(elements...)]...
- DO NUM|UNNUM
- DO [WHILE expression]
- EDIT (* depends on variable BWB.EDITOR$)
- ELSE
- ELSEIF
- END FUNCTION | IF | SELECT | SUB
- ENVIRON variable-string$ = string$
- ENVIRON$( variable-string )
- EOF( device-number )
- ERASE variable[, variable]...
- ERL
- ERR
- ERROR number
- EXIT FOR|DO
- EXP( number )
- FIELD [#] device-number, number AS string-variable [, number AS string-variable...]
- FILES filespec$ (* depends on variable BWB.FILES$)
- FOR counter = start TO finish [STEP increment]
- FUNCTION function-definition
- GET [#] device-number [, record-number]
- GOSUB line | label
- GOTO line | label
- HEX$( number )
- IF expression THEN [statement [ELSE statement]]
- INKEY$
- INPUT [# device-number]|[;]["prompt string";]list of variables
- INSTR( [start-position,] string-searched$, string-pattern$ )
- INT( number )
- KILL file-name
- LEFT$( string$, number-of-spaces )
- LEN( string$ )
- LET variable = expression
- LINE INPUT [[#] device-number,]["prompt string";] string-variable$
- LIST line[-line]
- LOAD file-name
- LOC( device-number )
- LOCATE
- LOF( device-number )
- LOG( number )
- LOOP [UNTIL expression]
- LSET string-variable$ = expression
- MERGE file-name
- MID$( string$, start-position-in-string[, number-of-spaces ] )
- MKD$( number )
- MKDIR pathname
- MKI$( number )
- MKS$( number )
- NAME old-file-name AS new-file-name
- NEW
- NEXT counter
- OCT$( number )
- ON variable GOTO|GOSUB line[,line,line,...]
- ON ERROR GOSUB line | label
- OPEN O|I|R, [#]device-number, file-name [,record length]
- file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length]
- OPTION BASE number
- POS
- PRINT [# device-number,][USING format-string$;] expressions...
- PUT [#] device-number [, record-number]
- RANDOMIZE number
- READ variable[, variable]...
- REM string
- RESTORE line
- RETURN
- RIGHT$( string$, number-of-spaces )
- RMDIR pathname
- RND( number )
- RSET string-variable$ = expression
- RUN [line]|[file-name]
- SAVE file-name
- SELECT CASE expression
- SGN( number )
- SIN( number )
- SPACE$( number )
- SPC( number )
- SQR( number )
- STOP
- STR$( number )
- STRING$( number, ascii-value|string$ )
- SUB subroutine-name
- SWAP variable, variable
- SYSTEM
- TAB( number )
- TAN( number )
- TIME$
- TIMER
- TROFF
- TRON
- VAL( string$ )
- WEND
- WHILE expression
- WIDTH [# device-number,] number
- WRITE [# device-number,] element [, element ]....
- -----
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: bwbasic-2.10 bwbasic-2.10/INSTALL bwbasic-2.10/bwbasic.doc
- # bwbasic-2.10/bwbtest bwbasic-2.10/bwbtest/dataread.bas
- # Wrapped by kent@sparky on Thu Oct 21 10:47:47 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 15)."'
- if test ! -d 'bwbasic-2.10' ; then
- echo shar: Creating directory \"'bwbasic-2.10'\"
- mkdir 'bwbasic-2.10'
- fi
- if test -f 'bwbasic-2.10/INSTALL' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/INSTALL'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/INSTALL'\" \(6264 characters\)
- sed "s/^X//" >'bwbasic-2.10/INSTALL' <<'END_OF_FILE'
- XSome Notes on Installation of the Bywater BASIC Interpreter:
- X-----------------------------------------------------------
- X
- X0. Quick-Start Guide For Compiling
- X
- X To use the default configuration (which is reasonable for most situations):
- X
- X On Unix, type "configure; make".
- X On MS-DOS using QuickC, type "nmake -f makefile.qcl".
- X
- X You can skip the rest of this file unless you want to customize the
- X BASIC dialect that is supported, or something goes wrong in the
- X above commands.
- X
- X1. Compiler Requirements
- X
- X Although earlier versions of bwBASIC would compile only with
- X ANSI C compilers, versions 2.10 and higher can be compiled
- X with "stock" C compilers, i.e., compilers that comply with
- X the older Kernighan and Ritchie C standard.
- X
- X Section I-B of bwbasic.h allows you to specify some compiler
- X features. If you have an ANSI C compiler, you needn't worry
- X with this. For stock C compilers, the default configuration
- X presumes that your compiler supports signal() and raise()
- X with the signal.h header, supports setjmp() and longjmp()
- X with the setjmp.h header, and has a separate string.h
- X header. If your compiler does not have these features
- X and the related header files, you can indicate this in
- X section I-B by setting appropriate flags to FALSE.
- X
- X
- X2. Configuration of header files
- X
- X You may need to examine file "bwbasic.h" to make important
- X changes for specific hardware and compiler configurations.
- X You may also need to change "bwx_tty.h" if you are using the
- X TTY implementation or "bwx_iqc.h" if you are using the version
- X for PCs with Microsoft QuickC (see below on "implementations").
- X If you want to redefine messages or even the BASIC command
- X names, you will need to edit "bwb_mes.h".
- X
- X
- X3. Makefiles
- X
- X Several makefiles are provided: "makefile.qcl" will compile
- X the program utilizing the Microsoft QuickC (tm) line-oriented
- X compiler on DOS-based p.c.'s, and "makefile" will compile the
- X program on Unix-based computers utilizing either a stock C
- X compiler or Gnu C++. I have also compiled the program utilizing
- X Borland's Turbo C++ (tm) on DOS-based machines, although I have
- X not supplied a makefile for Turbo C++.
- X
- X If you try the "IQC" implementation, you will need to alter
- X makefile.qcl to include bwx_iqc.c (and bqx_iqc.obj) instead
- X of bwx_tty.*.
- X
- X
- X4. Implementations
- X
- X The present status of bwBASIC allows two major implementations
- X controlled by the IMP_TTY and IMP_IQC flags in bwbasic.h.
- X IMP_TTY is the base implementation and presumes a simple
- X TTY-style environment, with all keyboard and screen input
- X and output directed through stdin and stdout. If IMP_TTY is
- X defined as TRUE, then the file bwx_tty.h will be included,
- X and a makefile should include compilation of bwx_tty.c.
- X IMP_IQC is a somewhat more elaborate implementation for
- X the IBM PC and compatible microcomputers utilizing the
- X Microsoft QuickC compiler. This allows some more elaborate
- X commands (CLS and LOCATE) and the INKEY$ function, and
- X allows greater control over output. If IMP_IQC is defined
- X as TRUE in bwbasic.h, then bwx_iqc.h will be included and
- X bwx_iqc.c should be compiled in the makefile.
- X
- X Only one of the flags IMP_TTY or IMP_IQC should be set
- X to TRUE.
- X
- X
- X5. Flags Controlling Groups of Commands and Functions
- X
- X There are a number of flags which control groups of commands
- X and functions to be implemented.
- X
- X (core) Commands and Functions in any implementation of
- X bwBASIC; these are the ANSI Minimal BASIC core
- X
- X INTERACTIVE Commands supporting the interactive programming
- X environment
- X
- X COMMON_CMDS Commands beyond ANSI Minimal BASIC which are common
- X to Full ANSI BASIC and Microsoft BASICs
- X
- X COMMON_FUNCS Functions beyond the ANSI Mimimal BASIC core, but
- X common to both ANSI Full BASIC and Microsoft-style
- X BASIC varieties
- X
- X UNIX_CMDS Commands which require Unix-style directory and
- X environment routines not specified in ANSI C
- X
- X STRUCT_CMDS Commands related to structured programming; all
- X of these are part of the Full ANSI BASIC standard
- X
- X ANSI_FUNCS Functions unique to ANSI Full BASIC
- X
- X MS_CMDS Commands unique to Microsoft BASICs
- X
- X MS_FUNCS Functions unique to Microsoft BASICs
- X
- X
- X6. Configurations
- X
- X The file bwbasic.h includes a number of configuration options
- X that will automatically select groups of commands and functions
- X according to predetermined patterns. These are:
- X
- X CFG_ANSIMINIMAL Conforms to ANSI Minimal BASIC standard X3.60-1978.
- X
- X CFG_COMMON Small implementation with commands and functions
- X common to GWBASIC (tm) and ANSI full BASIC.
- X
- X CFG_MSTYPE Configuration similar to Microsoft line-oriented
- X BASICs.
- X
- X CFG_ANSIFULL Conforms to ANSI Full BASIC standard X3.113-1987
- X (subset at present).
- X
- X CFG_CUSTOM Custom Configuration specified by user.
- X
- X Only one of these flags should be set to TRUE.
- X
- X
- X7. Adding Commands and Functions
- X
- X In order to add a new command to bwBASIC, follow the following
- X procedure:
- X
- X (a) Write the command body using function bwb_null() in bwb_cmd.c
- X as a template. The command-body function (in C) must receive a
- X pointer to a bwb_line structure, and must pass on a pointer to
- X a bwb_line structure. The preferred method for returning from
- X a command-body function is: return bwb_zline( l ); this will
- X discriminate between MULTISEG_LINES programs which advance to
- X the next segment and those which advance to the next line.
- X
- X (b) Add prototypes for the command-body function in bwbasic.h;
- X you'll need one prototype with arguments in the ANSI_C section
- X and one prototype without arguments in the non-ANSI_C section.
- X
- X (c) Add the command to the command table in bwb_tbl.c in the
- X group you have selected for it.
- X
- X (d) Increment the number of commands for the group in which
- X you have placed your command.
- X
- X The procedure for adding a new function is parallel to this, except that
- X you should use fnc_null() in bwb_fnc.c as the template, and the
- X function name must be added to the function table in bwb_tbl.c.
- END_OF_FILE
- if test 6264 -ne `wc -c <'bwbasic-2.10/INSTALL'`; then
- echo shar: \"'bwbasic-2.10/INSTALL'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/INSTALL'
- fi
- if test -f 'bwbasic-2.10/bwbasic.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/bwbasic.doc'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/bwbasic.doc'\" \(58924 characters\)
- sed "s/^X//" >'bwbasic-2.10/bwbasic.doc' <<'END_OF_FILE'
- X
- X
- X
- X
- X Bywater BASIC Interpreter/Shell, version 2.10
- X ---------------------------------------------
- X
- X Copyright (c) 1993, Ted A. Campbell
- X for bwBASIC version 2.10, 11 October 1993
- X
- X
- XCONTENTS:
- X
- X 1. DESCRIPTION
- X 2. TERMS OF USE
- X 3. QUICK REFERENCE LIST OF COMMANDS AND FUNCTIONS
- X 4. GENERAL NOTES ON USAGE
- X 5. EXPANDED REFERENCE FOR COMMANDS AND FUNCTIONS
- X 6. PREDEFINED VARIABLES
- X 7. UNIMPLEMENTED COMMANDS AND FUNCTIONS
- X and AGENDA FOR DEVELOPMENT
- X 8. THE STORY OF BYWATER BASIC
- X 9. COMMUNICATIONS
- X
- X The author wishes to express his thanks to Mr. David MacKenzie,
- X who assisted in the development Unix installation and configuration
- X for this version.
- X
- X
- X1. DESCRIPTION
- X
- X The Bywater BASIC Interpreter (bwBASIC) implements a large
- X superset of the ANSI Standard for Minimal BASIC (X3.60-1978)
- X and a significant subset of the ANSI Standard for Full BASIC
- X (X3.113-1987) in C. It also offers shell programming facilities
- X as an extension of BASIC. bwBASIC seeks to be as portable
- X as possible.
- X
- X bwBASIC can be configured to emulate features, commands, and
- X functions available on different types of BASIC interpreters;
- X see the file INSTALL for further installation information.
- X
- X The interpreter is fairly slow. Whenever faced with a choice
- X between conceptual clarity and speed, I have consistently chosen
- X the former. The interpreter is the simplest design available,
- X and utilizes no system of intermediate code, which would speed
- X up considerably its operation. As it is, each line is interpreted
- X afresh as the interpreter comes to it.
- X
- X bwBASIC implements one feature not available in previous BASIC
- X interpreters: a shell command can be entered interactively at the
- X bwBASIC prompt, and the interpreter will execute it under a
- X command shell. For instance, the command "dir *.bas" can be
- X entered in bwBASIC (under DOS, or "ls -l *.bas" under UNIX) and
- X it will be executed as from the operating system command line.
- X Shell commands can also be given on numbered lines in a bwBASIC
- X program, so that bwBASIC can be used as a shell programming
- X language. bwBASIC's implementation of the RMDIR, CHDIR, MKDIR,
- X NAME, KILL, ENVIRON, and ENVIRON$() commands and functions
- X offer further shell-processing capabilities.
- X
- X
- X2. TERMS OF USE:
- X
- X This version of Bywater BASIC is released under the terms of the
- X GNU General Public License (GPL), which is distributed with this
- X software in the file "COPYING". The GPL specifies the terms
- X under which users may copy and use the software in this distribution.
- X
- X A separate license is available for commercial distribution,
- X for information on which you should contact the author.
- X
- X
- X3. QUICK REFERENCE LIST OF COMMANDS AND FUNCTIONS
- X
- X Be aware that many of these commands and functions will not be
- X available unless you have set certain flags in the header files
- X (see the expanded reference section below for dependencies).
- X
- X ABS( number )
- X ASC( string$ )
- X ATN( number )
- X CALL subroutine-name
- X CASE ELSE | IF partial-expression | constant
- X CHAIN [MERGE] file-name [, line-number] [, ALL]
- X CHDIR pathname
- X CHR$( number )
- X CINT( number )
- X CLEAR
- X CLOSE [[#]file-number]...
- X CLS
- X COMMON variable [, variable...]
- X COS( number )
- X CSNG( number )
- X CVD( string$ )
- X CVI( string$ )
- X CVS( string$ )
- X DATA constant[,constant]...
- X DATE$
- X DEF FNname(arg...)] = expression
- X DEFDBL letter[-letter](, letter[-letter])...
- X DEFINT letter[-letter](, letter[-letter])...
- X DEFSNG letter[-letter](, letter[-letter])...
- X DEFSTR letter[-letter](, letter[-letter])...
- X DELETE line[-line]
- X DIM variable(elements...)[variable(elements...)]...
- X DO NUM|UNNUM
- X DO [WHILE expression]
- X EDIT
- X ELSE
- X ELSEIF
- X END IF | FUNCTION | SELECT | SUB
- X ENVIRON variable-string = string
- X ENVIRON$( variable-string )
- X EOF( device-number )
- X ERASE variable[, variable]...
- X ERL
- X ERR
- X ERROR number
- X EXP( number )
- X FIELD [#] device-number, number AS string-variable [, number AS string-variable...]
- X FILES filespec$
- X FUNCTION
- X FOR counter = start TO finish [STEP increment]
- X GET [#] device-number [, record-number]
- X GOSUB line | label
- X GOTO line | label
- X HEX$( number )
- X IF expression THEN [statement [ELSE statement]]
- X INKEY$
- X INPUT [# device-number]|[;]["prompt string";]list of variables
- X INSTR( [start-position,] string-searched$, string-pattern$ )
- X INT( number )
- X KILL file-name
- X LEFT$( string$, number-of-spaces )
- X LEN( string$ )
- X LET variable = expression
- X LINE INPUT [[#] device-number,]["prompt string";] string-variable$
- X LIST line[-line]
- X LOAD file-name
- X LOC( device-number )
- X LOCATE line, column
- X LOF( device-number )
- X LOG( number )
- X LOOP [UNTIL expression]
- X LSET string-variable$ = expression
- X MERGE file-name
- X MID$( string$, start-position-in-string[, number-of-spaces ] )
- X MKD$( number )
- X MKDIR pathname
- X MKI$( number )
- X MKS$( number )
- X NAME old-file-name AS new-file-name
- X NEW
- X NEXT [counter]
- X OCT$( number )
- X ON variable GOTO|GOSUB line[,line,line,...]
- X ON ERROR GOSUB line
- X OPEN "O"|"I"|"R", [#]device-number, file-name [,record length]
- X file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length]
- X OPTION BASE number
- X POS
- X PRINT [# device-number,][USING format-string$;] expressions...
- X PUT [#] device-number [, record-number]
- X QUIT
- X RANDOMIZE number
- X READ variable[, variable]...
- X REM string
- X RESTORE line
- X RETURN
- X RIGHT$( string$, number-of-spaces )
- X RMDIR pathname
- X RND( number )
- X RSET string-variable$ = expression
- X RUN [line][file-name]
- X SAVE file-name
- X SELECT CASE expression
- X SGN( number )
- X SIN( number )
- X SPACE$( number )
- X SPC( number )
- X SQR( number )
- X STOP
- X STR$( number )
- X STRING$( number, ascii-value|string$ )
- X SUB subroutine-name
- X SWAP variable, variable
- X SYSTEM
- X TAB( number )
- X TAN( number )
- X TIME$
- X TIMER
- X TROFF
- X TRON
- X VAL( string$ )
- X WEND
- X WHILE expression
- X WIDTH [# device-number,] number
- X WRITE [# device-number,] element [, element ]....
- X
- X
- X4. GENERAL NOTES ON USAGE:
- X
- X 4.a. Interactive Environment
- X
- X An interactive environment is provided if the flag INTERACTIVE
- X is defined as TRUE in bwbasic.h, so that a line with a
- X line number can be entered at the bwBASIC prompt and it will be
- X added to the program in memory.
- X
- X Line numbers are not strictly required, but are useful if the
- X interactive enviroment is used for programming. For longer
- X program entry one might prefer to use an ASCII text editor, and
- X in this case lines can be entered without numbers. One can use
- X DO NUM and DO UNNUM to number or unnumber lines. See also the
- X documentation below for the pseudo-command EDIT.
- X
- X 4.b. Naming Conventions
- X
- X Command names and function names are not case sensitive,
- X so that "Run" and "RUN" and "run" are equivalent and "abs()"
- X and "ABS()" and "Abs()" are equivalent. HOWEVER, variable
- X names ARE case sensitive in bwbASIC, so that "d$" and "D$"
- X are different variables. This differs from some BASIC
- X implementations where variable names are not case sensitive.
- X
- X Variable names can use any alphabetic characters, the period
- X and underscore characters and decimal digits (but not in the
- X first position). They can be terminated with '#' or '!' to
- X allow Microsoft-type names, even though the precision is
- X irrelevant to bwBASIC.
- X
- X 4.c. Numerical Constants
- X
- X Numerical constants may begin with a digit 0-9 (decimal), with
- X the "&H" or "&h" (hexadecimal) or the "&o" or "&O" (octal).
- X Decimal numbers may terminated with 'E', 'e', 'D', or 'd'
- X followed by an exponent number to denote exponential notation.
- X Decimal constants may also be terminated by the '#' or '!'
- X to comply with Microsoft-style precision terminators, although
- X the precision specified will be irrelevant to bwBASIC.
- X
- X 4.d. Command-Line Execution
- X
- X A filename can be specified on the command line and will be
- X LOADed and RUN immediately, so that the command line
- X
- X bwbasic prog.bas
- X
- X will load and execute "prog.bas".
- X
- X 4.e. Program Storage
- X
- X All programs are stored as ASCII text files.
- X
- X 4.f. TRUE and FALSE
- X
- X TRUE is defined as -1 and FALSE is defined as 0 in the default
- X distribution of bwBASIC. These definitions can be changed by
- X those compiling bwBASIC (see file BWBASIC.H).
- X
- X 4.g. Assignments
- X
- X Assignment must be made to variables. This differs from some
- X implementations of BASIC where assignment can be made to a
- X function. Implication: "INSTR( 3, x$, y$ ) = z$" will not
- X work under bwBASIC.
- X
- X 4.h. Operators and Precedence
- X
- X bwBASIC recognizes the following operators, with their level
- X of precedence given (1 = highest):
- X
- X ^ 1 exponentiation
- X * 2 multiplication
- X / 2 division
- X \ 3 integer division
- X + 5 addition
- X - 5 subtraction
- X = 6 equality or assignment
- X MOD 4 modulus (remainder) arithmetic
- X <> 7 inequality
- X < 8 less than
- X > 9 greater than
- X <= 10 less than or equal to
- X =< 10 less than or equal to
- X >= 11 greater than or equal to
- X => 11 greater than or equal to
- X NOT 12 negation
- X AND 13 conjunction
- X OR 14 disjunction
- X XOR 15 exclusive or
- X IMP 16 implication
- X EQV 17 equivalence
- X
- X 4.h. Numerical Precision (NOT)
- X
- X bwBASIC utilizes numbers with only one level of precision. If
- X the flag NUMBER_DOUBLE is defined as TRUE in bwbasic.h, the
- X precision implemented will be that of the C "double" data type;
- X otherwise (default) the precision will be that of the C "float"
- X type. At a number of points there are commands (or pseudo-
- X commands) that seem to recognize Microsoft-style precision
- X distinctions, but for the most part these are just work-around
- X aliases to allow Microsoft-style programs to be run.
- X
- X
- X5. EXPANDED REFERENCE FOR COMMANDS AND FUNCTIONS
- X
- X The "Dependencies" listed in the folowing reference materials
- X refers to flags that must be set to TRUE in bwbasic.h for the
- X associated command or function to be implemented. These flags
- X are as follows:
- X
- X (core) Commands and Functions in any implementation of
- X bwBASIC; these are the ANSI Minimal BASIC core
- X
- X INTERACTIVE Commands supporting the interactive programming
- X environment
- X
- X COMMON_CMDS Commands beyond ANSI Minimal BASIC which are common
- X to Full ANSI BASIC and Microsoft BASICs
- X
- X COMMON_FUNCS Functions beyond the ANSI Mimimal BASIC core, but
- X common to both ANSI Full BASIC and Microsoft-style
- X BASIC varieties
- X
- X UNIX_CMDS Commands which require Unix-style directory and
- X environment routines not specified in C
- X
- X STRUCT_CMDS Commands related to structured programming; all
- X of these are part of the Full ANSI BASIC standard
- X
- X ANSI_FUNCS Functions unique to ANSI Full BASIC
- X
- X MS_CMDS Commands unique to Microsoft BASICs
- X
- X MS_FUNCS Functions unique to Microsoft BASICs
- X
- X
- X ------------------------------------------
- X
- X Function: ABS( number )
- X
- X Description: ABS returns the absolute value of the argument 'number'.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: ASC( string$ )
- X
- X Description: ASC returns the ASCII code for the first letter in
- X the argument string$.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: ATN( number )
- X
- X Description: ATN returns the arctangent value of the argument 'number'
- X in radians.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: CALL subroutine-name
- X
- X Description: CALL calls a named subroutine (see SUB and END SUB).
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: CASE ELSE | IF partial-expression | constant
- X
- X Description: CASE introduces an element of a SELECT CASE statement
- X (see SELECT CASE). CASE IF introduces a conditional
- X SELECT CASE element, and CASE ELSE introduces a
- X default SELECT CASE element.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: CHAIN [MERGE] file-name [, line-number] [, ALL]
- X
- X Description: CHAIN passes control to another BASIC program.
- X Variables declared COMMON (q.v.) will be passed
- X to the new program.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: CHDIR pathname$
- X
- X Description: CHDIR changes the current directory to that indicated
- X by the argument pathname$.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Function: CHR$( number )
- X
- X Description: CHR$ returns a one-character string with the character
- X corresponding to the ASCII code indicated by argument
- X 'number'.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Function: CINT( number )
- X
- X Description: CINT returns the truncated integer for the argument
- X 'number'.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: CLEAR
- X
- X Description: CLEAR sets all numerical variables to 0, and all
- X string variables to null.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: CLOSE [[#]file-number]...
- X
- X Description: CLOSE closes the file indicated by file-number
- X (see OPEN).
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: CLS
- X
- X Description: CLS clears the display screen (IBM and compatibles
- X only as of version 2.10).
- X
- X Dependencies: IMP_IQC and IMP_CMDLOC
- X
- X ------------------------------------------
- X
- X Command: CMDS
- X
- X Description: CMDS is a debugging command that prints a list
- X of all implemented bwBASIC commands.
- X
- X Dependencies: DEBUG
- X
- X ------------------------------------------
- X
- X Command: COMMON variable [, variable...]
- X
- X Description: COMMON designates variables to be passed to a CHAINed
- X program (see CHAIN).
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Function: COS( number )
- X
- X Description: COS returns the cosine of the argument 'number'
- X in radians.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: CSNG( number )
- X
- X Description: CSNG is a pseudo-function that has no effect under
- X bwBASIC. It replicates a Microsoft-type command
- X that would convert the 'number' to single-precision.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: CVD( string$ )
- X
- X Description: CVD converts the argument string$ into a bwBASIC
- X number (precision is irrelevant in bwBASIC since
- X bwBASIC numbers have only one precision).
- X
- X Implenentation-Specific Notes:
- X
- X CVD(), CVI(), CVS(), MKI$(), MKD$(), MKS$(): These functions
- X are implemented, but are dependent on a) the sizes for integer,
- X float, and double values on particular systems, and b) how
- X particular versions of C store these numerical values. The
- X implication is that data files created using these functions
- X on a DOS-based microcomputer may not be translated correctly
- X by bwBASIC running on a Unix-based computer. Similarly, data
- X files created by bwBASIC compiled by one version of C may not be
- X readable by bwBASIC compiled by another version of C (even under
- X the same operating system). So be careful with these.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: CVI( string$ )
- X
- X Description: CVI converts the argument string$ into a bwBASIC
- X number (precision is irrelevant in bwBASIC since
- X bwBASIC numbers have only one precision; see also
- X the note on CVD).
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: CVS( string$ )
- X
- X Description: CVI converts the argument string$ into a bwBASIC
- X number (precision is irrelevant in bwBASIC since
- X bwBASIC numbers have only one precision; see also
- X the note on CVD).
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: DATA constant[,constant]...
- X
- X Description: DATA stores numerical and string constants to be
- X accessed by READ (q.v.).
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: DATE$
- X
- X Description: DATE$ returns the current date based on the computer's
- X internal clock as a string in the form "YYYY-MM-DD".
- X As implemented under bwBASIC, DATE$ cannot be used for
- X assignment (i.e., to set the system date).
- X
- X Note: bwBASIC presently (v2.10) does not allow assignment
- X to a function.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Command: DEF FNname(arg...)] = expression
- X
- X Description: DEF defines a user-written function. This function
- X corresponds to Microsoft-type implementation, although
- X in bwBASIC DEF is a working equivalent of FUNCTION.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: DEFDBL letter[-letter](, letter[-letter])...
- X
- X Description: DEFDBL declares variables with single-letter names
- X as numerical variables (precision is irrelevant in
- X bwBASIC).
- X
- X Dependencies: MS_CMDS
- X
- X ------------------------------------------
- X
- X Command: DEFINT letter[-letter](, letter[-letter])...
- X
- X Description: DEFINT declares variables with single-letter names
- X as numerical variables (precision is irrelevant in
- X bwBASIC).
- X
- X Dependencies: MS_CMDS
- X
- X ------------------------------------------
- X
- X Command: DEFSNG letter[-letter](, letter[-letter])...
- X
- X Description: DEFSNG declares variables with single-letter names
- X as numerical variables (precision is irrelevant in
- X bwBASIC).
- X
- X Dependencies: MS_CMDS
- X
- X ------------------------------------------
- X
- X Command: DEFSTR letter[-letter](, letter[-letter])...
- X
- X Description: DEFSTR declares variables with single-letter names
- X as string variables.
- X
- X Dependencies: MS_CMDS
- X
- X ------------------------------------------
- X
- X Command: DELETE line[-line]
- X
- X Description: DELETE deletes program lines indicated by the
- X argument(s). If you want to use DELETE for non-
- X numbered programs, first use DO NUM, then DELETE,
- X then DO UNNUM.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: DIM variable(elements...)[variable(elements...)]...
- X
- X Description: DIM specifies variables that have more than one
- X element in a single dimension, i.e., arrayed
- X variables.
- X
- X Note: As implemented under bwBASIC, DIM accepts only
- X parentheses as delimiters for variable fields.
- X (Some BASICs allow the use of square brackets.)
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: DO NUM|UNNUM
- X
- X Description: DO NUM numbers all lines in a program. The first
- X line is given the number 10, and subsequent lines
- X are numbered consecutively in multiples of 10. DO
- X UNNUM removes all line numbers from a program.
- X NOTE that these functions do nothing to line
- X numbers, e.g., following a GOSUB or GOTO statement;
- X these commands cannot be used as a replacement for
- X RENUM (available in some systems, but not bwBASIC).
- X With these commands, however, one can develop
- X unnumbered programs by entering new lines with numbers,
- X then running DO UNNUM to remove the line numbers.
- X Together with LOAD and SAVE (q.v.) one can use
- X bwBASIC as a primitive text editor.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: DO [WHILE expression]
- X
- X Description: DO implements a number of forms of program loops.
- X DO...LOOP simply loops; the only way out is by
- X EXIT; DO WHILE...LOOP loops while "expression" is
- X true (this is equivalent to the older WHILE-WEND
- X loop, also implemented in bwBASIC); DO...LOOP UNTIL
- X loops until the expression following UNTIL is true.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: EDIT
- X
- X Description: EDIT is a pseudo-command which calls the text editor
- X specified in the variable BWB.EDITOR$ to edit the
- X program in memory. After the call to the text editor,
- X the (edited) prgram is reloaded into memory. The user
- X normally must specific a valid path and filename in
- X BWB.EDITOR$ before this command will be useful.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: ELSE
- X
- X Description: ELSE introduces a default condition in a multi-line IF
- X statement.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: ELSEIF
- X
- X Description: ELSEIF introduces a secondary condition in a multi-
- X line IF statement.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: END IF | FUNCTION | SELECT | SUB
- X
- X Description: END IF ends a multi-line IF statement. END FUNCTION
- X ends a multi-line function definition. END SELECT
- X ends a SELECT CASE statement. END SUB ends a multi-
- X line subroutine definition.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: ENVIRON variable-string$ = string$
- X
- X Description: ENVIRON sets the environment variable identified by
- X variable-string$ to string$.
- X
- X It might be noted that this differs from the implementation
- X of ENVIRON in some versions of BASIC, but bwBASIC's ENVIRON
- X allows BASIC variables to be used on either side of the equals
- X sign. Note that the function ENVIRON$() is different from the
- X command, and be aware of the fact that in some operating systems
- X an environment variable set within a program will not be passed
- X to its parent shell.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Function: ENVIRON$( variable-string$ )
- X
- X Description: ENVIRON$ returns the environment variable associated with
- X the name variable-string$.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: EOF( device-number )
- X
- X Description: EOF returns TRUE (-1) if the device associated with
- X device-number is at the end-of-file, otherwise it
- X returns FALSE (0).
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: ERASE variable[, variable]...
- X
- X Description: ERASE eliminates arrayed variables from a program.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Function: ERL
- X
- X Description: ERL returns the line number of the most recent error.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: ERR
- X
- X Description: ERR returns the error number of the most recent error.
- X
- X Note that if PROG_ERRORS has been defined when bwBASIC is
- X compiled, the ERR variable will not be set correctly upon
- X errors. It only works when standard error messages are used.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: ERROR number
- X
- X Description: ERROR simulates an error, i.e., displays the message
- X appropriate for that error. This command is helpful
- X in writing ON ERROR GOSUB routines that can identify
- X a few errors for special treatment and then ERROR ERR
- X (i.e., default handling) for all others.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: EXIT [FOR]
- X
- X Description: EXIT by itself exits from a DO...LOOP loop;
- X EXIT FOR exits from a FOR...NEXT loop.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Function: EXP( number )
- X
- X Description: EXP returns the exponential value of 'number'.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: FIELD [#] device-number, number AS string-variable$ [, number AS string-variable$...]
- X
- X Description: FIELD allocates space in a random file buffer for device
- X indicated by device-number, allocating 'number' bytes
- X and assigning the bytes at this position to the variable
- X string-variable$.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: FILES filespec$
- X
- X Description: FILES is a pseudocommand that invokes the directory program
- X specified in the variable BWB.FILES$ with the argument
- X filespec$. Normally, the user must set this variable
- X before FILES can be used. E.g., for PC-type computers,
- X
- X BWB.FILES$ = "DIR"
- X
- X will work, for Unix machines,
- X
- X BWB.FILES$ = "ls -l"
- X
- X etc.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: FNCS
- X
- X Description: CMDS is a debugging command that prints a list
- X of all pre-defined bwBASIC functions.
- X
- X Dependencies: DEBUG
- X
- X ------------------------------------------
- X
- X Command: FUNCTION
- X
- X Description: FUNCTION introduces a function definition, normally
- X ending with END FUNCTION. In bwBASIC, FUNCTION and
- X DEF are qorking equivalents, so either can be used
- X with single-line function definitions or with multi-
- X line definitions terminated by END FUNCTION.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: FOR counter = start TO finish [STEP increment]
- X
- X Description: FOR initiates a FOR-NEXT loop with the variable
- X 'counter' initially set to 'start' and incrementing
- X in 'increment' steps (default is 1) until 'counter'
- X equals 'finish'.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: GET [#] device-number [, record-number]
- X
- X Description: GET reads the next reacord from a random-access file
- X or device into the buffer associated with that file.
- X If record-number is specified, the GET command reads the
- X specified record.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: GOSUB line | label
- X
- X Description: GOSUB initiates a subroutine call to the line (or label)
- X specified. The subroutine must end with RETURN.
- X
- X Dependencies: (core), but STRUCT_CMDS for labels
- X
- X ------------------------------------------
- X
- X Command: GOTO line | label
- X
- X Description: GOTO branches program execution to the specified line
- X (or label).
- X
- X Dependencies: (core), but STRUCT_CMDS for labels
- X
- X ------------------------------------------
- X
- X Function: HEX$( number )
- X
- X Description: HEX$ returns a string giving the hexadecimal (base 16)
- X value for the 'number'.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: IF expression THEN [statement [ELSE statement]]
- X
- X Description: IF evaluates 'expression' and performs the THEN
- X statement if it is true or (optionally) the
- X ELSE statement if it is FALSE. If STRUCT_CMDS
- X is set to TRUE, bwBASIC allows multi-line IF
- X statements with ELSE and ELSEIF cases, ending
- X with END IF.
- X
- X Dependencies: (core), STRUCT_CMDS for multi-line IF statements
- X
- X ------------------------------------------
- X
- X Function: INKEY$
- X
- X Description: INKEY$ reads the status of the keyboard, and a single
- X keypress, if available. If a keypress is not available,
- X then INKEY$ immediately returns a null string ("").
- X Currently (v2.10) implemented in bwx_iqc.c only.
- X
- X Dependencies: IMP_IQC and IMP_CMDLOC
- X
- X ------------------------------------------
- X
- X Command: INPUT [# device-number]|[;]["prompt string";]list of variables
- X
- X Description: INPUT allows input from the terminal or a device
- X specified by device-number. If terminal, the "prompt
- X string" is output, and input is assigned to the
- X appropriate variables specified.
- X
- X bwBASIC does not support the optional feature of INPUT
- X that suppresses the carriage-return and line-feed at the end
- X of the input. This is because C alone does not provide for any
- X means of input other than CR-LF-terminated strings.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: INSTR( [start-position,] string-searched$, string-pattern$ )
- X
- X Description: INSTR returns the position at which string-pattern$
- X occurs in string-searched$, beginning at start-position.
- X As implemented in bwBASIC, INSTR cannot be used for
- X assignments.
- X
- X Note: bwBASIC presently (v2.10) does not allow assignment
- X to a function.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: INT( number )
- X
- X Description: INT returns the largest integer less than or equal to
- X the argument 'number'. NOTE that this is not a "truncated"
- X integer function, for which see CINT.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: KILL file-name$
- X
- X Description: KILL deletes the file specified by file-name$.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Function: LEFT$( string$, number-of-spaces )
- X
- X Description: LEFT$ returns a substring a string$ with number-of-spaces
- X from the left (beginning) of the string). As implemented
- X under bwBASIC, it cannot be used for assignment.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: LEN( string$ )
- X
- X Description: LEN returns the length in bytes of string$.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Command: LET variable = expression
- X
- X Description: LET assigns the value of 'expression' to the variable.
- X As currently implemented, bwBASIC supports implied LET
- X statements (e.g., "X = 4.5678" at the beginning of
- X a line or line segment, but does not support assignment
- X to multiple variables (e.g., "x, y, z = 3.141596").
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: LINE INPUT [[#] device-number,]["prompt string";] string-variable$
- X
- X Description: LINE INPUT reads entire line from the keyboard or a file
- X or device into string-variable$. If input is from the
- X keyboard (stdin), then "prompt string" will be printed
- X first. Unlike INPUT, LINE INPUT reads a whole line,
- X not stopping for comma-delimited data items.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: LIST line[-line]
- X
- X Description: LIST lists program lines as specified in its argument.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: LOAD file-name
- X
- X Description: LOAD loads an ASCII BASIC program into memory.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Function: LOC( device-number )
- X
- X Description: LOC returns the next record that GET or PUT statements
- X will use.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: LOCATE line, column
- X
- X Description: LOCATE addresses trhe curor to a specified line and
- X column. Currently (v2.10) implemented in bwx_iqc.c only.
- X
- X Dependencies: IMP_IQC and IMP_CMDLOC
- X
- X ------------------------------------------
- X
- X Function: LOF( device-number )
- X
- X Description: LOF returns the length of a file (specified by device-number)
- X in bytes.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: LOG( number )
- X
- X Description: LOG returns the natural logarithm of the argument 'number'.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: LOOP [UNTIL expression]
- X
- X Description: LOOP terminates a program loop: see DO.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: LSET string-variable$ = expression
- X
- X Description: LSET transfers data from 'expression' to the left-hand
- X side of a string variable or random access buffer field.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: MERGE file-name
- X
- X Description: MERGE adds program lines from 'file-name' to the program
- X in memory. Unlike LOAD, it does not clear the program
- X currently in memory.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Function: MID$( string$, start-position-in-string[, number-of-spaces ] )
- X
- X Description: MID$ returns a substring of string$ beginning at
- X start-position-in-string and continuing for
- X number-of-spaces bytes.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: MKDIR pathname$
- X
- X Description: MKDIR creates a new directory path as specified by
- X pathname$.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Function: MKD$( number )
- X
- X Description: MKD$, MKI$, and MKS$ are all equivalent in bwBASIC.
- X They convert the numerical value 'number' into a string
- X which can be stored in a more compressed form in a file
- X (especially for random file access). Since bwBASIC does
- X not recognize differences in precision, these commands
- X are effectively equivalent.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: MKI$( number )
- X
- X Description: Equivalent to MKD$ (q.v.)
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: MKS$( number )
- X
- X Description: Equivalent to MKD$ (q.v.).
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: NAME old-file-name AS new-file-name
- X
- X Description: NAME renames an existing file (old-file-name) as
- X new-file-name.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Command: NEW
- X
- X Description: NEW deletes the program in memory and clears all
- X variables.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: NEXT [counter-variable]
- X
- X Description: NEXT comes at the end of a FOR-NEXT loop; see FOR.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: OCT$( number )
- X
- X Description: OCT$ returns a string giving the octal (base 8)
- X representation of 'number'.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: ON variable GOTO|GOSUB line[,line,line,...]
- X
- X Description: ON either branches (GOTO) or calls a subroutine
- X (GOSUB) based on the rounded value of variable;
- X if it is 1, the first line is called, if 2, the second
- X line is called, etc.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: ON ERROR GOSUB line|label
- X
- X Description: ON ERROR sets up an error handling subroutine. See
- X also ERROR.
- X
- X Dependencies: COMMON_CMDS, STRUCT_CMDS for labels
- X
- X ------------------------------------------
- X
- X Command: OPEN "O"|"I"|"R", [#]device-number, file-name [,record length]
- X file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length]
- X
- X Description: OPEN allocates random access memory for access to a disk
- X file or other device. Note that two quite different forms
- X of the OPEN statement are supported. In the first form,
- X "O" (note that these letters must be encased in quotation
- X marks) denotes sequential output, "I" denotes sequential
- X input, and "R" denotes random-access input and output.
- X Once OPEN, any number of operations can be performed
- X on a device (see WRITE #, INPUT #, PRINT #, etc.).
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: OPTION BASE number
- X
- X Description: OPTION BASE sets the lowest value for array subscripts,
- X either 0 or 1.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: POS
- X
- X Description: POS returns the current cursor position in the line.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Command: PRINT [# device-number,][USING format-string$;] expressions...
- X
- X Description: PRINT outputs text to the screen or to a file or device
- X specified by device-number. In the current implementation
- X of bwBASIC, expressions to be printed must be separated by
- X the comma (tabbed output), the semicolon (immediate
- X sequential output) or the plus sign (immediate sequential
- X output by string concatenation). Expressions separated
- X by blanks or tabs are not supported. If USING is specified,
- X a number of formatting marks may appear in the format
- X string:
- X
- X ! prints the first character of a string
- X
- X \\ prints 2+x characters of a string, where x =
- X the number of spaces between the backslashes
- X
- X & variable-length string field
- X
- X # represents a single digit in output format for
- X a number
- X
- X . decimal point in a number
- X
- X + sign of a number (will output + or -)
- X
- X - trailing minus after a number
- X
- X ** fill leading spaces with asterisks
- X
- X $$ output dollar sign in front of a number
- X
- X ^^ output number in exponential format
- X
- X _ output next character literally
- X
- X As currently implemented, the exponential format
- X will be that used by the C compiler.
- X
- X Dependencies: (core), COMMON_FUNCS for USING
- X
- X ------------------------------------------
- X
- X Command: PUT [#] device-number [, record-number]
- X
- X Description: PUT outputs the next available record or the record
- X specified by record-number to the file or device
- X denoted by device-number.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: QUIT
- X
- X Description: QUIT is a synonym for SYSTEM; with INTERACTIVE
- X environment, it exits the program to the
- X operating system (or the calling program).
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: RANDOMIZE number
- X
- X Description: RANDOMIZE seeds the random number generator (see RND).
- X Under bwBASIC, the TIMER function (q.v.) can be used
- X to supply a 'number' seed for the random number
- X generator.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: READ variable[, variable]...
- X
- X Description: READ reads values from DATA statements and assigns these
- X values to the named variables. Variable types in a READ
- X statement must match the data types in DATA statements
- X as they are occurred. See also DATA and RESTORE.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: REM string
- X
- X Description: REM allows remarks to be included in a program. As
- X currently implemented, the entire line following
- X REM is ignored by the interpreter (thus, even if
- X MULTISEG_LINES is set, a REM line will not be able
- X to find a segment delimiter (":") followed by another
- X line segment with command. bwBASIC does not currently
- X implement the Microsoft-style use of the single quotation
- X mark to denote remarks.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: RESTORE line
- X
- X Description: RESTORE resets the line and position counters for DATA
- X and READ statements to the top of the program file or
- X to the beginning of the specified line. (Currently this
- X must be a line number.)
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: RETURN
- X
- X Description: RETURN concludes a subroutine called by GOSUB.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: RIGHT$( string$, number-of-spaces )
- X
- X Description: RIGHT$ returns a substring a string$ with number-of-spaces
- X from the right (end) of the string). As implemented
- X under bwBASIC, it cannot be used for assignment.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: RMDIR pathname
- X
- X Description: RMDIR deletes the directory path indicated by pathname.
- X
- X Dependencies: UNIX_CMDS
- X
- X ------------------------------------------
- X
- X Function: RND( number )
- X
- X Description: RND returns a pseudo-random number. The 'number' value
- X is ignored by bwBASIC if supplied. The RANDOMIZE
- X command (q.v.) reseeds the random-number generator.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: RSET string-variable$ = expression
- X
- X Description: RSET transfers data from 'expression' to the right-hand
- X side of a string variable or random access buffer field.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: RUN [line][file-name$]
- X
- X Description: RUN executes the program in memory. If a file-name$ is
- X supplied, then the specified file is loaded into memory
- X and executed. If a line number is supplied, then execution
- X begins at that line.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: SAVE file-name$
- X
- X Description: SAVE saves the program in memory to file-name$. bwBASIC
- X only saves files in ASCII format.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Command: SELECT CASE expression
- X
- X Description: SELECT CASE introduces a multi-line conditional selection
- X statement. The expression given as the argument to SELECT
- X CASE will be evaluated by CASE statements following. The
- X SELECT CASE statement conclludes with an END SELECT
- X statement.
- X
- X As currently implemented, CASE statements may be followed
- X by string values, but in this case only simple comparisons
- X (equals, not equals) can be performed.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Function: SGN( number )
- X
- X Description: SGN returns the sign of the argument 'number', +1
- X for positive numbers, 0 for 0, and -1 for negative numbers.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: SIN( number )
- X
- X Description: SIN returns the sine of the argument 'number'
- X in radians.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: SPACE$( number )
- X
- X Description: SPACE$ returns a string of blank spaces 'number'
- X bytes long.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: SPC( number )
- X
- X Description: SPC returns a string of blank spaces 'number'
- X bytes long.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Function: SQR( number )
- X
- X Description: SQR returns the square root of the argument 'number'.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Command: STOP
- X
- X Description: STOP interrupts program execution. As implemented under
- X bwBASIC, STOP issues a SIGINT signal.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: STR$( number )
- X
- X Description: STR$ returns a string giving the decimal (base 10)
- X representation of the argument 'number'.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Function: STRING$( number, ascii-value|string$ )
- X
- X Description: STRING$ returns a string 'number' bytes long consisting
- X of either the first character of string$ or the character
- X answering to the ASCII value ascii-value.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: SUB subroutine-name
- X
- X Description: SUB introduces a named, multi-line subroutine. The
- X subroutine is called by a CALL statement, and concludes
- X with an END SUB statement.
- X
- X Dependencies: STRUCT_CMDS
- X
- X ------------------------------------------
- X
- X Command: SWAP variable, variable
- X
- X Description: SWAP swaps the values of two variables. The two variables
- X must be of the same type (either numerical or string).
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: SYSTEM
- X
- X Description: SYSTEM exits from bwBASIC to the calling program or
- X (more usually) the operating system.
- X
- X Dependencies: INTERACTIVE
- X
- X ------------------------------------------
- X
- X Function: TAB( number )
- X
- X Description: TAB outputs spaces until the column indicated by
- X 'number' has been reached.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: TAN( number )
- X
- X Description: TAN returns the tangent of the argument 'number'
- X in radians.
- X
- X Dependencies: (core)
- X
- X ------------------------------------------
- X
- X Function: TIME$
- X
- X Description: TIME$ returns the current time based on the computer's
- X internal clock as a string in the form "HH-MM-SS".
- X As implemented under bwBASIC, TIME$ cannot be used for
- X assignment (i.e., to set the system time).
- X
- X Note: bwBASIC presently (v2.10) does not allow assignment
- X to a function.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Function: TIMER
- X
- X Description: TIMER returns the time in the system clock in seconds
- X elapsed since midnight.
- X
- X Dependencies: MS_FUNCS
- X
- X ------------------------------------------
- X
- X Command: TROFF
- X
- X Description: TROFF turns of the trace facility; see TRON.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: TRON
- X
- X Description: TRON turns on the trace facility. This facility will print
- X each line number in square brackets as the program is
- X executed. This is useful in debugging programs with
- X line numbers. To debug an unnumbered program with
- X TRON, call DO NUM first, but remember to call DO UNNUM
- X before you save the program later.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Function: VAL( string$ )
- X
- X Description: VAL returns the numerical value of the string$.
- X
- X Dependencies: COMMON_FUNCS
- X
- X ------------------------------------------
- X
- X Command: VARS
- X
- X Description: VARS is a debugging command which prints a list of
- X all variables defined which have global scope.
- X
- X Dependencies: DEBUG
- X
- X ------------------------------------------
- X
- X Command: WEND
- X
- X Description: WEND concludes a WHILE-WEND loop; see WHILE.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: WHILE expression
- X
- X Description: WHILE initiates a WHILE-WEND loop. The loop ends with
- X WEND, and execution reiterates through the loop as
- X long as the 'expression' is TRUE (-1).
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: WIDTH [# device-number,] number
- X
- X Description: WIDTH sets screen or device output to 'number'
- X columns. device-number specifies the device
- X or file for oputput.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X Command: WRITE [# device-number,] element [, element ]....
- X
- X Description: WRITE outputs variables to the screen or to a file
- X or device specified by device-number. Commas
- X are inserted between expressions output, and strings
- X are enclosed in quotation marks.
- X
- X Dependencies: COMMON_CMDS
- X
- X ------------------------------------------
- X
- X
- X6. PREDEFINED VARIABLES
- X
- X BWB.EDITOR$
- X BWB.FILES$
- X BWB.PROMPT$
- X BWB.IMPLEMENTATION$
- X
- X The commands EDIT and FILES are pseudo-commands that launch
- X shell programs named in the variables BWB.EDITOR$ and BWB.FILES$,
- X respectively. The default values for these variables can
- X be changed in bwbasic.h (DEF_EDITOR and DEF_FILES), or they
- X can be changed on the fly by the user. An idea might be to
- X initialize these variables in "profile.bas" for specific
- X implementations; for instance, BWB.FILES$ might be defined as
- X "ls -l" on Unix systems or "dir" on DOS systems.
- X
- X The preset variable BWB.PROMPT$ can be used to set the prompt
- X string for bwBASIC. Again, it is suggested that a user-
- X selected promptcan be set up in a "profile.bas" to be
- X initialized each time bwBASIC starts. Note that special
- X characters can be added to the prompt string, e.g.,
- X
- X BWB.PROMPT$ = "Ok"+CHR$(10)
- X
- X will give an "Ok" prompt followed by a linefeed.
- X
- X The preset variable BWB.IMPLEMENTATION$ will return "TTY" for
- X the bwx_tty implementation and will return "IQC" for the
- X IBM PC or Compatibles with QuickC (bwx_iqc) implementation.
- X This may be useful in determing which commands and functions
- X (specifically CLS, LOCATE, and INKEY$) may be available.
- X
- X
- X7. UNIMPLEMENTED COMMANDS AND FUNCTIONS, and AGENDA FOR DEVELOPMENT
- X
- X There are some items not implemented that have been so long
- X a part of standard BASICs that their absence will seem surprising.
- X In each case, though, their implementation would require opera-
- X ting-system-specific functions or terminal-specific functions
- X that cannot be universally provided. Some specific examples:
- X
- X CLOAD Relies on CP/M or MSDOS conventions for binary
- X executable files.
- X
- X CONT See RESUME below (programmer ignorance?).
- X
- X DEF USR Relies on CP/M or MSDOS conventions for binary
- X executable files.
- X
- X FRE() The ability to report the amount of free memory
- X remaining is system-specific due to varying patterns
- X of memory allocation and access; consequently this
- X ability is not present in ANSI or earlier versions
- X of C and this function is not available in bwBASIC.
- X
- X INPUT$() C by itself is not able to read unechoed keyboard
- X input, and can read keyboard input only after a
- X Carriage-Return has been entered.
- X
- X INP Calls to hardware ports, like machine-language
- X routines, are highly system-specific and cannot
- X be implemented in C alone.
- X
- X LLIST See LPRINT below.
- X
- X LPOS See LPRINT below.
- X
- X LPRINT and LLIST, etc., require access to a printer device,
- X and this varies from one system to another. Users
- X might try OPENing the printer device on their own
- X operating system (e.g., "/dev/lp" on Unix systems,
- X or "PRN" under DOS) and see if printing can be done
- X from bwBASIC in this way.
- X
- X NULL In this case, I am convinced that NULL is no longer
- X necessary, since very few printers now require NULLs
- X at the end of lines.
- X
- X OUT See INP above (calls to hardware ports).
- X
- X PEEK() PEEK and POKE enabled earlier BASICs to address
- X particular memory locations. Although bwBASIC
- X could possibly implement this command (POKE) and
- X this function (PEEK()), the limitation would be
- X highly limited by the different systems for
- X memory access in different systems.
- X
- X POKE see PEEK() above.
- X
- X RENUM Since unnumbered lines can be entered and
- X executed under bwBASIC, it would not be
- X possible to implement a RENUM routine.
- X Instead, bwBASIC uses DO NUM and DO UNNUM.
- X
- X RESUME Is this possible under C? If so, I
- X simply have failed to figure it out yet.
- X Mea culpa (but not maxima).
- X
- X USR See CALL and DEF USR above (machine language
- X subroutines).
- X
- X VARPTR See PEEK and POKE above.
- X
- X WAIT See INP and OUT above.
- X
- X There are other commands, functions, and implementation details
- X that I am working on, and which are on the agenda list for future
- X versions of bwBASIC. These agenda include:
- X
- X PARACT i.e., the ability to execute PARallel ACTions. This
- X is described in ANSI BASIC, although I have not seen it
- X implemented before. It will offer a rough, non-
- X preemptive form of multitasking within the scope
- X of a BASIC program. Programmers will note points at which
- X there are already hooks for PARACT in bwBASIC.
- X
- X XMEM PC-type computers need to be able to use extended
- X memory. If we could use extended memory for program
- X lines, variables, and function defitions, we could
- X write much longer programs. This would entail,
- X however, a fairly serious rewriting of the program
- X to utilize memory handles for these storage features
- X instead of direct memory pointers.
- X
- X Windows The addition of memory handles in addition to the
- X non-preemptive execution of program lines (in a
- X crude form, already present) will make it possible
- X to develop implementations for Windows and perhaps
- X for other graphical user interfaces. But what form
- X should this take? I have in mind presently a BASIC
- X that would run in the background, appearing only
- X as an icon in the GUI space, with pop-up editors
- X and output windows. Thus, the interpreted language
- X would serve a purpose something like 'cron' (a task
- X scheduler) under Unix systems. You may have some
- X reflections that would help me in this.
- X
- X Graphics Here we face fairly critical differences in different
- X styles and implementations of graphics, e.g., between
- X GWBASIC, ANSI BASIC, VisualBASIC, etc. But it's
- X possible that Graphics commands and functions could
- X be added. These would all be implementation-specific.
- X
- X The ANSI Standard for full BASIC does not specify which particular
- X commands or functions must be implemented, and in fact the standard
- X is very robust. Perhaps no implementation of BASIC would ever
- X include all of the items, but some ANSI commands and functions which
- X remain unimplemented are:
- X
- X ACCESS
- X ANGLE
- X AREA
- X ARITHMETIC
- X ARRAY
- X ASK
- X BSTR
- X BVAL
- X CEIL
- X CELLS
- X CLIP
- X COLLATE
- X CONNECT
- X COSH
- X DATUM
- X DEBUG
- X DECIMAL
- X DECLARE
- X DEGREES
- X DEVICE
- X DISCONNECT
- X DISPLAY
- X DOT
- X DRAW
- X ERASE
- X EVENT
- X EXCEPTION
- X GRAPH
- X HANDLER
- X IMAGE
- X KEY
- X LCASE
- X LINES
- X LOG10
- X LOG2
- X MAT
- X MIX
- X MULTIPOINT
- X OUTIN
- X OUTPUT
- X PARACT
- X PICTURE
- X PIXEL
- X PLOT
- X POINTS
- X RADIANS
- X RECEIVE
- X RENUMBER
- X REWRITE
- X ROTATE
- X ROUND
- X SEIZE
- X SEND
- X SHIFT
- X SINH
- X TANH
- X TIMEOUT
- X TRACE
- X TRANSFORM
- X TRUNCATE
- X UBOUND
- X UCASE
- X VIEWPORT
- X WAIT
- X VIEWPORT
- X ZONEWIDTH
- X
- X
- X8. THE STORY OF BYWATER BASIC
- X
- X This program was originally begun in 1982 by my grandmother, Mrs.
- X Verda Spell of Beaumont, TX. She was writing the program using
- X an ANSI C compiler on an Osborne I CP/M computer and although my
- X grandfather (Lockwood Spell) had bought an IBM PC with 256k of
- X RAM my grandmother would not use it, paraphrasing George Herbert
- X to the effect that "He who cannot in 64k program, cannot in 512k."
- X She had used Microsoft BASIC and although she had nothing against
- X it she said repeatedly that she didn't understand why Digital
- X Research didn't "sue the socks off of Microsoft" for version 1.0
- X of MSDOS and so I reckon that she hoped to undercut Microsoft's
- X entire market and eventually build a new software empire on
- X the North End of Beaumont. Her programming efforts were cut
- X tragically short when she was thrown from a Beaumont to Port
- X Arthur commuter train in the summer of 1986. I found the source
- X code to bwBASIC on a single-density Osborne diskette in her knitting
- X bag and eventually managed to have it all copied over to a PC
- X diskette. I have revised it slightly prior to this release. You
- X should know, though, that I myself am an historian, not a programmer.
- X
- X
- X9. COMMUNICATIONS:
- X
- X email: tcamp@delphi.com
- X
- END_OF_FILE
- if test 58924 -ne `wc -c <'bwbasic-2.10/bwbasic.doc'`; then
- echo shar: \"'bwbasic-2.10/bwbasic.doc'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/bwbasic.doc'
- fi
- if test ! -d 'bwbasic-2.10/bwbtest' ; then
- echo shar: Creating directory \"'bwbasic-2.10/bwbtest'\"
- mkdir 'bwbasic-2.10/bwbtest'
- fi
- if test -f 'bwbasic-2.10/bwbtest/dataread.bas' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/bwbtest/dataread.bas'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/bwbtest/dataread.bas'\" \(505 characters\)
- sed "s/^X//" >'bwbasic-2.10/bwbtest/dataread.bas' <<'END_OF_FILE'
- X10 rem DATAREAD.BAS -- Test DATA, READ, and RESTORE Statements
- X20 print "DATAREAD.BAS -- Test DATA, READ, and RESTORE Statements"
- X30 DATA "Ted", 56.789
- X40 REM just to see if it advances correctly
- X50 DATA "Dale", 45.678
- X 60 READ N$, NUMBER, ANOTHER$
- X 70 READ ANUMBER
- X 80 PRINT "Data read: ";N$;" ";NUMBER;" ";ANOTHER$;" ";ANUMBER
- X90 RESTORE 30
- X 100 READ ANOTHER$
- X 110 READ ANUMBER, N$,NUMBER
- X 120 PRINT "After RESTORE:"
- X 130 PRINT "Data read: ";ANOTHER$;" ";ANUMBER;" ";N$;" ";NUMBER
- X140 END
- END_OF_FILE
- if test 505 -ne `wc -c <'bwbasic-2.10/bwbtest/dataread.bas'`; then
- echo shar: \"'bwbasic-2.10/bwbtest/dataread.bas'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/bwbtest/dataread.bas'
- fi
- echo shar: End of archive 1 \(of 15\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 15 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-