TranslateProject/sources/tech/20210623 Program on FreeDOS with Bywater BASIC.md
DarkSun 64dcb55778 选题[tech]: 20210623 Program on FreeDOS with Bywater BASIC
sources/tech/20210623 Program on FreeDOS with Bywater BASIC.md
2021-06-24 05:04:11 +08:00

5.4 KiB

Program on FreeDOS with Bywater BASIC

Install Bywater BASIC on your FreeDOS system and start experimenting with BASIC programming. woman on laptop sitting at the window

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 came built into most personal computers, from Apple to IBM PCs.

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 (Jim Hall, CC-BY SA 4.0)

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 (Jim Hall, CC-BY SA 4.0)

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 displays the usage and a brief description.

Bywater BASIC

Use the "help" system as a quick-reference guide (Jim Hall, CC-BY SA 4.0)

Another neat feature in Bywater BASIC is how it reformats your BASIC instructions, so they are easier to read. After typing 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 (Jim Hall, CC-BY SA 4.0)

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 (Jim Hall, CC-BY SA 4.0)

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.


via: https://opensource.com/article/21/6/freedos-bywater-basic

作者:Jim Hall 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出