Bywater BASIC fundamentals

Introduction

This document discusses fundamental operations of using Bywater BASIC on a Unix computer (such as cis.niagara.edu).

Case sensitivity

Bywater BASIC is case sensitive with respect to programmer-created identifiers such as variable names. This means, for example, that taxrate, taxRate, and TAXRATE are 3 distinct variable names.

However, command and function names are not case sensitive.  Thus, you may execute your program via run or RUN; you may compute the absolute value of the variable x via abs(x) or ABS(x).

Getting into BASIC

At the operating system prompt message, give the command bwbasic.  Thus (with your typing underlined):

cis $ bwbasic

(Note: Unix commands are case sensitive - for example, BWBASIC won't work.) You should notice that the prompt message changes: the Bywater BASIC prompt message is

bwBASIC: as opposed to the Unix prompt cis $

Retrieving a saved program file

Use a command of the form load "programname".  For example, if you have saved a program using the file name miles.bas, then you can retrieve this program as follows:

bwBASIC: load "miles.bas"

The quotation marks around the file name are required.

Listing your program

This refers to printing the list of statements that make up the program. You may list the entire program, or a single line, or a range of lines. Examples:

bwBASIC: list
     10: Rem a few lines of code to demo the behavior of the LIST command
     20: rem Here's a jolly good line of code.
     30: rem Here's a lousy line for attempting to start a relationship.
Assume that the previous example shows the entire program used for the following examples.
- - - - - - - - - - - -
bwBASIC: list 10-20
     10: Rem a few lines of code to demo the behavior of the LIST command
     20: rem Here's a jolly good line of code.
The above is an example of listing a range of lines, when the lines corresponding to the first and last linenumber in the range exist in the program.
- - - - - - - - - - - -
bwBASIC: list 10-15
     10: Rem a few lines of code to demo the behavior of the LIST command
     20: rem Here's a jolly good line of code.
     30: rem Here's a lousy line for attempting to start a relationship.
The above shows if you try to list a range, and the first linenumber of the range corresponds to an existing line of code but the last linenumber of the range does not, then the entire program is listed. Other dialects of BASIC would simply list all lines with linenumbers in the specified range.
- - - - - - - - - - - -
bwBASIC: list 10
     10: Rem a few lines of code to demo the behavior of the LIST command
The above is an example of trying to list one line, when the line requested exists in the program.
- - - - - - - - - - - -
bwBASIC: list 11

ERROR: Line number 11 not found
Thus if you attempt to list one line using a non-existent linenumber, a message informs you that no such line exists.

Entering a new line of code, or correcting an existing line

Type the line (with its linenumber) as you wish it to appear in your program.  Note when you list your program, Bwbasic will insert a colon following the linenumber.

Lines of code are ordered by linenumber - if you enter lines out of order, they will automatically be sorted (using ascending order) according to their linenumbers.  Since the linenumber must be an integer, it is wise to leave gaps in your numbering, so that you have the ability to insert additional lines of code if you decide it's desirable to do so.

Removing an undesired line of code

Just enter the linenumber of the undesired line to remove the line from your listing. For example, to remove line 15:

bwBASIC: 15

Saving a program file

Use a command of the form save "programname".  For example, if you wish to save your current program using the file name blah.bas, use

bwBASIC: save "blah.bas" The quotation marks around the file name are required.

Running a program

Running, or executing, a program, is the process of having the program do the work it's designed to do. This is done via the run command:

bwBASIC: run

Quitting BASIC

Use the command quit - bwBASIC: quit This will return you to the operating system prompt message.

Links

To Boxer's home page