FreeDOS logo

How to program on FreeDOS with Bywater BASIC

In the early days of personal computing, from the late 1970s and through the 1980s, many people got their start with BASIC programming. BASIC was a universal programming language that was built into most personal computers, from the Apple to the IBM PC.

When we started the FreeDOS Project in June 1994, it seemed natural that we should include an open source BASIC environment. I was excited to discover one already existed in Bywater BASIC.

The Bywater BASIC website reminds us that "Bywater BASIC 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)." It's also distributed under the GNU General Public License version 2, which means it's open source software. We only want to include open source programs in FreeDOS, so Bywater BASIC was a great addition to FreeDOS in our early days.

We've included Bywater BASIC since at least FreeDOS Alpha 5, in 1997. You can find Bywater BASIC in FreeDOS 1.3 RC4 in the "Development" package group, on the Bonus CD. Load this

Bywater BASIC
Installing Bywater BASIC on FreeDOS 1.3 RC4

FreeDOS installs the Bywater BASIC package in the \DEVEL\BWBASIC directory. Change to this directory with CD \DEVEL\BWBASIC and type BWBASIC to run the Bywater BASIC interpreter.

Bywater BASIC
The Bywater BASIC intepreter

Writing a sample program

Let me demonstrate Bywater BASIC by writing a test program. We'll keep this simple: print five random numbers. This requires only a few constructs: a loop to iterate over five values, and a random number generator. BASIC uses the RND(1) statement to generate a random value between 0 and 1. We can use PRINT to display the random number.

One feature I like in Bywater BASIC is the integrated "help" system. There's nothing more frustrating than forgetting the syntax for a BASIC statement. For example, I always forget how to create BASIC loops. Do I use FOR I IN 1 TO 10 or FOR I = 1 TO 10? Just type help FOR at the Bywater BASIC prompt, and the interpreter will display the usage and a brief description.

Bywater BASIC
Use the "help" system as a quick-reference guide

Another neat feature in Bywater BASIC is how it reformats your BASIC instructions so they are easier to read. After I've typed my brief program, I can type list to see the full source listing. Bywater BASIC automatically adds the CALL keyword to my RANDOMIZE statement on line 10, and indents the PRINT statement inside my loop. These small changes help me to see loops and other features in my program, which can aid in debugging.

Bywater BASIC
Bywater BASIC automatically reformats your code

If everything looks okay, then type RUN to execute the program. Because I used the RANDOMIZE statement at the start of my BASIC program, Bywater seeds the random number generator with a random starting point. This ensures that my numbers are actually random values, and don't repeat when I re-run my program.

Bywater BASIC
Generating lists of random numbers

Install Bywater BASIC on your FreeDOS system, and start experimenting with BASIC programming. BASIC can be a great first programming language, especially if you are interested in getting back to the "roots" of personal computing. You can find more information about Bywater BASIC in the manual, installed in the \DEVEL\BWBASIC directory as BWBASIC.DOC. You can also explore the online "help" system by typing HELP at the Bywater BASIC prompt.