Bywater BASIC Extended Reference Guide


 

Command or Function

Description

Dependencies

Function: ABS( number ) ABS returns the absolute value of the argument 'number'. (core)
Function: ASC( string$ ) ASC returns the ASCII code for the first letter in the argument string$. MS_FUNCS
Function: ATN( number ) ATN returns the arctangent value of the argument 'number' in radians. (core)
Command: CALL subroutine-name CALL calls a named subroutine (see SUB and END SUB). STRUCT_CMDS
Command: CASE ELSE | IF partial-expression | constant CASE introduces an element of a SELECT CASE statement (see SELECT CASE). CASE IF introduces a conditional SELECT CASE element, and CASE ELSE introduces a default SELECT CASE element. STRUCT_CMDS
Command: CHAIN [MERGE] file-name [, line-number] [, ALL] CHAIN passes control to another BASIC program. Variables declared COMMON (q.v.) will be passed to the new program. COMMON_CMDS
Command: CHDIR pathname$ CHDIR changes the current directory to that indicated by the argument pathname$. UNIX_CMDS
Function: CHR$( number ) CHR$ returns a one-character string with the character corresponding to the ASCII code indicated by argument 'number'. COMMON_FUNCS
Function: CINT( number ) CINT returns the truncated integer for the argument 'number'. MS_FUNCS
Command: CLEAR CLEAR sets all numerical variables to 0, and all string variables to null. COMMON_CMDS
Command: CLOSE [[#]file-number]... CLOSE closes the file indicated by file-number (see OPEN). COMMON_CMDS
Command: CLS CLS clears the display screen (IBM and compatibles only as of version 2.10). IMP_IQC and IMP_CMDLOC
Command: CMDS CMDS is a debugging command that prints a list of all implemented bwBASIC commands. DEBUG
Command: COMMON variable [, variable...] COMMON designates variables to be passed to a CHAINed program (see CHAIN). COMMON_CMDS
Function: COS( number ) COS returns the cosine of the argument 'number' in radians. (core)
Function: CSNG( number ) CSNG is a pseudo-function that has no effect under bwBASIC. It replicates a Microsoft-type command that would convert the 'number' to single-precision. MS_FUNCS
Function: CVD( string$ ) CVD converts the argument string$ into a bwBASIC number (precision is irrelevant in bwBASIC since bwBASIC numbers have only one precision). Implenentation-Specific Notes: CVD(), CVI(), CVS(), MKI$(), MKD$(), MKS$(): These functions are implemented, but are dependent on a) the sizes for integer, float, and double values on particular systems, and b) how particular versions of C store these numerical values. The implication is that data files created using these functions on a DOS-based microcomputer may not be translated correctly by bwBASIC running on a Unix-based computer. Similarly, data files created by bwBASIC compiled by one version of C may not be readable by bwBASIC compiled by another version of C (even under the same operating system). So be careful with these. MS_FUNCS
Function: CVI( string$ ) CVI converts the argument string$ into a bwBASIC number (precision is irrelevant in bwBASIC since bwBASIC numbers have only one precision; see also the note on CVD). MS_FUNCS
Function: CVS( string$ ) CVI converts the argument string$ into a bwBASIC number (precision is irrelevant in bwBASIC since bwBASIC numbers have only one precision; see also the note on CVD). MS_FUNCS
Command: DATA constant[,constant]... DATA stores numerical and string constants to be accessed by READ (q.v.). (core)
Function: DATE$ DATE$ returns the current date based on the computer's internal clock as a string in the form "YYYY-MM-DD". As implemented under bwBASIC, DATE$ cannot be used for assignment (i.e., to set the system date). Note: bwBASIC presently (v2.10) does not allow assignment to a function. COMMON_FUNCS
Command: DEF FNname(arg...)] = expression DEF defines a user-written function. This function corresponds to Microsoft-type implementation, although in bwBASIC DEF is a working equivalent of FUNCTION. (core)
Command: DEFDBL letter[-letter](, letter[-letter])... DEFDBL declares variables with single-letter names as numerical variables (precision is irrelevant in bwBASIC). MS_CMDS
Command: DEFINT letter[-letter](, letter[-letter])... DEFINT declares variables with single-letter names as numerical variables (precision is irrelevant in bwBASIC). MS_CMDS
Command: DEFSNG letter[-letter](, letter[-letter])... DEFSNG declares variables with single-letter names as numerical variables (precision is irrelevant in bwBASIC). MS_CMDS
Command: DEFSTR letter[-letter](, letter[-letter])... DEFSTR declares variables with single-letter names as string variables. MS_CMDS
Command: DELETE line[-line] DELETE deletes program lines indicated by the argument(s). If you want to use DELETE for non- numbered programs, first use DO NUM, then DELETE, then DO UNNUM. INTERACTIVE
Command: DIM variable(elements...)[variable(elements...)]... DIM specifies variables that have more than one element in a single dimension, i.e., arrayed variables. Note: As implemented under bwBASIC, DIM accepts only parentheses as delimiters for variable fields. (Some BASICs allow the use of square brackets.) (core)
Command: DO NUM|UNNUM DO NUM numbers all lines in a program. The first line is given the number 10, and subsequent lines are numbered consecutively in multiples of 10. DO UNNUM removes all line numbers from a program. NOTE that these functions do nothing to line numbers, e.g., following a GOSUB or GOTO statement; these commands cannot be used as a replacement for RENUM (available in some systems, but not bwBASIC). With these commands, however, one can develop unnumbered programs by entering new lines with numbers, then running DO UNNUM to remove the line numbers. Together with LOAD and SAVE (q.v.) one can use bwBASIC as a primitive text editor. INTERACTIVE
Command: DO [WHILE expression] DO implements a number of forms of program loops. DO...LOOP simply loops; the only way out is by EXIT; DO WHILE...LOOP loops while "expression" is true (this is equivalent to the older WHILE-WEND loop, also implemented in bwBASIC); DO...LOOP UNTIL loops until the expression following UNTIL is true. STRUCT_CMDS
Command: EDIT EDIT is a pseudo-command which calls the text editor specified in the variable BWB.EDITOR$ to edit the program in memory. After the call to the text editor, the (edited) prgram is reloaded into memory. The user normally must specific a valid path and filename in BWB.EDITOR$ before this command will be useful. COMMON_CMDS
Command: ELSE ELSE introduces a default condition in a multi-line IF statement. STRUCT_CMDS
Command: ELSEIF ELSEIF introduces a secondary condition in a multi- line IF statement. STRUCT_CMDS
Command: END IF | FUNCTION | SELECT | SUB END IF ends a multi-line IF statement. END FUNCTION ends a multi-line function definition. END SELECT ends a SELECT CASE statement. END SUB ends a multi- line subroutine definition. STRUCT_CMDS
Command: ENVIRON variable-string$ = string$ ENVIRON sets the environment variable identified by variable-string$ to string$. It might be noted that this differs from the implementation of ENVIRON in some versions of BASIC, but bwBASIC's ENVIRON allows BASIC variables to be used on either side of the equals sign. Note that the function ENVIRON$() is different from the command, and be aware of the fact that in some operating systems an environment variable set within a program will not be passed to its parent shell. UNIX_CMDS
Function: ENVIRON$( variable-string$ ) ENVIRON$ returns the environment variable associated with the name variable-string$. MS_FUNCS
Function: EOF( device-number ) EOF returns TRUE (-1) if the device associated with device-number is at the end-of-file, otherwise it returns FALSE (0). MS_FUNCS
Command: ERASE variable[, variable]... ERASE eliminates arrayed variables from a program. COMMON_CMDS
Function: ERL ERL returns the line number of the most recent error. MS_FUNCS
Function: ERR ERR returns the error number of the most recent error. Note that if PROG_ERRORS has been defined when bwBASIC is compiled, the ERR variable will not be set correctly upon errors. It only works when standard error messages are used. MS_FUNCS
Command: ERROR number ERROR simulates an error, i.e., displays the message appropriate for that error. This command is helpful in writing ON ERROR GOSUB routines that can identify a few errors for special treatment and then ERROR ERR (i.e., default handling) for all others. COMMON_CMDS
Command: EXIT [FOR] EXIT by itself exits from a DO...LOOP loop; EXIT FOR exits from a FOR...NEXT loop. STRUCT_CMDS
Function: EXP( number ) EXP returns the exponential value of 'number'. (core)
Command: FIELD [#] device-number, number AS string-variable$ [, number AS string-variable$...] FIELD allocates space in a random file buffer for device indicated by device-number, allocating 'number' bytes and assigning the bytes at this position to the variable string-variable$. COMMON_CMDS
Command: FILES filespec$ FILES is a pseudocommand that invokes the directory program specified in the variable BWB.FILES$ with the argument filespec$. Normally, the user must set this variable before FILES can be used. E.g., for PC-type computers, BWB.FILES$ = "DIR" will work, for Unix machines, BWB.FILES$ = "ls -l" etc. COMMON_CMDS
Command: FNCS CMDS is a debugging command that prints a list of all pre-defined bwBASIC functions. DEBUG
Command: FUNCTION FUNCTION introduces a function definition, normally ending with END FUNCTION. In bwBASIC, FUNCTION and DEF are qorking equivalents, so either can be used with single-line function definitions or with multi- line definitions terminated by END FUNCTION. STRUCT_CMDS
Command: FOR counter = start TO finish [STEP increment] FOR initiates a FOR-NEXT loop with the variable 'counter' initially set to 'start' and incrementing in 'increment' steps (default is 1) until 'counter' equals 'finish'. (core)
Command: GET [#] device-number [, record-number] GET reads the next reacord from a random-access file or device into the buffer associated with that file. If record-number is specified, the GET command reads the specified record. COMMON_CMDS
Command: GOSUB line | label GOSUB initiates a subroutine call to the line (or label) specified. The subroutine must end with RETURN. (core), but STRUCT_CMDS for labels
Command: GOTO line | label GOTO branches program execution to the specified line (or label). (core), but STRUCT_CMDS for labels
Function: HEX$( number ) HEX$ returns a string giving the hexadecimal (base 16) value for the 'number'. MS_FUNCS
Command: IF expression THEN [statement [ELSE statement]] IF evaluates 'expression' and performs the THEN statement if it is true or (optionally) the ELSE statement if it is FALSE. If STRUCT_CMDS is set to TRUE, bwBASIC allows multi-line IF statements with ELSE and ELSEIF cases, ending with END IF. (core), STRUCT_CMDS for multi-line IF statements
Function: INKEY$ INKEY$ reads the status of the keyboard, and a single keypress, if available. If a keypress is not available, then INKEY$ immediately returns a null string (""). Currently (v2.10) implemented in bwx_iqc.c only. IMP_IQC and IMP_CMDLOC
Command: INPUT [# device-number]|[;]["prompt string";]list of variables INPUT allows input from the terminal or a device specified by device-number. If terminal, the "prompt string" is output, and input is assigned to the appropriate variables specified. bwBASIC does not support the optional feature of INPUT that suppresses the carriage-return and line-feed at the end of the input. This is because C alone does not provide for any means of input other than CR-LF-terminated strings. (core)
Function: INSTR( [start-position,] string-searched$, string-pattern$ ) INSTR returns the position at which string-pattern$ occurs in string-searched$, beginning at start-position. As implemented in bwBASIC, INSTR cannot be used for assignments. Note: bwBASIC presently (v2.10) does not allow assignment to a function. MS_FUNCS
Function: INT( number ) INT returns the largest integer less than or equal to the argument 'number'. NOTE that this is not a "truncated" integer function, for which see CINT. (core)
Command: KILL file-name$ KILL deletes the file specified by file-name$. UNIX_CMDS
Function: LEFT$( string$, number-of-spaces ) LEFT$ returns a substring a string$ with number-of-spaces from the left (beginning) of the string). As implemented under bwBASIC, it cannot be used for assignment. MS_FUNCS
Function: LEN( string$ ) LEN returns the length in bytes of string$. COMMON_FUNCS
Command: LET variable = expression LET assigns the value of 'expression' to the variable. As currently implemented, bwBASIC supports implied LET statements (e.g., "X = 4.5678" at the beginning of a line or line segment, but does not support assignment to multiple variables (e.g., "x, y, z = 3.141596"). (core)
Command: LINE INPUT [[#] device-number,]["prompt string";] string-variable$ LINE INPUT reads entire line from the keyboard or a file or device into string-variable$. If input is from the keyboard (stdin), then "prompt string" will be printed first. Unlike INPUT, LINE INPUT reads a whole line, not stopping for comma-delimited data items. COMMON_CMDS
Command: LIST line[-line] LIST lists program lines as specified in its argument. INTERACTIVE
Command: LOAD file-name LOAD loads an ASCII BASIC program into memory. INTERACTIVE
Function: LOC( device-number ) LOC returns the next record that GET or PUT statements will use. MS_FUNCS
Command: LOCATE line, column LOCATE addresses trhe curor to a specified line and column. Currently (v2.10) implemented in bwx_iqc.c only. IMP_IQC and IMP_CMDLOC
Function: LOF( device-number ) LOF returns the length of a file (specified by device-number) in bytes. MS_FUNCS
Function: LOG( number ) LOG returns the natural logarithm of the argument 'number'. (core)
Command: LOOP [UNTIL expression] LOOP terminates a program loop: see DO. STRUCT_CMDS
Command: LSET string-variable$ = expression LSET transfers data from 'expression' to the left-hand side of a string variable or random access buffer field. COMMON_CMDS
Command: MERGE file-name MERGE adds program lines from 'file-name' to the program in memory. Unlike LOAD, it does not clear the program currently in memory. COMMON_CMDS
Function: MID$( string$, start-position-in-string[, number-of-spaces ] ) MID$ returns a substring of string$ beginning at start-position-in-string and continuing for number-of-spaces bytes. MS_FUNCS
Command: MKDIR pathname$ MKDIR creates a new directory path as specified by pathname$. UNIX_CMDS
Function: MKD$( number ) MKD$, MKI$, and MKS$ are all equivalent in bwBASIC. They convert the numerical value 'number' into a string which can be stored in a more compressed form in a file (especially for random file access). Since bwBASIC does not recognize differences in precision, these commands are effectively equivalent. MS_FUNCS
Function: MKI$( number ) Equivalent to MKD$ (q.v.) MS_FUNCS
Function: MKS$( number ) Equivalent to MKD$ (q.v.). MS_FUNCS
Command: NAME old-file-name AS new-file-name NAME renames an existing file (old-file-name) as new-file-name. UNIX_CMDS
Command: NEW NEW deletes the program in memory and clears all variables. INTERACTIVE
Command: NEXT [counter-variable] NEXT comes at the end of a FOR-NEXT loop; see FOR. (core)
Function: OCT$( number ) OCT$ returns a string giving the octal (base 8) representation of 'number'. MS_FUNCS
Command: ON variable GOTO|GOSUB line[,line,line,...] ON either branches (GOTO) or calls a subroutine (GOSUB) based on the rounded value of variable; if it is 1, the first line is called, if 2, the second line is called, etc. (core)
Command: ON ERROR GOSUB line|label ON ERROR sets up an error handling subroutine. See also ERROR. COMMON_CMDS, STRUCT_CMDS for labels
Command: OPEN "O"|"I"|"R", [#]device-number, file-name [,record length] file-name FOR INPUT|OUTPUT|APPEND AS [#]device-number [LEN = record-length] OPEN allocates random access memory for access to a disk file or other device. Note that two quite different forms of the OPEN statement are supported. In the first form, "O" (note that these letters must be encased in quotation marks) denotes sequential output, "I" denotes sequential input, and "R" denotes random-access input and output. Once OPEN, any number of operations can be performed on a device (see WRITE #, INPUT #, PRINT #, etc.). COMMON_CMDS
Command: OPTION BASE number OPTION BASE sets the lowest value for array subscripts, either 0 or 1. (core)
Function: POS POS returns the current cursor position in the line. COMMON_FUNCS
Command: PRINT [# device-number,][USING format-string$;] expressions... PRINT outputs text to the screen or to a file or device specified by device-number. In the current implementation of bwBASIC, expressions to be printed must be separated by the comma (tabbed output), the semicolon (immediate sequential output) or the plus sign (immediate sequential output by string concatenation). Expressions separated by blanks or tabs are not supported. If USING is specified, a number of formatting marks may appear in the format string: ! prints the first character of a string \\ prints 2+x characters of a string, where x = the number of spaces between the backslashes & variable-length string field # represents a single digit in output format for a number . decimal point in a number + sign of a number (will output + or -) - trailing minus after a number ** fill leading spaces with asterisks $$ output dollar sign in front of a number ^^ output number in exponential format _ output next character literally As currently implemented, the exponential format will be that used by the C compiler. (core), COMMON_FUNCS for USING
Command: PUT [#] device-number [, record-number] PUT outputs the next available record or the record specified by record-number to the file or device denoted by device-number. COMMON_CMDS
Command: QUIT QUIT is a synonym for SYSTEM; with INTERACTIVE environment, it exits the program to the operating system (or the calling program). INTERACTIVE
Command: RANDOMIZE number RANDOMIZE seeds the random number generator (see RND). Under bwBASIC, the TIMER function (q.v.) can be used to supply a 'number' seed for the random number generator. (core)
Command: READ variable[, variable]... READ reads values from DATA statements and assigns these values to the named variables. Variable types in a READ statement must match the data types in DATA statements as they are occurred. See also DATA and RESTORE. (core)
Command: REM string REM allows remarks to be included in a program. As currently implemented, the entire line following REM is ignored by the interpreter (thus, even if MULTISEG_LINES is set, a REM line will not be able to find a segment delimiter (":") followed by another line segment with command. bwBASIC does not currently implement the Microsoft-style use of the single quotation mark to denote remarks. (core)
Command: RESTORE line RESTORE resets the line and position counters for DATA and READ statements to the top of the program file or to the beginning of the specified line. (Currently this must be a line number.) (core)
Command: RETURN RETURN concludes a subroutine called by GOSUB. (core)
Function: RIGHT$( string$, number-of-spaces ) RIGHT$ returns a substring a string$ with number-of-spaces from the right (end) of the string). As implemented under bwBASIC, it cannot be used for assignment. MS_FUNCS
Command: RMDIR pathname RMDIR deletes the directory path indicated by pathname. UNIX_CMDS
Function: RND( number ) RND returns a pseudo-random number. The 'number' value is ignored by bwBASIC if supplied. The RANDOMIZE command (q.v.) reseeds the random-number generator. (core)
Command: RSET string-variable$ = expression RSET transfers data from 'expression' to the right-hand side of a string variable or random access buffer field. COMMON_CMDS
Command: RUN [line][file-name$] RUN executes the program in memory. If a file-name$ is supplied, then the specified file is loaded into memory and executed. If a line number is supplied, then execution begins at that line. INTERACTIVE
Command: SAVE file-name$ SAVE saves the program in memory to file-name$. bwBASIC only saves files in ASCII format. INTERACTIVE
Command: SELECT CASE expression SELECT CASE introduces a multi-line conditional selection statement. The expression given as the argument to SELECT CASE will be evaluated by CASE statements following. The SELECT CASE statement conclludes with an END SELECT statement. As currently implemented, CASE statements may be followed by string values, but in this case only simple comparisons (equals, not equals) can be performed. STRUCT_CMDS
Function: SGN( number ) SGN returns the sign of the argument 'number', +1 for positive numbers, 0 for 0, and -1 for negative numbers. (core)
Function: SIN( number ) SIN returns the sine of the argument 'number' in radians. (core)
Function: SPACE$( number ) SPACE$ returns a string of blank spaces 'number' bytes long. MS_FUNCS
Function: SPC( number ) SPC returns a string of blank spaces 'number' bytes long. MS_FUNCS
Function: SQR( number ) SQR returns the square root of the argument 'number'. (core)
Command: STOP STOP interrupts program execution. As implemented under bwBASIC, STOP issues a SIGINT signal. (core)
Function: STR$( number ) STR$ returns a string giving the decimal (base 10) representation of the argument 'number'. COMMON_FUNCS
Function: STRING$( number, ascii-value|string$ ) STRING$ returns a string 'number' bytes long consisting of either the first character of string$ or the character answering to the ASCII value ascii-value. MS_FUNCS
Command: SUB subroutine-name SUB introduces a named, multi-line subroutine. The subroutine is called by a CALL statement, and concludes with an END SUB statement. STRUCT_CMDS
Command: SWAP variable, variable SWAP swaps the values of two variables. The two variables must be of the same type (either numerical or string). COMMON_CMDS
Command: SYSTEM SYSTEM exits from bwBASIC to the calling program or (more usually) the operating system. INTERACTIVE
Function: TAB( number ) TAB outputs spaces until the column indicated by 'number' has been reached. (core)
Function: TAN( number ) TAN returns the tangent of the argument 'number' in radians. (core)
Function: TIME$ TIME$ returns the current time based on the computer's internal clock as a string in the form "HH-MM-SS". As implemented under bwBASIC, TIME$ cannot be used for assignment (i.e., to set the system time). Note: bwBASIC presently (v2.10) does not allow assignment to a function. COMMON_FUNCS
Function: TIMER TIMER returns the time in the system clock in seconds elapsed since midnight. MS_FUNCS
Command: TROFF TROFF turns of the trace facility; see TRON. COMMON_CMDS
Command: TRON TRON turns on the trace facility. This facility will print each line number in square brackets as the program is executed. This is useful in debugging programs with line numbers. To debug an unnumbered program with TRON, call DO NUM first, but remember to call DO UNNUM before you save the program later. COMMON_CMDS
Function: VAL( string$ ) VAL returns the numerical value of the string$. COMMON_FUNCS
Command: VARS VARS is a debugging command which prints a list of all variables defined which have global scope. DEBUG
Command: WEND WEND concludes a WHILE-WEND loop; see WHILE. COMMON_CMDS
Command: WHILE expression WHILE initiates a WHILE-WEND loop. The loop ends with WEND, and execution reiterates through the loop as long as the 'expression' is TRUE (-1). COMMON_CMDS
Command: WIDTH [# device-number,] number WIDTH sets screen or device output to 'number' columns. device-number specifies the device or file for oputput. COMMON_CMDS
Command: WRITE [# device-number,] element [, element ].... WRITE outputs variables to the screen or to a file or device specified by device-number. Commas are inserted between expressions output, and strings are enclosed in quotation marks. COMMON_CMDS

 

Return to Bywater BASIC Home Page