Chapter 1

Looking at the Basics

BASIC09 is a computer language created for use with the OS-9 operating system. Along with standard BASIC language statements and functions, it includes the most useful elements of the PASCAL computer language.


In brief, BASIC09's advantages are:


Full feature editing The text editor features automatic line
formatting, search, search and change,
global search, global search and
change, line renumbering, and much
more. You can move in and out of the
editor quickly and easily.
Modular You can write small, easy-to-under
programming stand procedures, then chain them to
functions create sophisticated programs. You can
call one procedure from another,
regardless of whether the called proce
dure is in memory or on disk.
Interfacing to OS-9 Both you and your procedures can
take advantage of almost any OS-9
function from within BASIC, including
the execution of disk management
commands and application programs.
Structured You can structure procedures more
programming efficiently and clearly by taking advan
tage of a variety of loop commands,
optional line numbering, and
BASIC09's ability to call modules
written in other computer languages.

1-1
BASIC09 Reference

Memory saving features

Complex data structures

Sophisticated graphics

High speed, precision math

Simple and fast debugging

Strings can be any length. For each operation, you can select the most efficient of five available data types. Compiled procedures use less space. You can save several procedures into one file.


Combine any type of data into a single dimensioned data structure that you can move, store, and assign easily and quickly.


BASIC09 has three levels of graphics. The high resolution graphics and text capabilities feature more than 50 functions.


BASIC09 has a full range of fast and accurate math and transcendental capabilities including powers, roots, trigonometry, logic, and Boolean functions.


BASIC09 provides superior debugging functions. It checks syntax as you enter lines. It points to the location of your errors and tells you what they are. You can stop programs, enter the debugger, then continue execution. Execution errors automatically put you in a debugging mode where you can examine values, and step and trace your way through faulty procedures.


Using BASIC09

Before anything else, make a backup copy of your BASIC09/ CONFIG diskette. You can do this using the BACKUP command. If you are not familiar with BACKUP, see Chapter 3 of Getting Started With OS-9.


To use BASIC09, boot your computer as described in Getting Started With OS-9. Replace the system diskette in Drive /DO with the BASIC09/CONFIG backup diskette and type:



After a short pause, during which OS-9 loads BASIC09 from the diskette, the screen displays the copyright and a new prompt, like this:


BASIC09

RS VERSION 01.0 0.01

COPYRIGHT 1980 BY MOTOROLA INC.

AND MICROWARE SYSTEMS CORP.

REPRODUCED UNDER LICENSE

TO TANDY CORP.

ALL RIGHTS RESERVED




The B: indicates that your computer is in the BASIC09 command mode. From the command mode, you can issue instructions to the system executive to manipulate procedures (programs).


Requesting More Memory

Unless you specify otherwise, BASIC09 automatically sets aside 8192 bytes of memory as a workspace into which you can type or load procedures. BASIC09 reserves approximately 1200 bytes of the workspace for internal use, leaving you with 6992 bytes for workspace.


There are two ways to set aside more memory for BASIC09 operations:










BASIC09 Reference

In both cases, because BASIC09 rounds the amount you request to the next multiple of 256, the actual reserved memory is 18176 bytes.


Note: If your system does not have enough free memory to reserve the amount you specify, the workspace size does not change.

You can also use the MEM command to reduce memory. However, BASIC09 does not reduce the size of the workspace if doing so destroys resident procedures.


Writing Procedures

BASIC09 is a modular programming language. Several procedures can occupy memory at the same time. Each procedure performs a particular function but can also interact with others to form a sophisticated program.


To create or change procedures, enter the edit mode by typing either e d i t ENTER or CD ENTER at the B : prompt . From now on, when directing you to enter the edit mode, this manual uses the easier to type CD.command.


Each time you type a procedure line and press ENTER , the editor checks for common errors. This automatic checking lets you catch mistakes before you run the program, saving you testing and rewriting time. You can even let the automatic checking help you learn the rules of BASIC09. If you are not sure about a syntax, go ahead and type it the way you think is correct. If you guess wrong, BASIC09 shows where the error is and displays a message to tell what is wrong.


BASIC09's use of modules lets you divide large and complex projects into smaller, easily manageable sections. Not only are the smaller procedures easier to write and understand, they are also easier to test As well, because BASIC09 lets you call procedures that are outside the workspace (the computer's memory where you write and edit procedures), you can accumulate libraries of procedures to incorporate into future programs.


You can work on a program's procedures either individually or as a group. For example, to work on the procedures as a group, save your workspace procedures into a single disk file. When you subsequently load the file, BASIC09 automatically loads all of the procedures.


1-4


Modules of Other Languages

BASIC09 can incorporate procedures from other languages, such as Pascal, C, or assembly language. Several users can then share the procedures.


Executing Procedures

You execute or run programs from the command mode. When you enter a procedure, BASIC09 compiles it. This means that the procedure is ready for execution as soon as you exit the edit mode. For instance, if you create a program named Greeting, you can execute it by typing from the command mode:




Leaving BASIC09

There are two ways you can exit from BASIC09:







When you use either method, the OS-9 prompt appears immediately indicating that the operating system is waiting for a command.

Note: When you exit BASIC09, you lose all procedures residing in the workspace. Be sure to save them on disk before leaving BASIC09.

The Keyboard and BASIC09

You can use some keys and key sequences to produce special characters and to accomplish special BASIC09 functions. You initiate a key sequence by pressing one key and holding it down while pressing a second key. The following list summarizes your keyboard's special functions:


BASIC09 Reference

a~T Produces graphic characters. Press a~T char
where char is a keyboard character).
crR~ A control key that you use with other keys.
(See below)
BREAK Or Stops the current program execution and
CTRL CD returns to the H : prompt in BASIC09's com
mand mode.
~ or Moves the cursor back one space.
CTRL CE
crR~~ Produces an underscore character.
CTRL Q Produces a left brace ( < ).
CTRL ~ Produces a right brace ( > ).
crR~ CE Produces a tilde H.
CTRL Q Produces a backslash (v).
CTRL BREAK Performs an ESCAPE function and sends an
end-of-file message to a program receiving
keyboard input. To be recognized, CTRL BREAK
must be the first thing typed on a line.
SHIFT BREAK Stops execution of a program and causes
BASIC09 to enter the Debug mode.
CLEAR Displays the next window.
SHIFT CLEAR Displays the previous window.
sHm ~ or Deletes the current line.
CTRL X~
CTRL 0 Activates or deactivates the shift lock function.
CTRL CD Produces a vertical bar ( ~ ).
CTRL CD Produces an up arrow (+).
CTRL CE Produces a left bracket ( t ).
CTRL s~ Produces a right bracket (1).

1-6


CTRL 0 Redisplays the last line typed, and positions
the cursor at the end of the line, but does not
process the line. Press ENTER to process the
line, or edit the line by backspacing. If you
edit, press cTR~ CE again to display the edited
line.
CTRL CE Redisplays the current command line.
CTRL w0 Temporarily halts video output. Press the
space bar to resume output.
ENTER Performs a carriage return or executes the
current command line.

1-7