0% found this document useful (0 votes)
126 views94 pages

Commodore 16 Manual 1984

The document is the user manual for the Commodore 16 computer. It contains 7 chapters that cover setting up the computer, using the keyboard, software basics, performing calculations and graphics, sound and music, the BASIC programming language, and additional reference materials. The manual describes unpacking the computer, identifying the switches and ports, setting up the system, and troubleshooting issues. It provides instructions for basic use and an encyclopedia of BASIC commands, statements, functions and variables.

Uploaded by

Sergio Llanes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views94 pages

Commodore 16 Manual 1984

The document is the user manual for the Commodore 16 computer. It contains 7 chapters that cover setting up the computer, using the keyboard, software basics, performing calculations and graphics, sound and music, the BASIC programming language, and additional reference materials. The manual describes unpacking the computer, identifying the switches and ports, setting up the system, and troubleshooting issues. It provides instructions for basic use and an encyclopedia of BASIC commands, statements, functions and variables.

Uploaded by

Sergio Llanes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

i i

Cz commodore ig

i
; USER MANUAL
»:

Mh '

ninni nioivFI (
I -.1 l<! I «

Ml rights rest rvptl


No pan ul tiii" manual-may be duplicated,
cop i
insmhtctlorrcproduccd many
formal by any mciimwithoul piioi
Wfttdft permission of C.'F.l.

fS commodore £z commodore
I HHnK'R.Ruwt.\\vlil.iii.( orliY.NoriluHf.NNI7 IU\
COMMODORE 16
USER MANUAL
TABLE OF CONTENTS
CHAPTER 1 Selling Up 5
CHAPTER 2 The Keyboard 1 7
CHAPTERS Software 29
CHAPTER 4 The First Steps 41
CHAPTER 5 Numbers and Calculations 53
CHAPTER 6 Graphics and Colour. ..... 63
CHAPTER 7 Sound and Music B3

BASIC 3.5 ENCYCLOPEDIA 93


Commands gg
Copyloitl (C» '964 by Commodore Electronics Limited
.

All rights 'eservec


Statements 109
Fjnctlons 143
Variables and Operators ... 152
Tils manua eorfaino copv'lQhtea and proprietory into'matton
Abbreviation and Reference Chan 157
No pm! be reproduced stored in a
ol lite imliicaiion T\ay
reHleval system, or transmitted in any torm 01 by ary means,
electronic, mechanical, photocopytnp,, roco'dmg 01 otherwise, APPENDICES .161
without the prior written permission of Commodore Error Messages 1 62
0ectn)nM3 UmllM Disk Error Messages . 166
Deriving Matnamatlcai Functions 1 72
Commodore BASIC Musical Note Table 73
v 35 1

Copyflhl (c) 1984 by Commodore Electron.cs Umtiod Screen Display Codes ,


... .178
a" Ignis reserved
i
ASCII and CHRS Codes 178
Copyr-gfii (c; 1977 by Microsoft, aJI lights rese'ved
Booklist tag

INDEX ....... 1
IB'
I

I
CHAPTER 1
SETTING
I

I
UP
Unpacking your Commodore 1

Getting to know the switches and sockets


I

Setting up your Commodore 16


I

Troubleshooting chart
I

• Peripherals
I

t
I

I
6 6
1
r r

UNPACKING YOUR COMMODORE 16 GETTING TO KNOW THE SWITCHES AND SOCKETS


Now you've opened lie box containing your new Commodore
ihat 1
and found this manual, the hrsl ihing lhat you should do is check to
make sure that you have all the Items on this list. You should have
(

1 Your Commodore 1

The Right Side Of Your Commodore 16


2 The power supply
THE ON/OFF SWITCH
3 The TV cable Your Commodore 1 6 should be turned OFF when you install or remove
cartridges or any peripheral device such as a printer or Datassette.
A. The user manual (You've probably tound this, since There is a red power located above the keyboard on the right,
light
you're reading il rlgnt now.) which lights up when power is on.

5. Olher assorted literature:


THE JOYSTICK SOCKETS
Warranty card You can plug joysticks Into these sockets, labelled JOY *1 and JOY
02. The Commooore 1 6 uses specially designed joysticks available
Irom your Commodore dealer.
It you don't find ailthese items in the box. check with your dealer
immediately for replacements. THE RESET BUTTON
Press the reset button when you want lo '*start over." as if you'd just
turned your computer on The reset button clears the screen and erases
Betore you connect anything, you should overtook these pictures of
any BASIC programs that were typed m. There are other ways lo reset
your computer. You can familiarize yourself with all trie outlets ana I

your computer without erasing programs. These will be discussed in


switches, so you can set up your computer system quickly and easily
Chapter 4.

6 I
1

THE POWER SOCKET THE VIDEO SOCKET


The end ol the power supply cable Ills inhere Plug the other end into a
This where you plug in Ihe cable thai connects a monitor to your
Is

standard electrical wall socket AFTER connecting the first end into your
Commodore 16. If you hook up your computer to a television set. you
won't need to use this.
computer.

THE SERIAL SOCKET


You can plug a disk drive or a printer info this socket. If you want to
plug in both, first plug the disk drive into this opening, and then plug the
printer cable into the back of the disk drive.

THE CASSETTE PORT


The Commodore 531 Datassette
1 tape recorder for cassette tape
software plugs In here.

SETTING UP FOR COMMODORE 16


Connecting your Commodore 1 6 is simple. You only need to do
two things:

1 Plug in Ihe POWER SUPPLY on the right side of your computer and
then into a wait plug.

2 Connect Ihe TV cable (Ihe thin black one) from Ihe aerial socket on
your TV to Ihe RF SOCKET on the back ol your computer

Make sure that you have enough eiectncal wall outlets to plug
The Back Of Your Computer everything in near where you decide to set up your computer. You may
need a power strip or extension cord for more outlets, especially If
you're also hooking up a printer or a disk drive. Remember that the
THE MEMORY EXPANSION PORT power on everything (computer, TV, etc.) should be turned OFF until
Commodore 16 software cartridges plug in here. Before you insert or you are completely set up and ready lo go.
remove cartridges, make sure the power is OFF

THE RF JACK
1: Connecting The Power Supply
This where you plug in one end of the TV cable (the thin black cable).
is

Only one end fits into this lack; the other end fits Into the TV serial
• FIRST plug Ihe round end of the POWER SUPPLY into the power
socket.
jack on me right side ol your computer.

THE HIGH/LOW SWITCH


This switch controls which television channel your Commodore 1 6 is
• THEN plug Ihe other end into an electrical socket on the wall.
on. This is primarily used for American TVs.

I
9
8
'

Connecting Your Commodore 16 To A Monitor


Ifyou're connecting your computer to a monitor Instead ot a TV, follow
the instructions m Ihe manual that is included with the monitor. Hooking
'
up a monitor tike the Commodore 1 702 Colour Monitor is simple. You
need to connect only one cable which goes directly from your monitor
to the VIDEO socket on Ihe back of your compuler

Finally . . .

Now it's time lo turn on your compuler (If you've been paying attention,

you should know where the POWER switch is by now.)

It wen| well, the red POWER


all light goes on, and this message
appears on your screen

COMMODORE BASIC V3 5 12277 BYTES FREE


READY.
2: Plugging In The TV Cable

• Plug ore end of the TV cable (only one will fit) mlo Ihe serial socket The flashing cursor unoer ihe READY message you that your
tells
on your TV Commodo'e 6 1 is wailing lor you lo start typing The background
colour is white, while Ihe letters are printed In black, with a light purple
• P'ug Ihe other end or me cable Into the RF fack on the back of your i
border around the screen
computer

If all didn't go well, the Troubleshooting Cnarl should come m handy

TROUBLESHOOTING CHART
Symptom Cause Remedy

Indicator light nol Computer not turned Make sure power switch is

ON' ON in ON posilion
Power cable not Check power socket tor
plugged in loose or disconnected
power cable

Power supply not Check connection with wall


plugged in outlet

Bad fuse m computer Take system lo authorised


dealer for replacement of
fuse

10 I
11
Symptom Cause Remedy Peripherals give you the capability to save and store data, print out
what appears onscreen (in black and white or colour), use software
No picture TV cable nol Check TV cable connection programs that are stored on cassette tape and tioppy diskelte. and give
plugged In you a sharp, clear picture of your computer's display.
TV nol on Turn TV on
Jom patlern on Cartridge nol Reinsert cartridge after
TV with cartridge properly inserted turning OFF powet
in place

Picture without Poorly tuned TV Retime TV


colour

TV nol connected Cneck connections


property

Colour sei too low Adjust colour setting


on TV or computer

Picture OK, but no TV volume loo low Adjust volume ol TV


sound

Poorly tuned TV Retune TV

IMPORTANT: Some TV sets cannot display me entire Commodore


1 6 screen. Instead, their picture cuts oil the lar left and lar right
column o( the screen. We recommend using a different TV set or a
monitor such as the Commodore 1 702, 1 802 or t 803 colour
monitor

It you can deal with the problem by pressing the


this isn't possible,
ESC key, followed by the R' key. This reduces the computer screen
display size lo 38 columns, so thai the entire picture can III
onscreen. You must repeat this each time you power up or reset
your computer

PERIPHERALS (

Peripherals are Ihe accessories that you can get to go with your
To save or recall programs, you'll need a device lhai stores data I
lata
Commodore 16 that increase what you can do with your computer can be recorded on and retrieved from both cassette tapes and
These accessories are available al your Commodore dealer, and allow r To use cassette tape software (and to record your own
diskettes.
you to use your computer lo the fullest. programs on cassettes), you'll need the Commodore 1 531.

12 \ \ 13
I

DATASSETTE lape recorder For diskettes, Ihere are several DISK When us»ng a wordprocesslng program or a graphics package on your
DRIVES Disk drives are typically fast and efficient lo
that are suitable. )
Commodore 16. a printer will reproduce what is on the screen on
use Disk drives that are compatible with your Commodore 1 6 are the paper Tnere are several models of Commodore printers available that
Commodore models 1 541 and 1 551 1 work with your computer These include the MPS-801 MPS-802, MPS-
,

803 (with optional tractor-teed), and DPS-1 101 (letter quality)


f

Your television set may not give you as clear a picture as you'd like for
your computer Commodore colour monitors are specially designed lo
give you the sharpest, brightest picture for viewing your Commodore
1
6 output There are several models available. Including the
Commodore 1 702, 1 802 and 803.1

14 15
CHAPTER 2
THE KEYBOARD
• A tour of the keyboard
I

• Special keys
! (

• Graphic keys
J I

• Function keys
J I

• The HELP key


1 f

! f

:
I

I I

! f

I I

J I

1 I

J I

I f

( 1

16 17
1

:
I

A TOUR OF THE KEYBOARD Special Keys


I

Several keys on your Commodore 16 keyboard behave quite differently


than any well brought-up typewriter key would even think of acting.
I I

These keys act lo enable other keys lo do things they wouldn't


ordinarily do. or perform luncllons related lo Ihe business of computing.
1

) (

Your Commodore 1 6 keyboard also conlains special symbols not found


I
i
I on many typewriters, or even on most computers. These special
symbols include me pound sign ( £ ), pi ( rr ). greaier and less than
signs ( brackets < [ ), and arrows f
< > > | t )—These special
symbols keys are often used in writing programs on your Commodore
16.
I I f

Mosl ol the keys on your Commodore 16 keyboard are identical lo Ihe


RETURN
keys on a typewriter, but each key can do more than a typewriter key
In this section, you'll learn how to use special keys like the <K key and You nave press Ihe BETtraM key at the end of each line of
lo
the four separate cursor keys. This section will show you the extra I instructions you enter on your Commodore 16 keyboard You might
features ol every key. including how to use the graphic symbols think of this key as an ENTER key because WORK
actually enters
pictured on the fronts of many ol me keys With each explanation of information and Instructions into your computer
Ihe different keys on your computer keyboard, you should find the keys
r
ana pracfice using them.
Using Your Keyboard Like a Typewriter You've already come across an example of me SHIFT Key in aclion In
When you ftrsl on your computer, they appear as capitals
type letters
i using your keyboard like a typewrite That is typical ol the «BWT key
it is always used to modify what other keys
print onscreen, but can't do
on the screen The letters and numbers appear on the screen exactly
anything by Itself (Always the bridesmaid, never the bride The
as they appear on the face of Ihe key when you press the key by itself. i
)

symbols,
Also, several olher keys {+. -. ,
@. *, and E ) may be typed shift key allows you lo type capita! letters, graphic
alone. Most punctuation marks need lo be typed with Ihe shift Key If punctuation marks, and a few olher things— with a little help from
you want to do some "regular" typing, you can type in capital and another key You'll be seeing more of Ihe SOFT key's functions

lowercase letters {like you would on a typewriter) by pressing the Ihroughout Ihis section, for things such as getting graphic symbols
I

shift key and the O


-,ey at the same time. After you do this, all
Tne shift lock key ig the same as the shift key. except lhal ll is
etter k eys typed alone are printed in lowercase. When you press the
locked into place, so you don't have lo hold it down. When
l
1 1
i

start key along with a letter, you get a capital letter. Numbers and
SHFT LOCK is on, every character you type Is SHIFTED. To release
punctuation keys work the same as they would in regular (non-typing) is back
i ;
the lock, |ust press SHIFT lock again, and everything you type
mode To gel out of typing mode, just press the two keys shift and i

to normal
C* ) together again.
I
i

KEY + KEY = RUN/STOP


I Press mis key lo break Into a running program to STOP what your
ENTER OR EXIT TYPING
Commodore 1 6 Is doing When your computer Is running a program,
MODE pressing this key gets you back in control of Ihe keyboard
i

SHIFT
+ A = A When you hold down me SHIFT and roh/stop keys simultaneously.
+ A - r —Ebb\ 1
Ihe Commodore 16 loads and runs the first program on a disk in the
disk drive.
1 i

18 S 1 I
19
The Cursor Keys KEY + EFFECT
I
INST/DEL DELETE (ERASE
TYPED
SHIFT
CHARACTERS)

(§@R I
v
'
SHIFT

CLEAR HOME
iKST/DEL INSERT (ADD
SPACES)

The cursor, the (lashing block thai marks where you are on the This key serves two primary functions: HOME and CLEAR. When you
computer screen, can be moved quickly and eas>ly around the screen press this key alone, the cursor immediately moves to the top left
by using the CURSOR KEYS. There are four separate cursor keys, coiner of the screen (which Is known as the HOME position). The resf
each with an arrow pointing out the direction the key moves the cursor of your screen stays Ihe same. If you hold down the SHOT key and
up, down, ielt. or right. You can use the cursor keys lo move the press clem/home not only does Ihe cursor move lo HOME, but
,

cursor over anything on the screen without affecting those characters. everything on Ihe screen is erased (or cleared). All that remains on the
Like all keys on the Commodore 1 6 keyboard, each cursor key can screen is Ihe blinking cursor at the top left corner of the screen.
automatically repeal. Ttvs means mat if you continually hold the key
down, the cursor continuously moves In the direction of the key you're
pressing (saving you from having to perform the tabled "rapid-fire key- EFFECT
KEY
press").
CLEAR /ROME HOME POSITION
CLEAR-HOME SHIFT CLEAR SCREEN
INST /DEL
SHIFT i -CLEAR
HOME
You can INSERT and DELETE
typing with thts key. When you
letters
press
and numbers from Ihe
(his key by the typed
itsell,
line you are cnit (Control) \
characler immediately to the left of the cursor disappears, and the
cursor moves over to where the missing characler was You can use
the cursor keys to go back to the middle of a line and then use DEL to The cm key is like theSHOT *oy in that always works wiih another
it

erase a letter. When you do this, the letter to the left is deleted, and the key. You must hold it down while you press other keys. CTBL is used
in three instances.
rest of the letters on Ihe line move over one space to the left to close
the gap. I i) As the COLOUR KEYS section explains, pressing CTBL and a
colour key lels you change the colour of the texl printed on Ihe
screen.
To open up space lo insert letters and numbers, type this key along You can pause a program thai is PRINTing or LISTing on Ihe screen
2)
with SHOT Space opens to the right of the cursor; the cursor tiself
f
by pressing CTBl and Ihe S key
does not move When you insert space In the middle of a line of letters. (To re-slart the program, press any key except bun/stop )

Ihe rest of the line moves lo the right


3) CTBL is used with reverse on/off and flash on/off
also
Tnese are explained later In this section
The ART/DEL «ey saves a lot of time when you want lo edit or change I In addition, some software programs that you buy make use of the
what you've lyped CTBL key for their own special functions.
'
(

2C I
21
I

I I I

(COMMODORE KEY) FLASH ON FLASH OFF


I
The Commodore Key Is very similar lo ,
and can be used fo You can make on your screen flash on and off
the characters
perform lour functions; continuously, like the cursor Hashes. Press ctbl and the flash oh
f
key to make whatever you type flash. Typing ctbl and flash off
of RETUmi esc ,nd O makes your typing normal (non-flashing)
1) When used wllh the shut O
key lets you got into typing
hey. Ihe 1

(
again.
>i

mode, where you can use both upper- and lowercase letters.
2) The O
key always acts as a shift lo let you type the graphic
symbol pictured on the LEFT tronl ot each key. Just hold down <J KEY - EFFECT
and press the graphic key you want
3) The O
key is used like the erst key lo cnange the colour ot whal
you type onscreen when pressed with a COLOUR KEY. CTBL + FLASH ON CHARACTERS
4) When you want to slow down a scrolling d-splay (a program thai I FLASH
appears line-by-ilne on the screen but might be going by too fast to
CTRL
follow), hold down the O
key. The display scrolling speed slows
down considerably When you release (he key, it goes back to
normal speed (Hey. the Jfc key can do something by itselfl)

CTRL + rUUBOFF NORMAL DISPLAY


hvs on fivs OIT (Reverse On/OH)
CTRL— 1
- OFF
Your Commodore 6 lets you print the reverse image of letters and
1
(Escape)
numbers. In other words, if your cursor is black and the screen
i
background is yellow, what you tyoe appears in yellow letters on a
black background.
The ESC key you perform many special screen editing functions,
lets
including functions to set up and manipulate screen windows.
Here's all you do lo get reversed images. Press the ctbl key and the
I

Windowing Is a special properly of your Commodore 1 6. which lots you


ivsoh key E ^erythlng you type ;>; now. displayed In revQRMh unM set apart an area of Ihe screen that may be used as work space wttnoul
you press the cm
and bts oft the hetuhn key. or the Etc key affecting the rest of Ihe screen. The ESC key can perlorm several
and O This returns you to typing normal (non-reversed) characters window editing functions, as well as many other regular uses, such as
Inserting, deleting, and scrolling All the functions of the ESC key will
be listed and explained when reviewing screen windows in Chapler A.
KEY EFFECT

RVSOK REVERSE PRINTING Colour Keys


ON
CTRL - Est \

CTRL HVS QFF - NORMAL PRINTING


w
CTRL -E-OFF \
(
The colour keys bear a
to 8. When pressed
striking resemblance lo Ihe number keys from 1
wllh either the ctbl or the C> key. they change
ihe screen colour of everything you type. Your Commodore 16 starts
oul with a white background and a blue border, wilh the cursor

22
23
> !

Hashing black. When you lype anything. Ihe characters appear in Graphic Keys
black. To changeIhe cursor {and what you type) to a different colour,
use Ihe colour keys On the Ironl ol the keys numbered from i to 8. Each letler key (and a tew other symbol keys) on your Commodore 1
there are two colours written Press cm along with a number key to ( ! I has two boxes on the front of the key. each wrth a different tine,
get the colour fisted on top. at the O key with a number to get the squiggle, Of symbol These are the graphic keys. When first turned on,
colour on the bottom You can change only the colour of the your Commodore 1 6 prints capital letters. When you type one of these
characters using the colour keys. To change the screen background or -•.'v ! 'j -villi the SHIFT or
i
.i ©
key. you type the graphic symbols
border colour, you must use a BASIC command (More on that later.) shown on the front of Ihe key on the screen. You can type the full set
ol more than 60 graphics you see on the fronts of many of the keys

NOTE: When changing colours be careful that you do not press the
number (colour) key even a split second belore pressing cm or KEY EFFECT
O you do, all you'll do is print a number on the screen rather
II
+ A - (GRAPHIC ON RIGHT
than change the colour f
SIDE OF KEY)
+ A = r (GRAPHIC ON LEFT SIDE
OF KEY)
SHIFT
KEY + EFFECT KEY + [ (

You can create pictures, charts, and designs by printing graphics side

CTHl + 1 * BLACK + 1 = ORANGE by side or on top ol each other, like building blocks. You can make
your graphics more interesting by using the colour keys to "draw" In
different colours T-y printing with some ol Ihe graphics keys to see
crtC + 2 = WHITE Cf + 2 - BROWN how they work. Cnapler 6 explains more about graphics.
I

When you're in typing mode, you can only use the graphic symbols on
CTRL f 3 = RED 3 = YEUOW GREEN the left front ol Ihe keys (by pressing & and the appropnate key) The
left side graphics are ideal for creating charts, graphs, and business
+ - CYAN forms,
CTHL 1 + 4 = PINK

+ 5 = PURPLE + 5 = BLUE GREEN I

1
1

+ 6 = GREEN C« + 6 - LIGHT BLUE


1 1

CTRL + 7 = BLUE O + 7 = DARK BLUE


1
f

+ 8 - YELLOW © + 8 - LIGHT GREEN I 1

1 r

1
1 i

24 1 1
l 25
! \

Function Keys the keys (rom BASIC programs,


change them al aiy time in direct
or

I I
f
mode A situation where you might want to redefine a (unction key Is
when you use a command frequently, and want to save time Instead of
repealedly typing in the command. Tne new definitions are erased
£ I | I

when you turn off your computer You can redefine as many keys as
f 1 Tne keys on the righi side ol
lour
you want and as many times as you want
your keyboard {apart Itom the I
f 4 \ resl ol Ihe keys) are special
function keys ifiat let you save I i
( The Help Key
f 2 time by performing repelitlve
(asks with the stroke of jus! one
f 5 \ key. The top of each key reads
HELP
fl 12. t3. and HELP You can
f 3
,
ji
gel these functions by just
I f] pressing the key by itself. The
17 \
f 16 keys read 14. 15. te
fronts ol Ihe
and f? Press shift and f; f2.
I HELP
,

f3 and HELP, respectively, to gel


When you make an error in a program, your computer displays an error
i

message to you whal you did wrong These error messages are
tell

,7 -1 Ihese (unctions
further explained in the Appendices In Ihe back of this manual
V i

You can gel more assistance with errors by using Ihe HELP key Alter
I
an message, press HELP lo locale your error exaclly. When you
error
Here's what each key does
press HELP, the line with the error is displayed on the screen with the
error flashing on and off For example

KEY1 one of the GRAPHICS modes when you supply Ihe


enters
number ol the grapnlcs area ana press itntmN The I ?SYNTAX ERROR M UNE 10 Your compuler displays this

GRAPHICS command is necessary for giving graphics HELP You press HELP
commands such as CIRCLE or PAINT More on GRAPHICS in ( 10 PRONT "COMMODORE
Chapter 6 COMPUTERS" The mistake ts displayed (lashing
KEY 2 prints DLOAD" on me screen you do
All Is enter the program i
on and oil
name to load a program from disk and hfl BETUM instead of
lyptng oul DLOAD" yourself. i
i

KEY 3 lists a DIRECTORY of files on Ihe disk In the disk drive.


KEY 4 clears the screen using Ihe SCNCLR command.
KEY 5 prints DSAVE" on Ihe screen All you do Isenter the program
name to save Ihe current program on disk and press httuum
i
KEY 6 RUNs the current program
KEY 7 displays a LISTing of the current program.
KEYS (Ihe HELP key) highlights errors In program statements In
i i

Hashing prml
I ! (

You can redefine any ol these keys to perform a (unction mat suils your
needs Redetinlng is easy, using Ihe KEY command. You can redefine

26 :
i 27
I

I
(

I
CHAPTER 3
I f
SOFTWARE
(
Introduction
I
I

• Cartridges
!

Cassettes
I

Diskettes
I
I

I (

r i

i
I

I I

I (

I I

I I

I I

I (

I I

2B
( I 29
i

INTRODUCTION
i

A computer without software is like a glass wtir>oul orange juice. Weil,


maybe not, but software does add to the usefulness of your computer f
and the and diversion it affords you. Software is ail the programs
fun
that can be entered and run on a computer. The hardware (In this case, i i

your Commodore 1 6) can use software m many forms: plug-in


cartridges, pre-recorded tapes and diskettes. The family of software I ! ( CARTRIDGE SLOT
Commodore 16 is growing quickly Your cealer can
available tor your
keep you up-lo-date on new products and inform you aboul tne features
I

of software that's currently available. CASSETTES


I
Your Commodore 16 can use software on CARTRIDGE, CASSETTE I

TAPE, and DISKETTE form, available Irom your Commodore dealer. All
you do is load them Into your Commodore 16. You can also create and I I

store your own programs on cassette tapes or floppy disks.

I I

CARTRIDGES
I I

Commodore produces a full assortment of cartridge soltware for your


Commodore 1 6. There is a variety of personal, education, and I
'
business programs, as well as exciting games available lor your
Commodore 6. You don't need any additional equipment to use
1 '
I
cartridge software; you do is plug tne cartridge Into tne back of your
all

computer and power on Here are the steps to follow to use cartridges •

I
Loading Cartridges I

A variety of software lor the Commodore 1 6 is available on cassette


STEP 1 Turn OFF your Commodore 1 6. I
I
tape Those cassette tapes are similar to the music cassettes that you
play on your tape deck or stereo. Software on lape works in the same
I I fashion as cartridge software, but you have lo have an additional piece
IMPORTANT: YOU MUST TURN OFF YOUR COMPUTER BEFORE
of equipment (called a peripheral) to load cassette software into your
YOU INSERT OR REMOVE CARTRIDGES. IF YOU DON'T, YOU
f computer To use cassettes, you need a Datassette tape recorder,
MAY DAMAGE THE CARTRIDGE AND THE COMPUTER I

available Irom your Commodore dealer.


I
I You can also use cassette tapes and the Datassette programs
lo slore
STEP 2 Hold the cartridge with the label facing UP. and insert the
you write yourself The next section explains how to save programs on
cartridge firmly in the cartridge slol (labelled 'memory I I tape
expansion') in tne back of your computer.

I I

STEP 3 Turn ON your Commodore 1

STEP A Begin tne game or program according to the instructions thai I (

come with the software.


t

I 31
I

The steps a program on cassene tape are the same,


for loading STEP 1 If the program you want is called "BASES", you would type
whether you're using pre-recorded software or programs you saved
yourself.
LOAD "BASES"
and press return
Loading Cassette Tapes
Your computer responds with:

STEP 1 Insert the cassette into your Dalassette and close the door PRESS PLAY ON TAPE
f }

STEP 2 Rewind the tape to the beginning by pressing the REWIND


STEP 2 Press the PLAY button on your Datassette to get your
button on the Datassette
computer to start looking After soarchmg on the tape for the
STEP 3 Press STOP when the tape is rewound to the beginning, type program called BASES, the message should appear
LOAD and press the MlUM key. The computer responds
with the following message; FOUND BASES
:;, LOADING
PRESS PLAY ON TAPE 1

The screen goes blank while your computer then "reads' the program
into its memory. If the entire tape goes by without the FOUND
STEP 4 Press the PLAY button on the Datassette The screen goes
blank as me Datassette starts When a program is found, the I f message, rewind the tape and try again. Once your computer has
digested the entire program, your Commodore i 6 tells you;
screen displays this message:
I I
READY.
SEARCHING I I

STEP 3 At the cursor, you instruct it to


FOUND program name I !

RUN
STEP 5 Press the Commodore key C
to load the program that was f I

and press retton At this point, your Commodore 6 1 runs


FOUND. there is more than one program on the tape, and the
If
(executes) the program "BASES",
program your Commodore 16 found isn't the one you want, do ! f

nothing Your computer will continue searching alter a brlel


interval. 1 I

When the program Is loaded, the word READY appears if you want to Saving Programs on Cassette Tape
I
stop the loading before it's complete, press hun'STC* on the
keyboard and then the STOP button on the Datassette. After the When you a program yourself and you want to keep for later use
write it

software is 'Oaoed. type RUN to start the program. You can also LIST f
or modification, you can SAVE that program When you SAVE a
the program or change it. if it is a BASIC program. program, you are in effect recording on a form of software (tape or
it

I ( disk) that allows you to recall the program so you can RUN It. make

Loading A Specific Program changes, etc When you want to save a program on cassette tape,
follow these sleps

To LOAD a specific program on the tape, use the LOAD "program STEP! Type
I f
nBrne" form of the LOAD command. The instructions are the same as
typing LOAD with no name, with just a few differences SAVE "program name"
r f

32 t i
33
cassettes, you only have and type the
to put the disk Into the disk drive
The program name you use can be anything you want, bul can
commands to LOAD or SAVE programs; there are no buttons to push
be no more than 16 letters and/or numbers long
There are a couple ot small lights on me front o( the disk drive. The
STEP 2 Press the key The computet displays this message: green light ts the power light, telling you whether the disk drive is turned
on or oh*. The red light letts you two things. During normal disk drive
use. when a program is being LOADed or SAVEd, It is Ht while the disk
PRESS PLAY & RECORD ON TAPE is spinning in the drive If there is a problem with the diskette or drive,

the red light flashes on and oft. even after the disk stops spinning in the
STEP 3 Press the RECORD and PLAY buttons on your Datassetto. The drive.
screen goes blank. When your program Is saved, the word
READY appears on the screen.
Loading Programs From Diskette
Examples ot SAVE Commands lor Cassette Tape:
STEP 1 Make sure that your disk drive is pluggea >n and the serial

cable Is connected Then turn the power ON.


SAVE "THE DAY" This name is the specific name
SAVE "YOURSELF" of the program being saved STEP 2 Insert the disk Into Ihe disk drive. The label side ot Ihe disk
must tace up. Insert the disk into the opening so that the
labelled end goes in last. Look lor a little notch on the side ot
NOTE: When saving a program onto a cassette tape, always be the disk (It might be covered with a sticker). This notch should
aware of where the tape is positioned. be to your left as you put in the disk, assuming that you're
facing your disk drive. Be sure the disk is In all the way.

DISKETTES

DIsks are last ana easy !o use. Be sure to handle your disks and your
disk drive carefully Disks may be referred to as diskettes, floppy disks,
or floppies interchangeably, they are all the same thing Unlike

34
[1 1

STEP 3 Close the protective "door" on the disk drive afler you insert
IMPORTANT: DO NOT HEADER A DISK THAT HAS ANYTHING ON
the disk. 1 1 1
ITUNLESS YOU WANT TO ERASE THE ENTIRE DISK. HEADERING
ERASES EVERYTHING ALREADY ON A DISK,
STEP 4 Type: 1 1 1

DLOAD "program name ol


Specific the program 10
name" be LOADed
1 !
1
Tt\e lormat for the HEADER command Is

( ) 1
HEADER 'disk name" l,Udevice#]|,Iid.#],Ddhve#

(To save lime, you could press FUNCTION KEY 2 and the
• The name you use is the name of the entire disk. Give the disk any
type in
program name ana the second quote marks.)
'
! 1 name up to 16 characters.
• Udevice # specifies which peripheral device number (which disk
'
drive unit), and defaults lo 8 (primary disk drive).
STEP 5 Press the return key The disk spins and your screen says:
rji • The id. the letter I and any two letters and/ or numbers, like 12 1.
is
SEARCHING FOR program name IR5, etc Give the disk any id. you want, but you should give every
FOUND program name disk a different d to avoid contusion. (Note: the firsl characler
I

LOADING must not be F).

READY.
i i • II you have a dual drive fa disk drive with two slots tor disks), you
should specify Ihe drive number with a Drive number is
- cursor
ALWAYS included in the command,
or 1 .

even wilh a single drive (DO).


i
i

STEP 6 Your software is now ready lo use. Type RUN and press the 1 1 !
ARE YOU SURE?
As soon as you press
^^^
return alter typing the HEADER command,
return Key io start ihe program.
i
your Commodore 1 6 asks ARE YOU SURE? This is to give you s last
(
DLOAD is finished,
1

If on the disk drive


the red light blinks afler the chance to change your mind. If you want to go ahead and header the
something weni wrong. Type: disk, lype YES or Y and press RETUJUT If you decide not lo header the
lype NO or N and press RETURN
(
disk,
?DSS (and nil BETURN )

f
Here are some examples of HEADER commands.
to find oul what went wrong. 1

1
HEADER "LETTERS",I07,D1
Examples of DLOAD commands: HEADER "FINANCES", U8.IS3, DO
(
DLOAD "•" LOADs the 1st program on the disk
DLOAD "FILES" LOADs a disk program called FILES.
NOTE: If you want to erase all files on a disk (as opposed to
I

DLOAD "SOF*"
1

LOADs Ihe first program on Ihe disk that


formatting a blank disk), use the HEADER command without an i.d
begins with the letters SOF.
' I number This in effect scratches (erases) alt the files that were on
.

Inai disk.

Headering A Diskette 1

Headering prepares a new BLANK disk for use Any blank disk must 1 1 Now that you know how to HEADER a disk, you're ready lo use disks lo
be formafted before it may be used, by using ihe HEADER command. write and save programs on your Commodore 6 (of any olher 1

1 1

1 37
'

i
I

1 1

Commodore BASIC Encyclopedia In the back


computer). The of Ihls
The Directory Command
manual has more Information about the HEADER command. 1

When you SAVE programs on disk, the computer keeps a listing of all

Saving Programs on Diskette the saved


flies on ihat disk. You can display the listing as a table of
1
contents to see what's on a disk by using the directory command
1

When you want lo reuse a program you've written, be sure to SAVE it 1


1
Type;
before you LOAD anolher program or turn otl the Commodore 16. K
you don't, you'll lose the program 1
(
DIRECTORY then press HETUHH
FUNCTION KEY 3)
(or ptess

SAVE
1

When you change a SAVEd program, you have to it again it you 1

want to keep the new version


As soon as you press return your Commodore 1 6 displays
everything on your disk.
I

When you reSAVE a program, you are replacing the old version with You can also display just part of the table of contents:
the new one. If you want to keep both the old and the changed
versions, you have lo give the new one a different name when you
I

DIRECTORY "MY"" Lists every tile on Ihe


SAVE it. disk that starts with the
I I

tetters MY.
Follow these steps to save a program on disk: DIRECTORY "'^PRG" Lists every program file.
I
DIRECTORY "«=SEQ" Lists every sequential file.

STEP 1 Type DSAVE "program name I (

STEP 2 Press return Tne computer displays this message when


the program is saved: ( (

SAVING 0: "program name" I 1

READY.
I 1

( 1

Example

DSAVE "MYPROGS" The program name can be 1 (

up lo 1 6 characters long
1
f
It the red light on the disk drive blinks after the DSAVE is finished,

something went wrong Type- '

?DSS (and "it BBTUHN 1 1

1 (
to learn what went wrong.

If you try lo SAVE a program on a write-protected disk (a disk thai does 1 (

not accept your output} you must turn the drive OFF, then ON again
( 1

I 98
I (

I f

I [

CHAPTER 4
THE
FIRST
i (
STEPS
Introduction
i
i

The screen display


i r

Reverse printing and changing colours


( i

• The first step

i • Correcting mistakes
f

)
• Screen windows

i r

i i

40 41
i

Reverse Printing and Changing Colours


INTRODUCTION I

Not only can you change Ihe colour of the cursor and characlers you
The purpose ol this chapter is to begin to acquaint you wilh some of the type (and your computer displays) on your monitor screen, you can
r
characteristics and capabilities of your and how
Commodore 16, to also reverse the character and background colours. That means that If
take the first steps toward programming with your computer you have Wack characters on a while background and you turn reverse
i
printing on (by typing coo, and 91 everything that appears on the
The Screen Display screen is reversed: Ihe characlers are in white, while the background
I behind those characters is black. You can experiment with changing
the character colour and using reverse printing, by following these
i
instructions'

STEP1 Hold down the key and press Ihe bvs on >-.

f
/

I
i CTHL

r
STEP 2 Release the keys and nold down ihe space bar
i
STEP 3 Hold down the space bar as long as you want While you hold
down the space bar. a line the same colour as the letters on
i your sceen should get longer. K Ihe line gels to the end of the
row, tt continues on the next row
Your Commodore comings and goings a'e seen on your TV or
1 6's f
monitor display screen Whatever you type, whatever your computer STEP 4 Release Ihe space bar (but don't press the return key).
has lo say about what you type, whatever programs you load
shows up on your monitor screen, whether you're hooked up to a
all . II
f STEP 5 Hold down the cm
key and press one of the colour keys
(not a colour that's already on your screen) As soon as you
colour or Wack and whtte TV, or a Commodore colour monitor Your
do this, the cursor changes to the colour of Ihe key you
Commodore 1 B screen, no matter what type ot monitor or TV you're [
pressed.
using, is 40 columns wide. That means that you can type 40 characters
trom Ihe left edge of the screen lo the right. There, are 25 rows, so thai r STEP 6 Hold the space bar down again. Now your computer draws a
an entirely filled screen can contain spaces tor 1000 (25 X 40) line in ihe now Keep changing colours wilh the CTtt
colour
characters. The Commodore 1 6's screen display is made up of Ihree r or keys and Ihe colour keys. Then ho'd down the space
elements: the characters (the letters, numbers and graphic symbols), bar to make more different coloured lines,
Ihe background, and the border When you first turn your computer on.
the characters are black, the background is white, and the boroer is
STEP by holding down
7 Turn off reverse prim and pressing the cm
light blue You've already seen how to change the colour of the
bvs off key Pressing ihe return key also turns oh reverse
printing
characlers using the number keys along witn CTRL or
j£t ,n Chapter
2. You can make the characters any of 1 6 different colours in this
fashion. There are a few oiher things you can do to make printing
characters more interesting.

42 i
43
1
I

r f

BRIEF INTERLUDE: You can lype numbers and punctuation


tellers, executes (carries out) that command. GOTO tells your computer to go
rn reversed print. Reverse letters make excellent headlines. You can I i back lo line 10 and execute the command (PRINT "FIRST TRY") Each
also use ihem (o hignltght special words and numbers. You can type time your computer got to line 20. It executed the GOTO command,
graphic symbols in reverse for the same effect To put a racing ! f returning to line 10 again and again This repetition is called a loop.


stripe on your screen, select a colour you like and type (he symbol
fby pressing s&FT and E) across an entire line. Then turn on
reverse printing; fill the next line with the same-symbol. only
i

i
The run/stop key breaks into whatever program the computer is
running, and returns control of the keyboard back to you.

reversed. On Ihe next line, type SHIFT and R (still in reversed print). r i

Then turn off reverse, and fill (he last line with iuft and R (no
TIP: Want lo slow down this program (or any olher) without slopping
longer reversed). Now your screen has a racing stripe In whatever
colour you chose; perhaps is a it humble achervement, but it does
!
it? Just hold down the © key
give your screen a certain flair .
. .

i (

Now type Ihe following, pressing return after each eniry.


I I
THE FIRST STEP
1
NEW This tells the computer to forget
I

What is anyway? An experienced programmer might tell


a program,
the last program and get ready for
you a program is a series of ordered statements organised to direcl
that
a new one.
I I

the computer to perform a sequence of steps toward some purposeful


result What you may learn from this is not to ask an experienced
I
programmer what a program is. The computer responds with the message
'

I
The following, although is only two lines long, qualifies as a program.
it READY You don't type this; this is your
Type it exactly as appears here. Don't leave out the numbers at the
it
computer letting you know that
i r
beginning each line, since they are the line numbers; they tell your
ot It's READY tor new commands or
computer what order to read and perform the lines of the program. Be programs.
sure to press the return key at the end of each tine you type. i i

10 PRINT'FIRST TRY" This line your computer to print the


tells
i

20 GOTO 10
words FIRST TRY on your screen

This line tells your computer to go back to


( ( 10 PRINT * o COMMODORE I
16" Press CfBt and Bvson

line 1 and print FIRST TRY again. i


(
Press and Rvs off

HUN When you and presb return


type this i
r Notice whal happens when you typo RTS ON and IVS OFF inside the
your computer does what each line tells it to quote marks. They appear on the screen as reversed characters. Now
do. i r type RUN and pres; return lo see Ihe program. When the program
is RUN, your Commodore 16 reads these reverse characters as what

Press the run/stop Key to slop Ihe program. i i


you typed In, and carries out Ihe reverse print as instructed The same
principle holds true (a reversed character appearing on the screen as a
Why did your computer print FIRST TRY so many times? PRINT Is a representation for wnat you type) for doing other things in a PRINT
command mat tells your computer to PRINT what appears between the f i
statement, like moving the cursor and changing colours, when you RUN
quote marks on the screen. When your computer reads this line, it
a program.
i t

44 [ i
45
Now try tne same line, bul replace BfS ON and HVS oft with your compulef to execute or into your
for that matter) either for
and FLASH oit (the < and > keys): computer's memory, you must press Ihe heturh key

10 PRINT" I
COMMODORE I" Press CTRL and flash on
1. YOU CAN EDIT A LINE by overtyping.
Press; CTRL and FLASH OFF Use the CURSOR KEYS to move to the place In the line thai you want
lo change Now just type over whal you want to change Press
When you RUN this, it PRINTS oul COMMODORE
16 |ust once. But the when you linistv

word COMMODORE Hashes continuously, even though your program EXAMPLE;


has already been RUN. When you use flashing print, it will (lash
conllnuously Both of Ihese one-line programs show how to use things
like reverse printing and flashing letters in the line of a program You
10 PRINT "IT IS ONE O'CLOCK"
would do other things (change colours, etc.) in the same manner
If you want to change Ihe time lo TWO. move the cursor lo the O In
Entering Commands ONE.
You might have noticed that you typed some things in as just a single
word (such as NEW), while on other lines you had to type in line i :
10 PRINT "IT IS0NE O'CLOCK"
numbers followed by commands and statements within quote marks.
That's because there are two 'modes' that you can use to communicate And now lust type TWO over ONE and press BETUHN
with your computet. Both are based on a language made up of terms
that your computer understands. The most straight-forward (and the 10 PRINT "IT IS TWO O'CLOCK"
one built m to your Commodore 16) is called BASIC. Your Commodore
16 understands a version called Commodore BASIC 3.5 The BASIC
terms (or keywords) are the heart o1 both modes The first type,
IMMEDIATE MODE, tells your computer to execute the BASIC NOTE: When working with numbered program lines you don'l have
command immediately. You enter the command to bo carried out by lobe at the end ot the line lo press return Your Commodore 16
your computer when you press the RETURN key This Is also known as
remembers the whole line even if you press Rrrutw in the middle
DIRECT MODE. The alternate mode is known as PROGRAMMING, or I f
of the line.

INDIRECT MODE Programming mode features line numbers, and


each line contains BASIC commands The entire program is executed
when you type the command RUN. carrying out the commands of the 2. YOU CAN OPEN UP SPACES IN A WORD OR LINE with the
lines according to line number (lowest lines first). Obviously,
programming mode is what you use to write computer programs.
key (press or along with the
mst/del key) Hold the keys
down until you open up as many spaces as you need. (Notice that
the cursor stays in the same place while spaces open up lo the right.)
I

Then just type what you want lo insert

CORRECTING MISTAKES 10 PRINT "CORE"


Mistakes are a way ot life with compulers. Mistakes in programming
must be searched for and remedied for a program to run correctly. To change this to COMMODORE, move tne cursor lo Ihe 'O' and press
That's whai the HELP key is for. A more practical kind ol mistake— the the shift and msT keys until enough space opens up. Don't bother
typing error—can mess up programs just as Dadly. Not only will lo count out the spaces. You can |usi guess and then open up more If
oompuling Improve your typing skills, you'll make great strides in there aren't enough
spotting and correcting typing errors as well There axe several ways lo
fix up typing errors Remember that to enter any changes (or anything, 10 PRINT "C ORE' cursor

46 47
this by typing UST. whichdisplays a ilne-by-line LISTing of your
Now add the other letters'.
program as it stored
is in the computer's memory. When you LIST a
program, all lines appear In correct order and the replaced lines don't
10 PRINT "COMMODORE"
appear

3. YOU CAN ERASE CHARACTERS AND CLOSE UP SPACE with Ihe


DEL Key by pressing the INST/DEL key by itself). This
(gel delete LIST RETURN
key erases characters or spaces immediately to the LEFT ol the The screen reads: 10 COLOR 0,3
cursor. 20 PRINT "COMMODORE 16"

You can see what the COLOR command does In this example. For a
10 PRINT "AFTERNOON SCHEDULE" more complete explanation, see Chapter 6, or look up COLOR in Ihe
BASIC Encyclopedia.
You can change this lo WEEKLY SCHEDULE by moving the cursor to
Replacing lines In a program is also a good way to experiment with
Ihe E in AFTERNOON, pressing Ihe msT/DFZ key three times, and
your computer When you replace a line, the new one doesn't have to
typing WHDO.Y
be anything like Ihe old line. For example, instead ot correcting Ihe
I spelling of COLOR, you can enter this line:
10 PRINT "AFTERNOON SCHEDULE"
and press inst/del three times 10 PRINT'COMMODORE 4 TIMES COMMODORE 4 «^'

10 PRINT "QRNOON SCHEDULE" in WEEKLY to replace


Type \ space
ERNOON ann return (
i

Now RUN the program anc see what happens.

4. YOU CAN RETYPE A LINE anytime, even after you've RUN the pro-
gram Your Commodore 1 6 automatically replaces the old line with
Ihe new one when you press return lo enter the new line. The old 5. YOU CAN ERASE AN UNWANTED LINE just by typing the number
tine still appears on the screen, but your computer ignores it. When of the line and pressing HETuWi The computer ignores the line
you have two statements with the same line number, your Commo- even Ihough still appears on the screen Type UST to get tne pro-
it

dore 1B only uses the last one entered. For example, in a brief pro- gram LISTing to make sure the line is gone from Ihe program.
gram using the COLOR command to change the colour ol the screen
"
background, a mistake might occur: 10PRINT "COMMODORE 4 TIMES COMMODORE 4 -
20 PRINT "COMMODORE 16"
I

10 COKOR 0,3 mistake Now type


20 PRINT "COMMODORE 16"
RETURN
10
Press the etuiui key to gel to a fresh line, and just retype line 10
correctly
UST

10 COLOR 0,3 The result, according to your computer

Now Ihe first line 1 is replaced by the second line 1 0. You can check 20 PRINT "COMMODORE 16"

49
48
CLEARING THE SCREEN SCREEN WINDOWS
I

There will be times when your screen is loo crowded, or you wanl to
reorganize what you've lyped, or you're |ust plain unhappy with what's
on the screen and want to banish it to wherever It is that print goes
I
once leaves the monitor screen. There are a few ways to accomplish
't

this, leaving the programs in your compter's memory intact


or dealing
the memory as well as the screen

One way to clear the screen is lo hold the space bab down, until it

dears the 1000 spaces on the screen a couple minutes or so) It


(tor
you've read this tar tnto the User's Manual, chances are that you have
the patience lo clear the screen like this, but also the intelligence to
realise that there has to be a belter way. Here are
some belter ways:

1. Hod the DOWN CURSOR key f until everything on the screen


scrolls oH the top of the screen.

2. Press the aan and CU/HOMK keys together This clears the Windows let you aefine a specific area of the screen as your
screen and repositions the cursor at the lop left-hand corner, (the workspace. Everything you type (lines you type. USTmgs of programs,
'home position')
etc.) after setting a window appears within the window's boundaries,
3. Type not attecting Ihe screen outside the window area. You can set up a
window anywhere on the screen.
SCNCLR and press return
This Is a BASIC language commanc that your computer Interprets as To set a wmoow, follow these steps
instruction lo clear the screen.
STEP 1 Move Vie cursor to ihe screen position you want as the top
4. Press the RESET BUTTON. This resets the machine, bringing left comer ot the window
Pack
the starling screen and clearing all programs out ot your computer's
STEP 2 Press the ESC key and release tt. and then press T.
memory.
STEP 3 Move the cursor to the position you want to be the bottom
right comer ot the window
if you want lo dear the computer's memory but. not the screen, lype:

NEW and press


STEP 4 Press EK and release, then 'B' Your window Is now set.
returh
This is a BASIC language command that tells the computer
to empty Us
Allscreen output is confined lo Ihe 'box' you have defined To cancel
memory. The 1 6 in the Commodore 1 6 refers to the amount of space the window, press the CLEAR/HOME key twice. The window is then
(I6K) that your computer has to store programs, Known as the memory. erased, and the cursor is positioned in the top let! corner of Ihe screen.
When you clear the screen with any ot the first three methods, you
clear the characters on the screen, but whatever Is in your computer's You can manipulate Ihe window and the text inside using the BC key.
memory stays there This means you have less space for new Screen editing functions, such as Inserting ana deleting text, scrolling,
programs The last two methods erase what Is held In your computer's and changing the size of the window, can be performed by pressing
memory, so that you again have the lull amount of space available lor esc followed by another key. To use a specific function, press the
new programs. appropriate key after pressing

50 51
KEY FUNCTION
A
B

C
D
Automatic insert
Set the bottom right comer of the screen window
(at the current cursor location)
Cancel automatic
Delete current line
insert
CHAPTER 5
1 Insert a line
J
K
Move
Move
to the beginning of the current line
to the end ot the current line
NUMBERS
Turn on scrolling
L
M
N
Turn of) scrolling
Return lo normal screen display size
AND
P
Cancel insert, quote, reverse, and flash modes
Erase everything from the beginning ot the line to the cursor
CALCULATIONS
Erase everything Irom the cursor to the end of the line
R Reduce screen display Introduction
T Set the top left corner of the screen window
V Scroll screen up Numbers and operations
W Scroll screen down
X Cancels the previous Escape function • Calculations

More about screen PRINTing

Variables

Numeric functions

User defined functions

52 53
INTRODUCTION Fractions and Decimals

You don't have lo be a mathematics genius to understano and make You can write a fraction like this 5
use ol the mathematics capabilities ol your Commodore 6. In addition
1
or like this: 1/2 Your computer Is actually
lo the straight-forward operations like addition, subtraction, performing the division
multiplication and division, you can use your computer to figure out
advanced functions like square roots and sines. You'll leaxn about the If you pul a a PRINT statement, your answer
fraction in is always
different types of variables,and how to use them. Your computer can returned as a decimal or whole number For example.
handle single digit whole numbers or complex numbers of up to 38
places expressed m exponential notation with equal efficiency You can PRINT 139/493 + 5 RETURN
do your calculations directly or as part of programs finally, this chapter 5.28194726
gives you a brief explanation of now lo set up your own functions lor
your computer lo evaluate.
THE PI KEY
NUMBERS AND OPERATIONS
Hore's an example that uses pi (3 1 41 59265 J,
which represents
You can use your computer like a simple calculator. Besides tne the ratio ol the circumference ol a circle to its diameter. Use ihis value
standard + and — operalion signs, your Commodore 1 6 uses the •
by Just pressing Ihe 7T key ( and =}:Q
sign for mulllplication and the / sign lor division and fractions.
I

(Computers use the * sign instead ol an X for multiplication because a


computer can't tell the difference between trie letter X and the PRINT TT /37* RETURN
mathematical symbol X.) You can use these operators and numbers In 8.39998C36E-03
Immediate mode (no line numbers) or In program lines. Type In
numbers and operators in PRINT statements WITHOUT QUOTES if you Scientific Notation
want your computer to perform the math involved If the numbers and
operators are in quotes (as in PRINT "2 + 2"), your computer will PRINT What computer mean by the E-03 part of Ihe above answer?
did your
exactly that on the screen, instead of performing tne addition. You can Your computer displays decimal numbers in Ihe range -999,999.999 to
get your computer to put two and two togelher by typing PRINT 2 + 2. 999,999.999 In standard numerals. Numbers beyond this range (with
more than nine digits) are automatically displayed in scientific notation.
BASIC MATHEMATICAL
You can enter numbers in yourself in this form and your computer will
OPERATORS BASIC RELATIONAL OPERATORS read them with no trouble (certainly less trouble than you had
Addition + converting mem!) Scientific notation is often uselul, since this special
Greater ihan > notation lets your computer display targe numbers In lewer digits.
Subtraclion - Less than <
Division and fractions / Equals >
> >"
Multiplication
Exponentiation
(press SHIFT and 0)
*
r
Greater man or equal
Less than or equal
Not equal to
<- or
< >
or

or > <
< Here
notation
is how the number 198.505.478 would be written in scientific

Omy ONE digil is shown to the


I

NOTE: Your computer doesn't accept commas as left of the decimal point
pari ol a number.
For example, you have lo lype 30359 Instead of 30.359. It you put a
comma in a number, your computer thinks you mean two numbers 1 .98505478E + B This number is ihe number of
(separated by Ihe comma), and would read it as 30 and 359 instead
digit places the decimal poini is
of 30359. :

moved
I

54 J
55
Fof a number less than one with several decimal places, Ihe second 10 PRINT "2001/2010="
number would be a - instead ol a +, indicating ihat Ihe decimal point 2001/2010 I
don't forget the semicolon
Is moved lo the right. RUN
For example
2001/2010= .995522388 this space >s left tor the answer's
1984 sign
0003359 - 3.359E - 4 Ihe answer for line 20 stays the

Other examples same

20 = 2E + 1 the decimal point is moved 1 digit left If you want to both PRINT the problem AND solve il you have to type it

105000= 1 05E + 5 the decimal point is moved 5 digits left twice once in quoles and once out ot quotes, as line 1 shows.
.0666 - 6.66E - 2 the decimal point is moved 2 digits right

Order of Calculation
PERFORMING CALCULATIONS
You can perform more than one calculation in one line. Try typing this.

To per'orm a calculation, type PRINT and men the math problem


without quotes, as in the following:
PRINT 200-50+3
10 PRINT 1+2, 2-1 Is the answer whal you expected? Try this:
20 PRINT 2«2, 4/2
RUN PRINT SO+5'200

3 1
Your Commodore 1 6 always performs calculations in a certain order.
Problems are solved from left to right; within thai general rule, some
types of calculations are solved first. The order thai your computer
evaluates expressions is called the order of precedence.
For the first time, PRINT didn't print exactly what you typed In the
statement. Instead, your computer solved the calculations and PRINTed FIRST: Your computer checks for negative numbers (not subtrac-
only tho answers. All you have to do to use PRINT to calcuiato is omit negative numbers).
tion, just

the quotation marks, Now try this: SECOND; Your computer soVes any exponents.
THIRD: Your computer solves all multiplication and division, from left
NEW to right.
10 PRINT "2001/2010" FOURTH. Your computer solves addition and subtraction, from left to
20 PRINT 2001 - 17 right
RUN
2001/2010
11984 one space here
NOTE: Your Commodore 1 6 always solves any pari of the problem
is left lor Ihe
that's surrounded by parentheses first. You can even put
answer's sign
parentheses within parentheses: 36 • (1 2 + (A / 3)). The contents of
the Innermost parentheses are solved first.
Since line 10 Is in quoles, your computer |ust PRINTs the problem as if
itwere regular lext: exactly as it appears between the quotation marks.
Notice that no space is left for the number's sign from line 10, as it is in Sometimes a good idea to oul negative numbers in parentheses lor
it's

the printout for line 20. Now move the cursor back lo line 1 and clarity. For example, if you want to multiply 45 by -5, type II like this:
change the line lo this: 4S*<— 5) Your computer can understand it with or without parentheses.
I

56 57
MORE ABOUT PRINTING ON THE SCREEN print' a" rwro'rD" ;•&","?'

You've probably noticed thai certainprograms had you lype commas In spaces the letters like this on your screen:
certain places, white in others there were semicolons. Your computer COLUMN
1 11 21 3' 40
inlerprets commas and semicolons as instructions lor the spacing of the
ROW 1 A B C D
printout
2 E F

The on the spacing of PRINT statements works the


eflect of punctuation
I

same with spacing ol both text in quotes (called "text strings") and When you use semicolons to separate items In a PRINT statement, your
numbers being calculated Try typing this brief program Commodore 16 ignores the print zones and PRiNTs all the items one
after another;

NEW
10 PRINT "0"."K" PRINT "A";"B";"C";"D";"E";"F"
20 PRINT "O'V'K"
PRINTS ims

Notice that the punctuation appears OUTSIDE ol the quote marks.


ABCDEF
When you RUN the program the screen looks like this:
I
I
O K One 10PRINTed this II the first PRINT item is 1 2 letters long and the second itBm is

OK Hoe 20 PRtNTed th<s separated by a comma, here's what happens:

If 10 and line 20 are nearly Identical, why ts there such a difference


line
PRINT "ABCDEFGHIIKL'V'M"
inwhat they PRINT on the screen? The only difference is due to the I

punctuation between the items this program PRINTS.


PRINTS this;

I
ZONE 1 ZONE 2 ZONE 3
When you use a commaa PRINT statement, the
to separate items in
items are PRINTed several spaces apart When you use a semicolon, ABCDEFGHJJKL M
the items are PRINTed right next to each other,

As you recall, your computer's screen has 40 columns across. These NOTE: Sometimes youli type a particularly long line on your
columns are divided into four 1 space areas, called PRINT ZONES computer, such as this:
When you use a comma to separate PRINTed items, your Commodore
1 6 PRINTS the first item In ihe first print zone, tne second item in the

second print zone. etc. The commas work like tabs on a typewriter. 10 PRINT "I LIKE YOUR TOUCH ON MY KEYBOARD. DO YOU
COME HERE OFTEN?"
PRINT ZONE < PRINT ZONE 2 PRINT ZONE 3 PRINT ZONE *
<
r i . i • i « !'pii».nini(.wiiDi>M»JH'B»B»nanimi"»n«i<coiw™ You'll notice lhat you run out ol room on one row. But
as you type this,
O K
keep typing; the Commodore 1 6 automatically moves on io the nexl
row and continues printing there until your line is linished. You can type
Ifyou try to PRINT more than four items separated by commas, your as many as BO characters on one program line (up to two full 40-column
computer automatically goes to the next line to PRINT For example: rows}.

Now try RUNnlng this one line program. The message is printed on two
f

58
59
tows. If your than one row. your Commodore 1 6 lets It
lino is longer Make sure that you always use the nght variable type. If you try to do
spill over row Your computer considers the line ended
to the next I something like assign a word to an integer variable, your program won't
when you press Ihe HETUWf key, nol when you lype lo the end of the work. This program shows you what variable can or can't be used in
a
row You'll get used to tins as you use your Commodore 1
given situation, and you can find oui what happens when you try out
different types ol data:

USING VARIABLES 10 PRINT "ENTER A NUMBER* this asks you to enter

a number for the


The example 36*(1 2+(A/3)) shows one of the most powerful fealures
20 INPUT X% variable
of a computer. When you have a letter instead of a number in a
mathematical problem, you're using a VARIABLE. A variable 30 PRINT "I READ YOUR NUMBER AS"; X%
represents a value:
40 PRINT "NICE GOING. ACE!"
10A-3
20PRINT"TOTAL:";A'4 50 END

If you RUN this program, the screen result is. When you RUN this program, try to enter these values (one each time
you RUN when you're asked and see whal happens
it)

TOTAL: 12 ONE FIFTH


.043
There are three types of variables you can use 10

SAMPLE
TYPE SYMBOL DESCRIPTION EXAMPLES VALUES
Floating real (decimal) X, AB, T4 23.5. 12.
point or whole f

numbers 1.3E+2 NUMERIC FUNCTIONS


Integer % Whole numbers X%, A1% 15.102.3
Text siring S letters, Included in your computers BASIC language are numeric functions,
numbers. XS. MSS "TOTAL:", which are like the advanced calculations found on most scientific
and all other "DAY 1"."CBM" calculators (such as sine, cosine, tangent, etc )
characters in
quotes
Most ol Ihe functions can be used by tvp<ng the name ol Ihe function
'
(
and the number to be operated by the formula in parentheses, like this
Every time you wanl a variable to be read as a whole number, the
symbol tor that would Include the % sign A variable that
variable FUNCTION(X)
contains text MUST end
with a $ as part of the variable tf it doesn't
have that symbol, your computer expects a floating point number. A For example, to find oul the sine of a variable, you would type
variable wilhout either of the symbols f % or %) is read as a floating point
number (a "regular" number). Integer variables (whole numbers) are a PRINT SIN(X)
subset of floating point variables: they are numbers with no decimal
places with X as any number you wanl to Input.

60 61
You could also include one of the functions in a program line, as the
example shows;
following I

10 FOB X= 1TOS
20 PRINT "THE
30 NEXT X
SQUARE ROOT OF"; X;"IS"; SQR(X) CHAPTER 6
You'll find a complete listing of the numeric functions In the BASIC
Encyclopedia In the back of this manual. GRAPHICS
NOTE: Most commands have an abbreviation mat you can type
AND
instead o( typing out the entire BASIC name. Your Commodore 16
interprets the abbreviation exactly as It would read the full name. An COLOUR
example of an abbreviation is as follows
• Graphics characters
Lthen O prints L on your screen !
I

Your computer reads this as It you'd typed out LOAD. Abbreviations Character animation
are useful as a tlmesaver. There Is a complete list of the accepted
abbreviations m the BASIC Encyclopedia
Controlling colours

User Defined Functions High resolution graphics


i I

An effective wayuse your computer's math capability Is to create


lo Points, lines, and labels
user defined functions. User defined functions are extremely useful In
calculations, and easy to implement using your Commodore 16. User • Squares, circles, polygons, and painting
defined functions allow you to program a formula, ana then let your
computer plug in vaiues to be calculated This can be used for many Multi-colour graphics
!
different purposes.

Here is a statement utilizing the user defined function for calculating Ihe
value of a secant
[

10DEFFNS(X)-1/COS(X)

This figures out the value of Ihe secant of any number entered lor X.
FNS is the name of the function defined by this statement Appendix C I

contains a table of mathematical functions not included in your


computer's BASIC language
User defined functions save memory space when you would use a
function more than once, and make your programs easier to read and [

understand

62 63
To draw the left Keeping the shift loot down, go to the space
side:
GRAPHICS CHARACTERS
'
!
directly beneath the curved edge (where you pressed the "U" in the last
I

You should remember from Chapter 2 that each letter key contains 2
step. Press the "B" key. then cursor to Ihe space directly beneath Ihe
line segment you just drew and press "B" again. Do this until you've
different graphic characters, as do the @. -, ", and £ keys for a total I
f
of62 different graphic characters To these graphic characters, you
print
pressed the "B" key a total ol 7 limes. (Using the cursor keys win be
tough at first; you'll gel belter with practice.)
must hold down the shift or O keys while you press the key tor the
1 1
graphics symbol you want.

Whet your Commodore 6 1 is not in mode, hold down


typing 1 1

and press a tetter key lo print the graphics character on the right side of
key These characters include the playing card suits, a solid
that letter 1 r
and a hollow ball, and a set of lines and connecting characters that you
can use to draw many different pictures on your screen. 1 i

The O key pressed with a key always produces the graphic


tetter

character pictured on the key The left side graphics are


left fronl ol Ihe 1 i

an assortment of bars, souares, lines and blocks, uselul In drawing


charts and graphs. 1 r / \
c
1 i

Pick a Card, Any Card To draw the bottom edge. Similar to Ihe lop edge, you press "J" once
1 i

Here an example to help give you a better idea ol how to use the
is
and then press the "C" key 5 times, finishing off with the "K" key.
graphic characters to create representations. Follow these instructions 1 i

to create a playing card, in this case the six of hearts.


1 i
First,change the cursor colour to red. Hold down the Key along
with Ihe "3" key lo change the cursor colour.
1 i

u i 1 i

V /
1 1

Now time lo draw Ihe top edge of the card: Press the mutt loci
it's

key so that it stays down Press "U". followed by the C" key 5 times,
1
i
'

and then the T. To draw Ihe right edge: Draw Ihis in the same fashion as the left edge,
1 i pressing Ihe 'B' key a total of 7 times (while cursoring lo the appropriate
place).
1
i

i
B 1

1 i

1 i

64 1 i 65
1
1

1 1

NOTE: When the shift lock down, you can press return and
is
I
not get a SYNTAX ERROR from your computer as a response. Even
1
1

though you had characters on the line that weren't commands thai
1
I
the computer can understand, your computer interprets the return
key as just an Instruction to return to the beginning of the next line
1 1 when the OVT key is held down. Your computer does nol try lo
read or interpret what has been typed as BASIC language
1 1
1 commands when shift oi shift loci is down.

Release the wan


loot by pressing it once In the upper left corner
1 1

You can use the graphic keys to enhance your printout For example,
(one space down end one space over from the rounded edge) pfess the
'6*. Go to the bottom right corner, position
1 J here's how to underline a word or column-
the cursor one space up and
space lo the lelt and type another 'ff
1 1
move the cursor to the line below what you want to underline.
First,
Then hold down the -fr key and the "T" key, which prints an underline
SHIFT S I
space. Hold these two keys down until the entire portion of text is
1

\ underlined.
6 1 1

1 I The purpose ot this section is to show you how the graphic symbols of

W9 1 I
your Commodofe 1 6 can be manipulated to creale different shapes and
figures and used in a more practical sense in addition to the 62 graphic
characters available to you, you can also use the reverse of these
characters. (Remember the racing stripe!) Now that you have a good
1
:
r idea ot what is involved in using the graphic symbols to build different
L J. forms, you should experiment with them yourself, and see what you
1
1 :

come up with.

Now to ge t down
to the heart of the matter—6 of them to be exact.
1 1
Press the SHIFT LOCK down again. Go one space down from and one
space lo the right, from where you typed the 6. Press the 'S' key, hit the CHARACTER ANIMATION
SPACE BAR and press the 'S' again Cursor down two rows and repeat
,
1 1

the 'S- SPACE -S' sequence. Add the last two hearts two more rows
Movies are really a sequence of still piclures Each picture is a tittle
down You now have an official six ol hearts playing card This won'l 1 !
f differeni from the one that came before. The protector shows each
do you too mucn good In a game of blackjack, however. If you want to ptclure tor a very short time, then goes on to the next one. The scene
improve your hand, creale a couple ol cards of your own 1 1 becomes animated.

1 1
Computer animation works the same way First the computef draws
one picture, then it changes the picture slightly. Your Commodore 16 is
fast enough to move objects smoothly around the screen In your games
l : 1

and practical programs. A movie is animated at a rate of 30 pictures per


l
1 second. The changes are last enough to fool the eye and create the
illusion of movement. The only way you can attain the speed to create

i
1

66 i I
67
! I

I I
"
this Illusion on your computer is lo use a program lo draw a picture, 10 PRINT " HOME SHUT M SHIFT W SHIFT N
wait for a split second, (ben change to a new picture. 20 PRINT" SPACE O + SPACE
30 PRINT " SHIFT N SPACE SHIFT M"
I
I 40 FOR L= 1 TO 300: NEXT L
To get program
the create pictures you would use the PRINT
to
SO PRINT " HOME SPACE SHIFT W
statement with the graphic characters. The simplest type of animation
involves alternating two characters to gel the effect of movement, 60 PRINT " O T C> + T" <
70 PRINT " SPACE © G fr. G"
80 FOR L= 1 TO 300: NEXT L
i

This progr am sim ulates animation by alternating ihe circle shift & O)
( II
90 GOTO 10
and heart (JHfBt & S) symbols. It you use your imagination, you could
consider this a heartbeat ol sorts
I
Type RUN and press Betuhn

! I

IMPORTANT TO NOTE: Each time SOFT or O is referred to, il Inbolh examples of animation so far. the figure has been stationary In
should be typed at the SAME TIME as the key following it when I
i
one area on Ihe screen. The next step is lo move the animated figure
entering the program, since nolhtng happens when either Is typed by around. The TAB function helps when you want to move objects from
Itself ( the led edge, (The TAB function is explained in detail In ihe BASIC
Encyclopedia) The following program portrays a snake crawling on Ihe
i l screen.

Remember
program, and press
lo type NEW and press mft before entering each new (

KTUBK to enter each these programs


line In all Remember lhal ana the tollowing key are slil lyped together.

I
I

10 PRINT "HOME SHOT 5FORA=0TO30


I
20FOHL=1TO 100
!

10 PRINT " SHIFT CUl


"

30 NEXT L "
type these keya i
20 PRINT TAB (A) " SHIFT U SHUT I SHIFT U SHIFT I
40 PRINT " HOME SHIFT simultaneously
I
30 PRINT TAB (A) " SHIFT K SHIFT I SHIFT K SHIFT I SHIFT Q"
50 FOR M=l TO 200 40 FOR L=l TO 100: NEXT L
60 NEXT I
50 PRINT " SHIFT CLE "
70 GOTO 10 60 PRINT TAB (A + 1)" SHIFT I SHIFT U SHUT 1 SHIFT U SWT W"
( 70 PRINT TAB (A+l)" SHUT I SHIFT K SHIFT I SHIFT K"
80 FOR L=l TO 100: NEXT L
You'll see Ihe obvious limitation of animation alternating two characters 90 NEXT A
when you RUN this program To stop it press Ihe boh/stop key

To gel a more interesting you can build a small picture from


effect I Lines 20 and 30 should look like this when typed tn:
f\J\
several graphic characters, then change a few ol the characters while
leaving others in the same pace
object moving, as In the following program;
This gives the elfecl of part of a larger I

I
I

I
'
Lines 60 and 70 will look like this;

vxr
I
I 69
f

Using characters like the ball (SHIFT O), you can play video games on The second number after COLOR setecls the colour you want to put on
the screen. To move a bail, just erase ihe ball ana replace it at a new
I
the area of the screen you've specified. The colour numbers
position, as In th<s program conespond 1o the colour keys on Ihe keyboard.

"
10 PRINT " SHIFT a* I

20 PRINT " space shift O Left cursor arrow Colour Numbers


30 FOR L=l TO 50: NEXT L I

40 GOTO 20 COLOUR * COLOUR COLOUR


I

When you RUN the program, remember to press the MB/stc* Key 1 BLACK 9 ORANGE
when you want stop moving the 2 WHITE BROWN
to ball.
M 3 RED
1

11 YELLOW GREEN
CONTROLLING COLOURS 4 CYAN 12 PINK
i

Separate colours can be put Inlo each pan at the screen The border
i
5 PURPLE 13 BLUE GREEN
can be one colour, the background a different one, and each character 6 GREEN 14 LIGHT BLUE
can have Its own colour You already know how to set the character i
7 BLUE 15 DARK BLUE
colours using the keyboard. Vou can change the colours ol Ihe other 8 YELLOW 16 LIGHT GREEN
scroen areas using the BASIC language command COLOR i

For example, you can turn Ihe border of your screen 'ea by typing the Each colour also has an adjustable brightness level, called the
command COLOR 4,3 and pressing the MlUM
key. The number 4 in
f
luminance You can add a number from (darkest) through 7 (brighies!)
after the colour number to vary the colour Type COLOR 4 ,3, and
the command stands lor the border area, and colour number 3 is red
(the same number as on the key marked RED).
f
press KTOlK The border becomes a dark red. Type COLOR 4, 3, 7
and the border changes 10 a bright red
Try typing COLOR 0, 7 and hitting betum The screen background (
now turns blue. The number stands for the background, while the 7 is
In short, the COLOR command looks like this

blue {also the same as the keyboard) ! COLOR area, colour, luminance

The first number after the word COLOR specifies Ihe area on the
Here is a quick program to show you all your Commodore 1 6's colours.
screen you want to change This table lists what each screen area (

number controls; you'll learn about areas 2 and 3 when vou get inlo First type NEW and press hetubm
multi-colour graphics later m this chapter !

Screen Area Numbers 10 COLOR 0, 7, 7


I
20FORM-0TO7
30FORN-1TO2
AREA* AREA NAME I
40 FOR L=l TO 16
50 PRINT " cm. wn oh " type these keys together
Background 60 READ A
1 Character 70 COLOR I. A. M
2 Multi-colour 1
'

80 PRINT SPACE SPACE'


' •

3 Multi-colour 2 90 NEXT
4 Border 100 PRINT
I
CHARACTERS 110 RESTORE
BACKGROUND 120 NEXT N.M
1
130COLOR1,2, 4
BORDER 200 DATA 7,14,4,13,6,16,11,8,10.9.3,12,5,15,2,1
I

70 71
I
I

I I

When you RUN program. (he screen background changes to a lighl


this
To switch from the normal graphics (of text mode) to high-resolution,
blue, and ihe spectrum ol Commodore 1 6 colours is shown al each
I 1 justtype the command GRAPHIC 2,1 and press HETORH The screen
luminance level. You'fl notice Ihat black is Ihe same al all luminance
goes blank and Ihe cursor reappears near the bottom of the screen
levels.
1 1
Your Commodore 1 6 screen is divided into 2 separale sections: Ihe top
forgraphics and Ihe bottom live lines lor text. It you don't wanl the
NOTE: Like most ol the BASIC graphic lerms reviewed in this bottom five lines for text, you can use the command GRAPHIC 1,1,
1
chapter. COLOR may be referred to as a statement or command
1

but you won't be able to see any commands you type. You can switch
interchangeably. back and forth from graphics to text using the GRAPHIC command
(
(
The command GRAPHIC switches the screen back to text, while
GRAPHIC 2 switches back to hign-res without erasing Ihe screen
THE GRAPHIC COMMAND 1 I
Adding ,1 after the command erases the screen

( I
The graphics you've seen so There is another way to clear the high-resotulton screen. The
use only the keyboard without really
tar
taking advantage of your computer's capabilities. The BASIC language command SCNCLR erases the screen without changing the graphic
of your Commodore 1 6 contains commands to draw shapes and forms
1 1
mode Once you use high-resolution graphics, Ihe computer sots aside
through programs. To use the graphics-related commands of you' 10K of memory for your high-res screen. This memory is taken trom
computer, you must enter a new mode, the GRAPHIC mode. Graphic 1 1 the BASIC program area. When you are through using graphics, you
mode can be considered the drawing mode, since all the drawing can reclaim this memory by using ihe command GRAPHIC CLR.
commands are "activated". You can't use these commands until you 1 1

specify exactly what graphics mode you want to use; you specify
which type ot graphics mode you want by using the GRAPHIC I 1

command. There are three different modes: normal text, high-


resolution graphic and multi-colour graphic modes. Wllh the f '

GRAPHIC command, you can even have part-text, part-graphic screens HIGH RESOLUTION GRAPHICS
that 'ol you can write on one pari ol Ihe screen and draw on the rest.
1 (
The command to enter this new mode is GRAPHIC Your Commodore 1 6 screen contains 25 rows of 40 characters each.
( ! 1
or 1 000 total character positions on the screen. Each character is

In general the GRAPHIC command looks like this formed out ol single dots, with 8 rows of 8 dots each making an entire

GRAPHIC mode, clear -* — this part is optional


1 I
character. Your screen has a total of 320 dots on each row, and 200
rows of dots, or 64.000 dots all together. The high resolution graphics
on your Commodore 1 6 give you control over every single dol
' '
1

Mode number Effect


1
Using normal graphics, you have limited control over me Individual
!

Texl dots Drawing a racing stripe or a playing card is a nice little exercise,
1 High-resolution graphics bul your creation is limited to using the characters (letters, graphic
'
f symbols, etc.) on your computer keyboard. You can slill create all
2 High-resolution graphics + text
Multi-colour graphics kinds of shapes and figures but just a fraction of what you could do if
Multi-colour graphics + text
1 1 you could control each dot by itself The high resolution graphics
capability of your Commodore 16 lets you do |ust that Resolution
(
Clwr number Effect
1

Don't clear screen 1 1

1 Clear screen
I f

72 i 1
73
refers lo the precision and control you have in drawing; with nigh Some forms of the DRAW command are
resolution graphics, you can use commands thai let you draw and I

erase dots, lines, circles, and other shapes.

!
I COMMAND RESULT
There is one limit to high-resolution (hi-res tor short) graphtcs. Your DRAW colou' source, column, row POINT
computer can only use two colours in each 8*8 character position, I
DRAW colour source, column, row TO column,
That Is. each 8x8 space on the screen (where a* single character row LINE
would fit) is limited to two colours {foreground and Background colour I DRAW colour source TOcolumn, row LINE DRAWN FROM
tor that square) You can use different colours for each different LAST POINT
character position, but only two colours within mat position. Anolhei
graphic mode that will be covered later in this section, multi-colour
Colour source Is for the background. for the foreground. Anything
I

mode, allows up to four differenl colours per character position at the I


drawn in the background colour (0) Is the same as erasing the
cost of the resolution available in the high-resolution mode foreground colour at that spot.
i

Here a program that utilizes some of the high resolution graphics


is

computet and the GRAPHIC command in particular.


capability of your I. ! In the DRAW command, number is either I {draw a dot) or
the first

{erase a dot). The next two numbers are for the column and row
Clear the computer's memory with the NEW command so you're sure
that there are no "left-over" program tines, and then (
positions for the dot. So you wanted to draw a dot at column 1 7. row
if
type.
20, you would type DRAW 1,17,20. To erase the same dot, you'd Type

I
DRAW 0,17,20
10 COLOR 0,1
20 GRAPHIC 1,1 (
30 FOR L=2 TO 16 The DRAW command can also draw a line between any two points.
40 COLOR 1.L.2 Justadd the word TO and the coordinates of the other end, like this.
50 DRAW 1,0,L*12 TO 319.LM2
I
DRAW 1 ,1 ,1 TO 1 00,1 00. This draws a line Irom the dot at 1 .1 lo

60 DRAW l.L'18,0 TO L-18, 199 100.100. You can erase this line by typing the same command, just
70 NEXT L
I
substituting a for the 1 immediately after DRAW
80FORL-lTOS000:NEXT
90 COLOR 1,2 J I

100 GRAPHIC If you are used drawing graphs in malh, you might get a little
lo
! confused at first while using the computer. The coordinate system in
your Commodore 1 6 is different from what you've used before. In math
Notice mat the colours change near the intersections. This is due lo the I
the 0.0 point would either be at Ihe cenire or Ihe lower left comer of the
limitations of hi-res graphics, with too many colours too close together. screen, but on your computer n Is the upper left corner. You'll get used
to this system as you practice.
(

Points, Lines and Labels Once you have put a on the screen, you can draw a line
point or line
from it to DRAW 1 TO 150,50. This draws a
any other point like this:
Type the commands GRAPHIC 2,1 DRAW 1,0,0 and press betdrn line from Ihe last poinl drawn lo column 50 row 150. your program If

Look closely at the upper left corner of the screen. Your Commodore uses a loi ol DRAW TO commands, you could place Ihe first dot at a

1 6 drew a white dot there The DRAW command can be used to draw position on Ihe screen by using the LOCATE command, as in
a single dot anywhere on tho screen, a line, or a shape. LOCATE 100,100, to Immediately return lo Ihe first position
I I

74 (
I
75
(

(
This program draws a curve based on Ihe sine lunclioo 81 CHAR 1,0,0,"GRAPH OF':CHAR l.O.l/'FORMULA"
f 82CHAR1,0,2,"Y»SW(X)"
83 DRAW 1,0,100 TO 319,100,189,0 TO 189. 199
NEW r 84CHAR 1,0,12,"X-AXIS": CHAR 1,22,0, "Y"
10 COLOR 0,1 85 CHAR 1,22,2,"A": CHAR 1,22,3,"X"
20 COLOR 1.2 86 CHAR 1.22,4/T*: CHAR 1.22.VS"
i
30GRAPHIC 1.1
40LOCATE 0,100
50FORX = TO 319 1
i

60 Y - INT (100+99 SIN(X.'20))


70 DRAW 1 TO X.Y
80 NEXT X
90 FOR L=l TO 5000 i

100 NEXT L
110 GRAPHIC

I i SQUARES, CIRCLES, POLYGONS AND PAINTING


Don'! lype NEW after RUNnlng Ihe lasl program To plot the program Using the DRAW command, you can draw pictures by plotting many
dlff erently. change line 70 lo: f
f
dots or lines. To draw a square, you can use ihe command DRAW
1,0,0 TO 100,0 TO 100,100 TO 0,100 TO 0,0 to connect lour
dots with
I r (our lines (plotting each endpoint ol the square) or you can just use the
70 DRAW l.X.Y BOX command.
I i

Drawing Rectangles
This program plots the same curve using points Instead ol lines.
I i
One ot the graphic commands ot your Commodore 1 6 makes easieri(

to draw squares and other rectangular shapes. The BOX command


r
I letsyou pick the points ot 2 opposite comers ol the square To
duplicate the same box as in the above example, just use BOX
i
( 1,0,0,100,100. The number! again means that you want lo draw and
noi erase. The next four numbers are me coordinates ol the box's
The Char Command
opposite corners, (0.0) al the upper-left corner and (100.100) near Ihe
!
Graphs are more easily understood and uselul it you label them. You middle ol Ihe screen
can use the CHAR command lo mix text right into a high resolution <
drawing. For instance, the statement CHAR 1,0,S,"HELLO" puts the
I The BOX commana can lorni any rectangle |ust by changing Ihe
corners. You can even rotate the box by specifying an angle (m
word HELLO into the sixth row at Ihe left edge ot the screen (the lirst
row is 0'), The tirsl number after ihe word CHAR is either 1 (lor draw) I I degrees) after the lasl coordlnale, like this: BOX 1,50,50,100,100,45.
The box is rotates -55 degrees clockwise so lhat resembles a diamond
(lor erase). The next two numbers are the column and row where
II
o*
I
shape.
Ihe texl appears. [

IIyou would like lo draw a solid box instead of just Ihe outline, you just
Leave the last Iwo programs In ihe computer, don't type NEW Add f (
add a comma 1 alter the angle. A solid box at the centre of the screen
these lines: is shown as BOX 1,100,50,220,150., 1. Notice thai you need a comma
f I

f l
76 77
1 1 i

i
'
r
lo lake the p'ace Ql the angie, even though you don't want the box The usual forms of the CIRCLE command are:
rotated This ts so your computer reads the comma as the DEFAULT i
i

value, which means that interprets your lack ot response as an


It
Commam! Effect
instruction you don't Include the comma, the 1 at the end ol the line
II
! 1 1

Is read as the angle lor the box to be rotated. CIRCLE on. centre column, centre row, radius circle

1
I
1
CIRCLE on, c-col, c-row, width, height wa
CIRCLE on, c-col, c-row, wid, hi, start, finish arc
Some typical forms of the BOX command are: CIRCLE on, c-col, c-row, wtdth, height., .angle rotated oval
1 1

CIRCLE on. c-col. c-row. wid, ht.... point angle polygon


Command Effect
1 1 I

BOX on. column row column 2, row 21 , 1 , Outline


This commano draws a circle in the centre of the screen: CIRCLE
BOX on, col row col 2, row 2, angle
1 . 1 , Rotated I
I 1, 160, 100,50. This tells your computer lo draw a circle with its centre at
BOX on. col row col 2, row 2,
1 ,
l , . fill Solid box
column 160 and row 100. with a radius of 50. This may actually
BOX off, col row col 2, row 2. angle.
t ,
i , Ill Erase area
produce an oval, since the dots on some TV's and monitors ( American
1 I
of screen ones, lor example) are taller than they are wide. To change this to a
real circle you must add a separate number to tell that the height is
1 '
different from the width, Uke this: CIRCLE 1,160,100,50,42.
Column 1 row 1 etc. are screen positions of endpolnts that you
, ,

specify. Column 1 row 1 is the upper left corner of the box while row
, 1 1

and column 2 is the bottom right corner


l
1 Drawing Polygons
Here Is a program that illustrates the BOX command (line 60) Your Commodore 16 can also draw a square, u-angle or other polygon
! 1 1

using the CIRCLE command. Just tell the computer how many
10 COLOH 0,1 i
degrees to go between points on the circle, like Ihis. CIRCLE
1 (
20 COLOR 1,2 1,160, 100,50,42,,,. 120. This command draws a triangle, since each
30 GRAPHIC 2,1 side is 1 20 degrees (Remember that omitting number values while
40 A = RND(1)'20+ 10
1 1
including commas in a graphic command causes your computer to read
50 FOR L=0 TO 359 STEP A standard default values lor the missing number.) A simple (ormula to

60 BOX 1, 100, 30, 220, 130, L 1 ! 1


get the angle lor a polygon with N sides is 360/N
70 NEXT L
80 FOR L« 1 TO 2000: NEXT L (

90 GRAPHIC 0,1 Here's a quick program lor drawing polygons:


1 1

10 GRAPHIC 2,1
20 INPUT-HOW MANY SIDES";A
30 IF A < 2 OR A > 100 THEN PRINT "DONT BE RIDICULOUS":
GOTO 20
Drawing Circles 40 CIRCLE l.I60.80,40,33„ M 360/A
I 50 GOTO 20
Your Commodore 16 also has commands lor drawing circles Uke the
BOX command, you can vary the shape of the circle (to form an oval or
I
an ellipse), and you can rotate the oval. You can also just draw a You can choose to draw only an arc Instead o> a whole circle. The
section ol me shape (called an arc). CIRCLE command accepts the starting and ending angles In degrees,
(

78 79
f

the height number The command CIRCLE


right afler 75 PAINT 1, 160, 1O0
1,160, 100,50,42,90, 1B0 displays only the lower right section ot the
circle To rotate an oval, add the angle ot clockwise rotation after the
command, like this example: CIRCLE 1,160,100,100,20,, ,30.

Here's a program that uses CIRCLE commands (or an interesting


effect. Don't forget to clear your computer's memory by typing in NEW f

if you entered the last program


I

10 COLOR 0, (

20 COLOR 1,2
30 GRAPHIC 1,1 MULTI-COLOUR GRAPHICS
A = RND(l)" 20+ 10
:
I
40
SO FOR L=0 TO 359 STEP A The Commodore 1 6 high resolution graphics give you control over
60 CIRCLE 1, 160. 100, 80, 40...L I
every single dot or "pixel" on the screen, but you have seen that the
70 NEXT L ability to put colours close together is limited. Most hkes programs

80 FOR L= TO 2000: NEXT L


1 f can use only one or two colours For Including more different colours,
90 GRAPHIC 0,1 your computer has a special "in-between" graphics mode called multi-
( colour graphics. In multi-colour graphics, you control half as many dots
on each row as in hi-res because each dot is twice as wide. You get
160 dots on each row. while still getting 200 rows. There is a trade-off
I
for the use of multiple colours, which is slightly lower resolution.

I
This program will be slightly different each time you RUN
To begin using multi-colour graphics, review the GRAPHIC command
f
see that the multi-colour screen without
earlier in this chapter. You'll
text is GRAPHIC 3 and the multi-colour screen with 5 lines of text Is

The Paint Command f GRAPHIC 4.

To make a circle or other shape more than just an outline, you can use (

Ihe PAINT command The PAINT command fills In any enclosed area Now look at the table listing the COLORcommand. There are two
up to the boundaries formed by lines drawn on the screen. If there are areas that we haven't used yet, areas 2 and 3. These areas hold two
f

no lines rjrawn, the screen is filled right to the edge. The BOX extra colours. You can use any of the three colours (1 the text colour;
.

command has a fill option that colours In boxes and rectangles. The 2. an extra colour; and 3, another extra colour) These colours do not
f
PAINT command can colour in irregular shapes and other non-uniform Interfere with each other on the screen the way the hi-res colours do in
areas on the screen that can't be filled with other commands. some previous programs In this chapter.

To see what the PAINT command does, add this line to the last
This program makes use of multi-colour graphics, showing a "neon
program:
sign" effect.

,i
BO
"I

; t

NEW
10 COLOR 0,1 !

20 GRAPHIC 3,1
30 COLOR 3,1
40 TRAP 200
50 DRAW 3,10,10
60
TO 10,100: DRAW
DRAW 3,30,10 TO 30,100: DRAW
3,10,5S TO 30,55
3,50,10 TO 80,10
f

(
CHAPTER 7
70 DRAW 3,65,10 TO 65,100: DRAW 3,50,100 TO 80,100
80FORL=0TO7
90 COLOR 3,2,L
i
SOUND
100 FOR M= TO 100: NEXT M
AND
f
1

110 NEXT L
120 COLOR 3,1 [

130
140
FOR M-l TO
GOTO 80
100: NEXT M
f
MUSIC
200 GRAPHIC 0: COLOR 1,2,7
Introduction
r
Colour area 3, the second of the multicolour areas, has a special ability
Volume command
t
thatnone ol the others has Once you have drawn on the screen using
area 3, you can change that colour everywhere it appears on the Sound command
screen by using the COLOR command, If you set the colour with i

COLOR 3,5 and draw using that colour, your graphics appear in • Creating sound effects
purple. you then change the colour with COLOR 3,6, all the purple
II f

areas would change to green. This doesn't work with any other area.
The Series 264 Programmer's Reference Guide contains more Making some music
information about graphics

[
The Mustc Machine

82 [ 83
M BM
i

Try the example again and use a different number after the VOL
first
INTRODUCTION command. The larger the number, the louder the note is played.
Here Isa short program lo make music on your Commodore 16. Alic
you've typed it in, when you RUN It, a question mark will appear on f
your scree" Type any number trom lo 1 01 5 as your response and
The Sound Command
press return To stop the program, enter a zero as your value.
i
The SOUND command tells your computer everything it needs to know
aboul Ihe sound you want to otay The SOUND command is followed
10 VOL 8 i

by three numbers thai describe the note


20 DO
30 INPUT X
i
SOUND voce, nolo value, duration
35 IF X > 1013 OR X<0 THEN PRINT "0 TO 1015, PLEASE": GOTO 30
40 SOUND 1,X, 10 i

LOOP UNTIL X-0 The number In the sound command refers lo voice. The number
first
50
i
for vo'ce can be a .2 or 3 The Commodore 1 6 sound is produced by
1
i
two different "voices", 1 for Ihe first voice and 2 for the second vo»ce.
Pressing the huh /stop key also stops the program
1
The third voice option applies lu voice 2's capacity to produce either a
i
lone or noise.

Here's how to play a single note on your Commodore 1


i r

Voice 1 - This voice plays only tones Select INs voce wllh a 1 after
First Type VOL 8 and press ( I the SOUND command
Second Type SOUND 1,266,60 and press return i i
Voice 2 - This voice is like voice i , but can be used lo play tones o'
noise tor sounds. Type a 2 In the command lo use this voice for tones,
i

You should hear a note play tor about a second and Ihen stop. You
i
or a 3 to use this voice for noise, to make sound effects like thunder

might consider this an unfinished symphony in the most extreme sense


and rain
i i
ot the word (one note down. 3.500 lo go). you don't hear anything,
II

turn up the volume of your television or monitor and try again it


The second number word SOUND is Ihe note value
after the
i
i

(frequency). This can bo any number from O lo 101 5. tells your It

Commodore 1 6 how low- or high-pitched a note to play As the


Tnese two steps are the only commands thai you need to know to play i i
numbers get larger, the noles get higher The highest values (in Ihe
music on your Commodore 1 6. Both commands are easy to
1 01 5 neighborhood) are not audible lo Ihe human ear
understand and easier to use ! I

I I Note:Wnn voice 3, noise is "white" only in the range ol 600-940


The Volume Command You can use register values outside this range to create interesting

I
I sound effects.
The VOL command controls the VOlume ol the notes that your
Commodore 1 6 plays. The number thai comes after VOL
is the selting
i I
torthe volume This command works pretty much like the volume knob This displays a! of the notes in one scale, along with Ihe note value to
on your TV When it is set at zero (VOL 0). the volume is ott and you use There is a complete chart ot notes tor the Commodore 6 n Ihe 1

f
won'l hear anything When you set it at 8 (VOL 8), the volume is appendix.
turned up all the way. and your computer plays as loud as it can.

84 I 85
which counts time in sixtieths of a second A duration of 60 keeps the
I note on lor one second The rule ol thumb lor duration is the larger the
number, Ihe longer the note stays on. In tact, II you use 65535. the nole
Ill II III 41 III II I stays on lor over 16 minutes. To turn a sound off, use a zero duration,
which does not allow Ihe sound to be produced.

A Musical Sound Effect


! Sound effects can be created using either musical tones or noise.
Comb>nmg simple BASIC programs ana sound commands can
generate unusual and entertaining effects. For instance, Ihe FOR
NEXT . STEP loop can be used creatively In sound eflects. This
command sets up a loop; each time the computer reads FOR, It
changes the counter variable (S in this example). When it reads NEXT.
It goes back to the FOR statement. This program uses a FOR

NEXT loop with a negative STEP, to count down from a high number lo
NOTE A a lower one by 25 at a time
B C D E F G f
VALUE 770 798 810 834 854 864 881
ACTUAL FREQUENCY 440.4 494.8 522.7 588.7 658 699 782.2 10 VOL 8 sets VOLume at 8
(HZ) 20 FOR S= 1000 TO 700 STEP -25 creates loop, with
30 SOUND 1, S, 1 downward STEPs
Try the Wowing program:
40 NEXT S

NEW
! Type RUN ano press return to near the sound effect, The key is line
20. which selects a number range from 1 000 to 700 going down the
10 VOL 8 -<— sets VOLume scale. STEPping down 25 numbers at a time Finally, line 30 instructs
20 X -0 (

your Commodore 16 to play each note lor (us: an instanl by selttng the
30 DO DURATION to 1 which is 1 /60 ol a second. Experimenting with
40 SOUND l.X.5 « plays nole
,

different number and duration values can give you some very
50 X= X +S
interesting effects.
60 LOOP UNTIL X - 1015
70 VOL -* turns off VOLume
80 END (
Creating a Noise Sound Effect
Using a value ol 3 selecting a voice in the SOUND command
when
This program shows of some ol your Commodore '6's musical range. (

spc-cilies noise. This isused lo create sound effects with noise rather
than tone. The following program uses voice 3 lo create the sounds ol
The third number after the word SOUND controls the Duration (length) f

a windstorm.
note This tells your computer how long to play the note. This
ol the
number can be anything Irom to 65535. This number sets a timer, I
10 VOL 2 -« sets VOLume level
20 R-INTIRND{0)-10) + 1 < selects RaNDom number Irom 1
(
30FORX = 1TOR to 10
40SOUND 3, 600+ 30*X, 10
(

{continued on next page)


f

86 I 87
r

50 NEXT X Press numbers 1 Ihrough 8 to play notes. The screen border even

60FORX = RTO STEP -1 1


I
changes colours with the different noles When you finish playing,
70 SOUND 3, 600+30-X, 10 press Ihe space bar to slop me program.
80 NEXT X I

90 T = INT(RND{0) " 100) + 30


100 SOUND 3 600, T
Now thai your Commodore 1 6 can be used like a piano, you mighl feel
r

( (he urge to play a popular song. Here are Ihe numbers lo press lo play
110 GOTO 20
a well-known song that surely must be considered a classic.
I
I
Lines 30 and 60 up FOR
sel .NEXT loops lor the nole value
.

mmm
(frequency) ol Ihe sound, one increasing and one decreasing, based on 115 5 6 6 5
f
the random number from line 20. Is Important to have variation in
11
I

4 3 3 2 2
4
pilch, since windstorms have different forces of gusts of wind. Lines 40 5 5 4 4 3 3 2
and 70 are the SOUND commands that creale Ihe noise. Lines 9C and
100 sel up a random delay lo recreate the uneven nature of a
windstorm wllh lime lapses between howls The program selects a
I

f
(

5 5 4 4 3 3
115 5 6 6
4 4 3 3 2 2
2
5
1
i
RaNDom number that is used for the duration of another SOUND
command. This SOUND command stays at ihe same pilch and
provides a consistent background noise that serves as a counterpoint to This next program plays a song by reading a list ol DATA statements
the gusts of wind. This may seem pretty complicated, like you need to Your compute' READs the numbers contained in the DATA statement
be an experienced programmer to be able 10 do But it's really
li.
as values for variables (in this case X and Y), changing the values with
nothing more than experimenting, trying different things, and seeing each loop The DATA statements are in pairs. The first number Is the
note value for the SOUND command and the second number Is ihe
what noise comes out. Creating sound effects using noise is
challenging, trying to capture Ihe right elements of the sound you want duration for the SOUND command
exactly To be good al it. you have lo be willing lo experiment
Row Boat

Making Some Music 10 VOL 8


I 20 DO
You may nol understand everything that's going on in these programs, 30 READ X, Y
but type Ihem In anyway and see what happens 40 SOUND 1, X, Y
45 FOR D=l TO Y'16+30:NEXT
This program simulates a piano using the Keys Irom 1 through 8. 50 LOOP UNTIL X=0 <— This loop creates a brief delay
60 END between notes
5 SCNCLR 100 DATA 169, 45, 169. 45, 169, 30
10FORX-1TOB: READN(X): NEXT X 110 DATA 262, 15, 345, 45, 343, 30
20 VOL 8 120 DATA 262, IS, 345, 30, 383, 15
30 DO 130 DATA 453, 60, 596, 45, 453, 45
40 GET AS: IF A$="" THEN 40 140 DATA 345, 45, 169, 45, 453, 30
30 A=ASC(A$): IF A<49 OR A >56 THEN 90
'

ISO DATA 383, IS, 345. 30, 262, 15


1

60N-A-48 160 DATA 169, 60


70 SOUND 1, NfN), 5 1
200 DATA 0,
80 COLOR 4, N, 3
1

90 LOOP UNTIL A = 32
100 VOL 0: COLOR 4, 2, 7 1

110 DATA 169, 262, 345. 383, 4S3, 516, 571, 596
1 1

1
Bfl ( !
\

THE GREAT COMMODORE 16 As you can see, music and sound can be used lo enhance programs or
be the focus of the program itself. The examples in this chapter just
MUSIC MACHINE give you a taste of the music capabilities of your Commodore 1 6 Don't
1 r be afraid to try new sounds and noises and create your own
The (asl program is a little longer. Tnis is the "GREAT COMMODORE masterpiece.
16 MUSIC MACHINE". When you press a key from 1 through 9, the
1 i

note is played, and a note appears on the start on the correct line.
By now, you've begun a handle on some ot the things you can
to get
1 r do with your Commodore 6. The aim of this manual has been to give
1

5 GOSUB 1000 you a taste ot computing, to have you try new things and see wnat
6F0RX = 1T0 9: READ N(X}: NEXT X 1 happens, to learnabout your computer and lo have fun In the process
8 CHAR 1. 8, 1,"*THE GREAT MUSIC MACHINE*" But there's still so much more programming, for example. This
, ,

10 VOL 7 1 r manual has touched on how lo begin lo use BASIC, but is nol a tutorial
20 DO ( 1 or BASIC lexlbook by any means. The BASIC Encyclopedia
30 GET A$: AS=
THEN 30 ,[
IF " 'no space (Immediately lollowlng this chapter) gives a complete listing of ALL the
1
35A = ASC(A$) IF A < 49 OR A > 57 THEN
: 50 BASIC commands on your Commodore 1 6. with explanations and
36N= A 48 - examples. In many of the programs in the last couple of chapters, you
1
(
40SOUNDi,N(N), 4 may not have understood exactly what steps were doing what. To
45 GSHAPE N$, 150, 8 <6+(9-N)), 4 learn more aooul programming with the BASIC language, you should
46 FOR Z=l TO 50: NEXT Z 1 1 read books lhal were written to leach BASIC A list of these books
47 GSHAPE N$, ISO, 8 ' (6+(9-N)). 4 appears in the appendix. It you are really interested in programming,
50 LOOP UNTIL A = 32 1
( you might want to gel the Series 264 Programmers Reference Guide,
55 VOL 0: GRAPHIC 0: SCNCLR whicn focuses on the hows and whys of programming, revealing the
60 END ( i
secret and not-so-secret tricks of the programming trade Now thai
100 DATA 345, 383. 4S3, 516, 571, 596, 643. 68S, 704 you've finished reading this manual, you mighl think that you're on your
1000 GRAPHIC 1,1 own, bul not entirely. You can read any o' the many computer
1
f
1010 FOR Y=60 TO 124 STEP 16 magazines, some of which are entirely devoted to Commodore
1020 DRAW 1, 100, Y TO 200, Y 1
computers, peripherals and software You can also become part of a
group of people near you who share your interest in Commodore
(

1030 NEXT Y
1040 AS="FEDCBAGFE" computers; a Commodore User's Group. For moie Information on these
1050 FOR X = l TO 9: C- 13 CBM
1

groups, contact the Information Centre.


1060 IF INTCX/2) - X/2 THEN C = 14
1070 CHAR 1, C, X + 6, MIDS <A$, X, 1), 1
(

1075 CHAR 1, C-f 10, X+6, RIGHTS <STR$ (10-X}, 1)


1080 NEXT X 1 i

1090 FOR X= 1 TO 8: FOR Y* 11 TO 16: DRAW


1, X, Y: NEXT Y, X
1100 Y-l: X-8: DRAW 1, 8, 16 TO X, Y 1 (

1110SSHAPENS, 1,1,8, 16
1120 GSHAPE N$, 1 1,4 (
1 [
1130 RETURN
1
(

i (

1
(

90 r
<

f
BASIC 3.5
(
ENCYCLOPEDIA
(
Introduction

Commands
I

Statements
I

Functions
(

Variables and operators


I

Abbreviation and reference chart


I

<

I
I

I
f

I
i

92 [
ftt
EXAMPLE LOAD'program name",D0. U8
INTRODUCTION
.additional arguments
You've seen manual an assortment ot exercises using Ihe BASIC
in Ihis
keywords \ irgument
ar (possibly optional)
language, to give you a (eel tot computer programming and some ot
Ihe parts of the command or statement that you must type In exactly as
ihe vocabulary Involved. This encyclopedia gives a complete list ol the they appear are highlighted in a darker lype in Ihe format listing, while
rules and lerms (SYNTAX) of the BASIC 3.5 language, along with a
the name of the command is in capital letters. The words that you don't
concise description ot each Experiment with these commands, and
type in exactly, such as the name of a program, are printed in lighter
remember that you can't damage your Commodore 1 6 by typing in
italic type. When quote marks (" "> appear (usually around a program
programs, and that Ihe best way to learn computing Is by doing
or file name), you should include them in the command or statement,
like In Ihe format example
The encyclopedia provides formats and briet explanations and
examples ol Ihe BASIC 3 5 commands and statements. Is not It

intended to teach BASIC. you are Interested in learning BASIC,


It • KEYWORDS appear in uppercase tetters and boldface type. YOU
Appendix G lists tutorial books that witl help. MUST ENTER THESE KEYWORDS EXACTLY AS THEY APPEAR
However, many keywords have abbrevialions that you can also use
Commands and statements are listed In separate sections. Within Ihe (see the reference chart).
sections, Ihe commands and statements are listed in alphabetical order.
Commands are used mainly In direct mode, white statements are most Keywords are words lhat are part ot Ihe BASIC language that your
ollen used In programs. In most cases, commands can be used as computer knows Keywords are the central part of a command or
statemenls In a program it you prefix them wild a line numoer. You can statement They tell the computer what kind of action you wanl it to
use many statements as commands by using them in direct mode (i.e., lake. These words cannot be used as variable names.
without line numbers) II you are unsure where a term is located, they
are all 'Isled in tne reierence chad.
• ARGUMENTS (also called parameters) appear In lowercase letters

The BASIC Encyclopedia is organized along the lines ot the tallowing Arguments are the parts of a command or statement that you select;
they complemenl keywords by providing specific information aboul the
• COMMANDS: the commands used lo work with programs, edit,
command or statement. For example, a keyword tells Ihe computer lo
store, and erase them. load a program, while an argument tells Ihe computer which specific
• STATEMENTS: the BASIC p*ogram statements used In numbered I

program lo load and e second argument specifies which drive the disk
programs.
lines ot containing the program is in Arguments Include filenames, variables,
• FUNCTIONS: the string numeric, and prim functions line numbers, etc.
• VARIABLES AND OPERATORS: the dllterent types of variables,
legal variable names, and arithmetic and logical operators.
• SQUARE BRACKETS [| show OPTIONAL arguments You select
A luiler explanation of BASIC 3.5 commands is provided in Ihe Series any or none ot the arguments iisted. depending on your requirements
264 Programmer's Reierence Guide, available from your Commodore
dealer or your local bookstore.
• ANGLE BRACKETS < > indicate that you MUST choose one of the
arguments
COMMAND AND STATEMENT FORMAT listed.

The commands and statements presented in Ihis section of the


encyclopedia follow consistent format conventions to make them as • VERTICAL BAR separates items in a list ot arguments when your
i

clear as possible. In most cases, there are several examples to choices are limited lo those arguments listed, and you can't use any
Illustrate whal the aclual command looks tike The following example
other arguments. When the vertical bar appears in a list enclosed in

shows some of the format conventions that are used In Ihe BASIC SQUARE BRACKETS, your choices are limited to the items in the list,
but you still have the option not lo use any arguments
commands and statements;

94
• ELLIPSIS . . , a sequence ol three dots, means lhal an option or BACKUP
argument can be repealed mote than once.

• QUOTATION MARKS " enclose character strings, filenames, and


' BACKUP Ddnve* TO Ddrive* |, ON Uunrt#|
other expressions When arguments are enclosed in quotation marks in
a formal, you musl include the quotation marks in your command 0( This command copies all the Dies on a diskette to another diskette on a
statement. Quotation marks are required parts of a command or dual drive system. You can copy onto a new diskette without first using
statement the HEADER command to format the new diskette because the
BACKUP command copies al> the information on the diskette, Including
• PARENTHESES When arguments are enclosed in parentheses In a the format. You should always BACKUP important diskettes In case
format, you must include the parentheses in your command or the original is lost or damaged

statement. Parentheses are also required when they appear »n a


command or statement description.
Because the BACKUP command also HEADERS diskettes, destroys II

• VARIABLE refers to any valid BASIC variable name, such as X. A$. any information on the diskette onto which you're copying information
orT% So it you're backing up onto a previously used diskette, make sure it

contains no programs you wish to keep. See also the COPY

• EXPRESSION means any valid BASIC expression, such as A+B+2 command


or 5*(X+3)

NOTE: This command can only oe used with dual disk drive.
BASIC COMMANDS

AUTO I EXAMPLES:
AUTO [line*
f
BACKUP DO TO Dl Copies all files from the disk in drive
Turns on the automatic line numbering feature which eases the job of to tne disk in drive 1

entering programs by typing the line numbers for you. As you enter
each program line and press retubn the next line number is printed on BACKUP DO TO Dl ON U9 , Copies all files from drive C to drive
the screen, with the cursor In position to begin typing thai line. The
1 In disk drive unit 9
[line#J argument relers to the increment between line numbers. AUTO
with NO ARGUMENT turns oft auto line numbering, as does RUN This
slatement is executable only In direct mode

EXAMPLES
COLLECT
AUTO 10 automatically numbers line in increments o( ten

AUTO 50 automatically numbers line In increments of fifty


COLLECT [Ddrive#] |,ON Uuml#l
AUTO turns OFF automatic line numbering
Use this command to free up space allocated to improperly closed files

and deieles references to these files from the directory


f

96 97
[ I

EXAMPLE COPY "CATS" TO "DOGS" Copies CATS as a


program called DOGS
COLLECT DO on ihe same drive.

CONT
DELETE
CONT (Continue)
DELETE [first Hne#J |- iasl llne*|

This command is used lo re-slarl the execution ol a program that has


been slopped by either using the STOP key. a STOP statement, or an Deletes lines ot BASIC text. This command can be executed only in
END statement within the program. The program win resume execution direct mode.
where 'eft off. CONT will not work you have changed or added
it if

lines of the program (or even (ust moved the cursor to a program line EXAMPLES:
and hit return without changing anything), the program slopped due
if

to an error, or you caused an error before trying to re-start the


if
DELETE 75 Deietes line 75.
program The error message in this case is CAN'T CONTINUE ERROR.

DELETE 10 - SO Deetes lines 10 through 50 inclusive.

f
DELETE -30 Deletes all tines from the beginning ol the
COPY program up to and Including line 50.

COPY [Ddrive#,J "source file" TO [Ddrivejf ,) "other file" [,ON Uuntt#] DELETE 75- Deletes ail lines from 75 on to Ihe end of the
program
COPYs a file on the disk in one drive (the source file) to the disk in the
I

other on a dual disk drive only, or creaies a copy of a file on the same
drive (with a different file name).
[

EXAMPLES- DIRECTORY
I

COPY DO/'NOON" TO Dl, "NIGHT" Copies NOON from


drive lo drive 1
DIRECTORY |Ddrive#] [,Uunii#|[. 'filename"!

renaming it NIGHT
f Displays a disk directory on the Commodore ^6 screen Use CTRL -S
COPY DO, "STUFF" TO Dl, "STUFF" Copies STUFF from lo pause Ihe display (any other key restarts the display after a pause)

drive to drive 1 (
Use me fr key Commodore key) to slow down. The
(Ihe II

DIRECTORY command cannot be used to print a hard copy Y ou must


COPY DO TO Dl Copies all tiles from load the disk directory (deslroying the program currently in memory) to

drive Q to drive 1. do that.

"'.'/
f
BB
EXAMPLES The DLOAO command can be used within a BASIC program lo find and
RUN another program on disk. This is called chaining.
DIRECTORY List all files on the disk

DIRECTORY Dl ( U9, "WORK" Lists the file on disk drive unit 9 (8


is the delaull). drive named
WORK
1 ,
DSAVE

DIRECTORY "AB*" Lists all files starting with the letters DSAVE filename" |,Ddrrve#] [,Uunrt#]
"AB", like ABOVE. ABOARD, etc.
This command stores a program on disk (Use SAVE to store
DIRECTORY DO, "FILE ?.BAK" The ? Is a wild-card that matches programs on tape.) You must supply a program name.
any single character in thai
position: FILE 1 .BAK, FILE 2.BAK.
FILE 3.BAK all match the siring. EXAMPLES

DSAVE "DDAY" SAVES the program "DDAY" to disk

NOTE: To print out the OIRECTORY ot drive 0, unit 8, use the DSAVE (AJ) SAVEs to disk program whose name
following.
is In the variable AS.
LOAD"$0",8
r DSAVE "PROG 3", D0.U9 SAVES Ihe program "PROG 3" lo the
OPEN4,4:CMD4:UST
PRINT#4;CLOSE4 disk drive with a unit number of 9.

HEADER
DLOAD
HEADER "dtskname" ,Ddrlve# [,Iid #| |,ON Uunit#]
DLOAD "filename" [,Ddrive#| [,Uun«*|
Before you can use a new diskette for the firsl time you must format it

This command loads a program from disk into current memory. (Use with Ihe HEADER command. you want to erase an entire diskette for
If

LOAD to load programs on lape.) You must supply a program name. re-use you can use the HEADER command. This command divides the
disk Into sections calleo blocks, and it creates a table of contents,
called a directory or catalog, on the disk The d<skname can be any
EXAMPLES name up to 6 characters long The d. number is any 2 characters.
1 i

Give each disk a unique id number Be careful when you HEADER a


DLOAD "DTRUCK" Searches the disk tor the program disk because Ihe HEADER command erases all sioreo data Giving no
DTRUCK" and LOADS it. id. number al'-ows you to perform a quick header. The o(d id. number
Is used. You can on'y use ihe quick header method If the disk was
DLOAD (A$) LOADs a program trom disk whose previously formatted, since the quick header only clears out the
name is in the variable AS. You will get dkecto'y rather than formatting ihe disk.
an error it A$ is empty.

100 101
! 'I

EXAMPLES: The keys may be redefined in a program, For example:


I I

HEADER "MYDISK", 123, DO 10KEY2,"TESTING" + CHR$(34):KEY3, "NO"


I (

HEADER "THEBALL", US, Dl, US 10 FOR I - 1T0 8: KEY I, defines the function keys as
I ( CHR$(I+132):NEXT they are defined on the
Commodore 64 and VIC 20
) I

HELP I To resfore all function keys to Iheir default values, reset your
Commodore 1 6 by turning it off and on, or press the RESET bulton,

I I

HELP

The HELP command Is used after you gel an error in your program.
When you type HELP, the line where Ihe error occured is listed, with LIST
me portion containing the error displayed in Mashing characters.
LIST [first line) I
-[last tine]]

The LIST command lets you look al lines of a BASIC program that have
KEY been typed or LOADed into the Commodore 1 6's memory. When LIST
is used alone (without any numbers following it), you get a complete
LISTlng of the program on your screen, which may be slowed down by
KEY |key#. string) holding down ihe &
key, paused by CTKL -S (unpaused by pressing
I I
( any other key), or STOPped by pressing the mm/no* key. you II

There are eight Keys availaDle follow Ihe word LIST with a line number, your Commodore 1 6 only
(8) function to Ihe user on your
Commodore 16 compuler tour unshitted and lour shifted Your I
'
I shows that line number If you type LIST wilh iwo numbers separated
Commodore 16 allows you to define what each key does when by a dash, the Commodore 1 8 shows all lines from the first to the
pressed. KEY without any parameter specified gives a listing displaying I second line number. you type LIST followed by a number and just a
If

all the current KEY assignments: The data you assign to a key is typed dash, ilshows all the lines from that number lo the end of the program
out when that lunction key is pressed. The maximum length tor all the I
I
And if you type LIST, a dash, and then a number, you get all the lines
definitions together is 1 28 characters. Entire commands or a series of from the beginning ol the program to that line number Using these
commands) can be assigned to a key. For example: variations, you can examine any portion of a program, or easily bring
I I
lines lo the screen for modification.

KEY 7, "GRAPHICO" + CHR$(13) + "LIST" + CHR$(13) I I

EXAMPLES.
causes the compuler lo select lexl mode and list your program I

whenever Ihe 'F7' key is depressed (in direct mode). The CHR5(1 3) is LIST Shows entire program
the ASCII character for ktuwi Use CHR$<34) to incorporate a I

double quote into a KEY string. LIST I0Q- Shows from line 100 until the end of me program.
I .
1

I .
I

102 I
[ 103
LIST 10 Shows onfy line 10.
i

LOAD "BRIDGES" 8 Looks tor the program called BRIDGES


LIST- 100 Shows lines from the beginning unlii line 1 00 f

on the disk drive, and LOADS it if found.


i

LIST 10-200 Shows lines from 10 to 200. inclusive.


The LOAD command can be used within a BASIC program to find and
i
RUN the next program on a tape This is called chaining.

The RELOCATE FLAG determines where in memory a program is


i

loaded. A relocate (lag of tells the Commodore 1 6 to load the


LOAD program at the start of the BASIC program area, and a flag ol tells it '

to LOAD from the point where It was SAVEd. The delaull value of the
i

LOAD ["filename" (.device*] [.relocate flag) ] relocate Hag is 0. This is generally used only when loading machine
i
language programs.
This the command to use when you want to use a program stored
Is on
cassette tape or on disk. It you type just LOAD and hit the hetorn i

key, the Commodore 16 scieen goes blank. Press play, and the
Commodore 1 6 starls looking for a program on the tape When llnds It

one. the Commodore 1 6 prints FOUND "lliename" You can hit the
i

NEW
C" key to LOAD; rf you don't press Ihe key, the compuier resumes
i
searching on the tape after a brief interval. Once the program is
LOADed, you can RUN. LIST, or change D
NEW
i

This command erases the entire program in memory and clears out any
variables that may have been used Unless the program was stored
You can also type the word LOAD followed by a program name, which i
somewhere. It 'S lost uniil you type il in again. Be careful when you use
Is most often a name In quoles("program name"). The name may be
followed by a comma (outside of Ihe quotes) and a number (or numeric
tnis command
i

variable), which acts as a device number to determine where Ihe The NEW command can also be used as a statement m a BASIC
program is stored (disk or tape) tt there is no number given, your program. When your Commodore 16 gels to this line, the program Is
[
computer assumes device number 1 which is the cassette tape
, erased and everything stops. This is not especially useful under normal
recorder. circumstances

The other device commonly used w<m the LOAD command Is usually I

the disk drive, which Is device number 8.


(
RENAME
EXAMPLES:
I
RENAME [Ddrlve #.] "old name" TO "new name" Uumt #) ((

LOAD Reads in the next program on tape f


Used to rename a file on a diskette.
LOAD "BASES' Searches tape for a program called EXAMPLE
BASES, and LOADS it if h is found f

RENAME D0."ASSET" TO Changes Ihe name of the file from


LOAD A$ Looks for a program whose name is m r "LIABILITY" ASSET to LIABILITY
the variable called AS.
f

1CM i
105
(

EXAMPLES:
RENUMBER I

RUN Slarts program working from lowest line number.


RENUMBER [new starling line * [.Increment | t
old starling line #] ] 1

RUN 100 Starts program at line 1 00


The new starting line is tne number of the first line in the program after
I
renumbering. It defaults to 10.

I
The increment is the spacing belween line numbers, e. 10, 20, 30
it also defaults to 1 0,
I etc.
SAVE
I

SAVE ("filename" |. device* f.EOT flag] 1

The o'd starling line number number in (he program where


is ihe line [
renumbering is lo begin This allows you to renumber a portion of your This command stores a program current ly in memory onto a cassette
program. It defaults lo Ihe first line of your program. tape or disk. If just type the word SAVE and press BETUWi your
you
I

Commocore 16 altempts lo store the program on Ihe cassette tape. It


has no way of checking if there is alieady a program on the tape in that
This command can only be executed from direct mode I

location, so be careful with your tapes If you type the SAVE command

EXAMPLES followed by a name in quoles or a siring variable name, the


I
Commodore 16 gives the program lhal name, so may be more easily
It

RENUMBER 20, 20, 1 Starting al line renumbers Ihe program


1 ,
located and retrieved In Ihe future. If you want to specify a device
Line becomes line 20. and omer unes
1
I
number for the SAVE, follow the name by a comma (after the quotes)
are numbered in increments of 20.
and a number oi numeric variable Device number t is the tape drive,
I
( and number 8 is the disk. Alter the number on a tape command, there
RENUMBER, 65 Starting at line 65. renumbers m can be a comma and a second number, which is between and 3
,

Increments of 1 0. Line 65 becomes line !


second number is 2, the Commodore 1 6 puts an END-OF-TAPE marker
1 (unless there are already lines (EOT flag) after your program. If you are trying to LOAD a program and
the Commodore 1 6 'tnds one of these markers rather than the program
numbered 10-64, In which case fhe I

command Is nol carried out).


you are trying to LOAD, you get a FILE NOT FOUND ERROR

I
I

EXAMPLES
I

SAVE Stores program to tape withoul a name.


RUN I

SAVE "MONEY" Stores on tape with the name MONEY


RUN |Une f\ :
I

Once a program has been typed Into memory or LOADed, the RUN SAVE AS Stores on tape with name m variable AS
I

command makes it start working RUN clears all variables in the


program belore starling program execution Ihere is no number If SAVE "YOURSELF"^ Stores on disk with name YOURSELF
I
following the command RUN, the computer starts with the lowest
numbered program line. If there Is a number following tne RUN '

command execution starts al thai line. RUN may be used within a


I

program.
f

Oh 107
.

SAVE "GAME". 1, 2 Stores on tape with name GAME and


VERIFY without anything after the command causes the Commodore
places an END-OF-TAPE marker after me I 1 6 check the next program on tape, regardloss of its name, against
to
program.
the program now in memory VERIFY followed by a program name (in
f quotes) or a string variable searches the tape for that program and then
checks VERIFY followed by a name and a comma and a number
I
checks the program on the device with that number (1 for tape. 8 (or
disk) The relocate tlag is Ihe same as in the LOAD command.
SCRATCH I

EXAMPLE:
SCRATCH "file name" |.D drive #][.U unit #|

VERIFY Checks the next program on the


Deletes a from the disk directory. As a precaution, you are asked
file
! tape.
"Are you sure?" betore your Commodore 16 completes the operation.
Type a Y to perform the SCRATCH or type N to cancel the operation. VERIFY "REALITY" Searches for REALITY on tape,
Use this command to erase unwarned Hies, to create more space on the checks against memory,
disk.

VERIFY "ME",8,1 Searches for ME on disk, then

EXAMPLE: checks.
I

SCRATCH "MY BACK", Dl Erases the file MY BACK from the I

disk m drive 1
BASIC STATEMENTS
(

I
BOX

I BOX (colour source #|, a1 . b1 , (a2. b2l [, angle |,paintj


|

VERIFY I colour source Colour source (0-3); default Is 1 (foreground colour)


ai.bl . . Corner coordinate (scaled)
' a2, b2 . .Corner opposite at bt (scaled); default ts the PC
.

VERIFY "filename" |.devlce#] [.relocate Mag)


angle . Rotation in clockwise degrees: default Is degrees
. .

paint , , . Paint shape with colour (0:off, 1 on); default Is


(
This command causes your Commodore 16 to check me program on
tape or disk against the one In memory This <s proof thai the program
( This command allows you to draw a rectangle of any stee anywhere on
you |ust SAVEd Is really saved, to make sure that nothing went wrong
the screen To get the default value, include a comma without entering
This command is also very useful to position a tape so that your
computer resumes writing following the end of the last program on the I a value. Rotation is based on the centre of the rectangle. The Pixel
Cursor (PC) is left at a2, b2 after the BOX statement is executed.
tape. All you do is tell the Commodore 1 6 to VERIFY ihe name of the
last program on Ihe tape It wilt do so, and tell you that the programs I
.
(

don't match (which you already knew) Now the tape is where you EXAMPLES
want it, and you can store the next program without fear of erasing an I
I

old one.
BOX 1, 10, 10, 60, 60 Draws Ihe outline of a rectangle
I
(

1
08 I ( 109
BOX , 10, JO, 60, 60, 45, 1 Draws a filled, rolaled box (a T . Starting arc angle (default 0)
diamond) Ending arc angle (detault 360)
angle .Rotation in clockwise degrees
BOX , 30, 90, . 45, 1 Draws a tilled, rotated polygon I (default is degrees)
•nc Degrees between segments
2 degrees)
(default is

CHAR
CHAR [colour source fLx.y. string' [.reverse flag)

!
colour source Colour source (0 - 3)
A i * • * i
* Character column {0 - 39)
y Character row (0 - 24) f

"slnng" , , i ,
Text to be printed
reverse. Reverse fiold flag (0 = off, 1 » on) [

With the CIRCLE command you can draw a circle, ellipse, arc, triangle
Text (alphanumeric strings) can be displayed on any screen at a given or an octagon The final coordinate Is on the circumference ot the
location by the CHAR command. Character data is read from the
I
circle at the ending arc angle. Any rotation is about the centre. Arcs
Commodore 1 6 character ROM area. You supply the x and y are drawn Irom the starling angle clockwise lo the ending angle The
I
coordinates of the starting position and the text string you want to segmeni Increment controls the coarseness of the shape, with lower
display. Colour source and reverse imaging are optional values for inc creating rounder shapes.
(

The string is continued on the next line If it attempts to print past the EXAMPLES
I
right edge of me screen. When used In TEXT mode, the string printed
by the CHAR command works just like a PRINT string, including
i
reverse field, cursors, flash on/off, efc. These control functions inside
Ihe string do not work when the CHAR command Is used to display text CIRCLE, 160,100.65,10 Draws an ellipse.
in GRAPHIC mode. CIRCLE, 160.1Q0,6S,50 Draws an oval.
CIRCLE ,60,40,20,18,, ,.45 Draws an octagon
CIRCLE, 260,40,20,,, „90 Draws a diamond
CIRCLE , 60,140,20,18,,,, 120 Draws a triangle.

CIRCLE
i

CIRCLE |cs] ,[a.b). xr [,


[yr] [, [sal. |. [ea) [, |
angle) [,inc] j J ] i

CS . Colour source (0 - 3)
a.b Centre coordinate (scaled)
(defaults to the Pixel Cursor |PC])
xr X radius (scaled) i

y Y radius (detault is xr)


i

110
111
I

I I

PRINT* 1 Set output back lo me screen.


CLOSE i
'

CLOSE 1 Close the die.


CLOSE tile * i
i

This command completes ana closes any files used by OPEN


statements. The number following Ihe word CLOSE Is the (He number
(o be closed. i
'
COLOR
EXAMPLE
i
'
COLOR source *. colour # [.luminance #|
CLOSE 2 Logical Hie 2 is closed.
i :
I
Assigns a colour to one of the 5 colour sources:

i
i
N umber Sourca
background
CLR i 1 foreground
i

2 multicolour 1

CI.R 3 multicolour 2
i I

4 border
This command erases any variables In memory, but leaves Ihe program
I
ilseif intact. This command ib automatically executed when a RUN or I

NEW command is given, or when any editing Is performed Colours you can use are in the range 1 - 16 (t is Wack, 2 is white, 9 is
i
'
orange, etc. from your keyboard colour keys) As an option, you can
Include the luminance level 0-7, with being lowest and 7 being
i '
highest. Luminance defaults to 7 Luminance lets you select from eight
levels of brightness for any colour except black.
CMD
'
I

CMDIile# [.write HstJ


I
I

CMD sends the output which normally would go to the screen (I.e.
PRINT statement, LISTS, but not POKEs into the screen) (o another i '

device Instead. This could be a printer, or a data file on tape or disk.


DATA
This device or Hie must be OPENed first. The CMD command must be I '

toilowed by a number or numeric variable referring to the (lie. DATA list of constants separated by commas
'
(

EXAMPLES: This statement followed by a list of items to be used by READ


is

i I statements. The items may be numbers or words, and are separated by


OPEN 1,4 OPENS device 0A, which is the printer. commas Words need not be inside of quote marks, unless they
i
contain any of the following characters: SPACE, colon, or comma. If
i

CMD1 AH normal output now goes to the printer two commas have nothing between them, the value will be READ as a
zero for a number, or an empty string The DATA statement must be
i
'
UST The USTing goes to the pnnter, not the screen part of a program, otherwise it will not be recognized. Also see the

even the word READY. RESTORE statment. which allows your Commodore 16 lo reread data
i I

'

112
i

113
(

EXAMPLE: DIM
(

DATA 100, 200, FRED, "WILMA", , 3. 14. ABC123 i DIM variable (subscripts) [ variable* subset ipts))

(
Betore you can use an array of variables, the program must ftrsl
execute a DIM statement to establish the DIMensions of that array
(unless there are 1 1 or fewer elements in the array). The statement DtM
i
DEF FN isfollowed by the name of trie array, whicn, may be any legal variable
name. Then, enclosed In parentheses, you put the number (or numeric
variable) of elements In each dimension An array with more lhan one
i

DEF FN name (variable) - expression dimension is called a malnx You may use any number of dimensions,
!
but keep tn mind that the whole list of variables you are creating takes
up space In memory, and Is easy lo run out of memory you gel
it if
This command allows you lo define a complex calculation as a lunclion
I carried away. To figure the number of variables created with each DIM.
In the case of a long formula thai is used several times within
i

a multiply Ihe total number of e'ements In each dimension of the array


program, this can save a lot ol space.
I I
(Each array starts with element 0.)

The name you give the numeric function begins with the letters FN, I I

followed by any lega' numeric variable name. First you must define the NOTE: Integer (single-digit) arrays take up 2/5ths of Ihe space of
function by using the statement DEF followed by the name you've given floating point arrays
I !
the function Following trie name Is a set ol parentheses with a
(J
numeric variable (in this case. X) enclosed. Then you have an equal
I I
sign, followed by the formula you want
to define. You can "call" the
formula, substituting any number for X. using the format shown in line EXAMPLE
I
20 of the example below: I
10 DIM AS(40).B705).CC%<4.4,4)

( 1

EXAMPLE 41 Elements 16 Elements 125 Elements


I
(

10DEFFNA(X)=12'(34.75-XA3)+X You can dimension more than one array In a DIM statement by
I
I
separating the arrays by commas. It the program executes a DIM
20 PRINT FNA(7) statement for any array more lhan once, you'll get a re'DIMed array
The number 7 is inserted each I

error message II is good programming practice to place DIM


I

piace X is located In the formula


stalemenls near ihe beginning of the program
given m the DEF statement. I . I

I !

NOTE: DEF FN can only be used wnh standard numeric functions, ( I


DO (LOOP) WHILE (UNTIL EXIT)
not integer or string functions.

I I DO|UNTIL boolean argument WHILE |


boolean arguement)
stalemenls [EXIT]
I I

114 (
I 115
I
'(

(
LOOP[UNTIL booiean argumeni WHILE boolean argument] END
f
(An example of a boolean argumeni Is A=l or H>-57
END
Performs the siatemenis between ihe DO statement and the LOOP I (

statement. If no UNTIL or WHILE modifies either the DO or the LOOP When the program executes an END statement, the program stops
statement, execution of the intervening statements continues I RUNnlng Immediately. You may use the CONT command to re-start
Indefinitely. If an EXIT statement is encountered io the body of END
a DO the program at Ihe statement following the statemenL
loop, execution is transferred to the first statement lollowing the LOOP
f

statement DO loops may be nested, lollowing the rules defined for


FOR-NEXT loops.
I (

Itthe UNTIL parameter is used. Ihe program continues looping until the ( ( FOR . . . TO . . . STEP
boolean argument is satisfied (becomes TRUE). The WHILE parameter
Isbasically the opposite of the UNTIL parameter; the program continues
looping as long as the boolean argument is TRUE. FOR variable = start value TO end value (STEP increment]
I I
This statemenl works with the NEXT
statement to set up a section of
EXAMPLE: number of times. You may Just want
the program that repeals for a set
I
I your computer to count up to a large number so the program pauses for
DOUNTTLX-0ORX-1 a few seconds, in case you need something counted, or something
I < must be done a certain number o' times (such as printing).
LOOP
DO WHILE A$="":GET A$:LOOP I (
The loop variable is the variable that is added to or subtracted from
during the FOR/NEXT loop. The start value and the end value are the
I ( beginning and ending counts tor the loop variable.

DRAW I (
The logic ol Ihe FOR statemenl is as loiiows First, the loop variable Is

set to tne start value. When the program reaches a line with the
I f
DRAW (colour source *\ [, al. b1][,TOa2, b2.][ .] command NEXT, it adds tne STEP increment (default 1 ) to the value

of the loop variable and checks to see If Is higher than the end of loop
It

With this command you can draw Individual dots, lines, and shapes.
( I
value. If It not higher, the next line executed is the statement
is

You supply colour source (0-3). starting (al , b1 ) and ending poinls (a2. immediately following the FOR statement. If the loop variable is larger
b2). I ( than the end of loop number, then Ihe next statement executed Is the
one following the NEXT statement A STEP value can be positive or
( ( negative. See also the NEXT statement.
EXAMPLES:
a dot DRAW 1. 100, 50 — no endpolnt specified, defaults to I
(
EXAMPLE'
a1 ,b1 value tor a2.b2 to create a dot
lines: DRAW 10.10, TO 100,60
. I
. f 10 FOR L - 1 TO 20
DRAW TO 25,30 20 PRINT L
a shape: DRAW 10,10 TO 10.60 TO
, 100,60 TO 10,10 ( ( 30 NEXT L
40 PRINT "BLACKJACK! L - "I
I .
f

116 (
f 117
.

f 'I

I (
This program prints Ihe numbers from one lo twenty on Ihe screen,
lollowed by Ihe message BLACKJACK! L
The word GET Is followed by a variable name, usually a string variable,
21
: I tfa numeric were used and any key other than a number was hit, the
program would stop with an error message. The GET statement may
The end of loop value may be lollowed by (he word STEP and another i r also be put into a loop, checking for an empty result, which waits for a
number or variable In this case, Ihe value following ihe STEP is added key lo be struck to continue. The GETKEY statement could also be
each lime instead ol one. This allows you lo count backwards, by i i
used in this case. This command can only be executed within a
fractions, or any way necessary. program.
i i

You can setup loops inside one another. This Is known as nesting EXAMPLE.
loops. You must be careful to nest loops so that the last loop to start is i i

10 GET A$:IF A$ "A" THEN 10 This line warts for the


the first one to end.
'A' key to be pressed
i 1
to continue,
EXAMPLE OF NESTED LOOPS
i
i

10 FOR L = 1 TO 100 i

20 FOR A = S TO 11 STEP 2 TiisHDR. NEXT i i


GETKEY
1
loop ts "nested
[ 30 NEXT A Ihe larger one.
'
inside
i 1
GETKEY variable list
40 NEXT L i
i
The GETKEY statement Is very similar lo the GET staiement. Unlike
the GET statement. GETKEY waits for Ihe user to type a character on
i i the keyboard This lets it be used easily to wait tor a single character to
be typed,
1 <

This command can only be executed within a program.


' (

EXAMPLE:
i i
10 GETKEY AS This line waits tor a key to be
GET i i
struck. Typing any key will
continue the program

GET variable list i <

The GET statement is a way to get data from the Keyboard one i
i

character at a time When the GET Is executed, the character that was
typed Is received If no character was typed, 'hen a null (empty) i
i

character is returned, and the program continues without waning for a GET
key There is no need to press tne return key. and m fact the i
t
hetuum key can be received with a GET
GET* file number, variable list

I . !

118 I ( 111
1

Used with a previously QPENed device or file to input one character at in direct mode. GOTO line # allows you to start execution of the
a lime. Otherwise, it works like the GET statement program at the given line number witnout clearing the variables

This command can only be executed within a program. I

EXAMPLE:
EXAMPLE: (
10 PRINT "REPETITION IS THE MOTHER OF LEARNING"
GET*1,A$ 20 GOTO 10
I

The GOTO in line 20 causes line 10 to be run continuously, until the


I
key is pressed

GOSUB f

GOSUB line #
This statement is like the GOTO statement, except that your r GRAPHIC
Commodore 6 remembers where
1 It came
a with a
from When line
RETURN statement is encountered, the program Jumps back to the .
i

statement immediately following the GOSUB The target of a GOSUB GRAPHIC mode [.clear option]
statement is called a subroutine A subroutine is useful it there is a i
routine In your program that can be used by several different portions of This statement puts your Commodore 16 in one of lis 5 graphic modes
the program Instead of duplicating the section of program over and 1

over, you can set it up as a subroutine, and GOSUB to it from the mode description
different parts of the program See also the RETURN statement. normal text
(
1 high-resolution graphics
2 high-resolution graphics, spilt screen
EXAMPLE f 3 multicolour graphics

20 GOSUB 800 means go 4 multicolour graphics, split screen


to the subroutine
beginning al line BOO and execute i

When executed. GRAPHIC 1 - 4 allocates a 10K bit-mapped area, and


i
the BASIC text area is moved down below ihe hwes area, This area
remains allocated even if the user returns to TEXT mode (GRAPHIC 0).
800 PRINT "HI THERE";RETURN f
It 1 is given in the GRAPHIC statement as the second argument, the

screen is also cleared

EXAMPLES:
GOTO or GO TO (

GRAPHIC 1,1 Selects hhres graphic mode and clears the screen.
GOTO line #
i
GRAPHIC 4,0 Selects multi-colour graphics with an area lor text,
without clearing the screen
After a GOTO statement is executed, the next line to be executed wiil
be the one with the line number following the word GOTO. When used
i

120 121
EXAMPLE
GRAPHIC CLR
i
50 IF X>0 THEN PRINT"OK": Checks the value ol X. II X Is

GRAPHIC CLR ELSE END greater lhan 0, the THEN clause


i i
is executed, and the ELSE clause

This is actually a lorm of the GRAPHIC statement; instead of specifying isn't. IfX is not greater than 0.
a mode to use graphics, this statement clears the 10* of memory [ ( the ELSE clause is executed and
allocated to the graphic area, and that memory space becomes the THEN clause Isn't.

available for BASIC once again [ !

( (

IF . . . THEN . . :ELSE [
I

I
I
INPUT
IF expression THEN then-clause [:ELSE else-clause]

IF THEN lets the computer analyze a BASIC expression preceded [ ( INPUT ["prompt string".] variable list

by IF and lake one of two possible courses of action. If the expression


is true, the statement following THEN is executed. This expression may I I
The INPUT statement allows the compute' to ask for data from the
be any BASIC statement. If the expression is false, the program goes person running the program and place into a variable or variables.
II

directly to the next line, unless an ELSE clause is present. The The program stops, prints a Question mark (?) on the screen, and wails
I
expression being evaluated may be a variable or formula. In which case for the person to type Hie answer and press the BETUHN key
It is considered true if nonzero, and false if zero. In most cases, there Is

an expression involving relational operators (• <, >, <«, >-. <>, ,

AND. OR. NOT). The word INPUT is followed by a variable name or list of variable
I names separated by commas. There may be a message Inside
quotes before the list of variables lo be input. If this message (called a
The ELSE clause. present, must be In
It the same line as the IF-THEN prompt) is present, there must be a semicolon (,) after the closing quote
I

pan When an ELSE clause is present. It is executed when the THEN of the prompt. When more than one variable is to be INPUT. Ihey
clause isn't executed. In other words, the ELSE clause executes when should be separated by commas when typed In If not. the computer
I I

the IF expression is FALSE asks for the remaining values by printing two question marks {??) II
yoj press the BETurn key witnout INPUTting values, the INPUT
I I variables retain the values previously held for those variables This
1^1 statement can only be executed within a program.
! I
1

OK EXAMPLE:
I

Cneck 10 INPUT "WHAT'S YOUR NAME";At


0? E w i
I

No \ End I
20 INPUT "AND YOUR FAVORITE COLOR"; B$
30 INPUT "WHAT'S THE AIR SPEED OF A SWALLOW";A
: I

I (

122 [ f 123
'

i '

INPUT LOCATE
i r

INPUT* life number, variable lis!


LOCATE x-coordlnate, y-coordlnate
i
(

This works tike INPUT, but lakes (he data from a previously OPENed The LOCATE command lets you put the pixel cursor (PC) anywhere on
file or device. No prompt string is allowed This command can only be
(

the screen. The PC is the current location of the starting point ot the
used in program mode next drawing. Unlike the regular cursor, you can't see the PC. but you
t I
can move II with the LOCATE command. For example.
EXAMPLE:
I

LOCATE 160. 100

INPUTS, AS, C, D$
positions the PC In the centre of the high resolution screen You won't
' see anything until you actually draw something. You can find out
i
where the PC Is at any time by using the RDOT(0) function to get the X-
coordinate and RDOT(l to get the Y-coordlnate. The colour source of
)

I the dot at the PC can be found by PRINTing PDOT(2). (In all drawing
LET commands where a colour option Is available, you may select a value
I from to 3. corresponding to Ihe background, foreground, multicolour
1 or multicolour 2 as the colour source.)
[LET) variable - expression
,

The word LET is hardly ever used in piograms, since it is not


necessary, but the statement itself is 1he heart of all BASIC programs
Whenever a variable is defined or given a value. LET is alwayB Implied MONITOR
The variable name which is to get the result of a calculation is on the f

left side of the equal sign, and the number or formula is on the right
MONITOR
side. !

This command takes you out of BASIC Into the built-in machine
f r language monitor program The monitor is used to develop, debug,
EXAMPLE:
and execute machine language programs more easily than from BASIC.
( See the section on monitor commands for more Information (When In
10 LET A= 5 the monitor, typing an 'X' and pressing arrufiN gets you back to
I i BASIC.)
20 B= 6 LET is implied (but not necessary)
in lines 20, 30 and 40. I
30 C » A • B + 3

- "HELLO-
i

NEXT
40 DJ
! I

NEXT [variable. . . . ,vanable|


'

I I

124
I
f 125
.

The NEXT slalemeni Is used with ihe FOR statement. When the EXAMPLE:
computer encouniers a NEXT statement, goes back to the it

corresponding FOR statement and checks the loop variable (See FOR
statement tor more detail.) It the loop is finished, execution proceeds 10 INPUT X:IF X<0 THEN 10 When X = 1 . ON
with the statement after the NEXT statement. The word NEXT may be 20 ON X GOTO 50, 30, 30, 70 sends control to the
followed by a variable name, a list ot variable names separated by 25 PRINT "FELL THROUGH":GOTO 10 lirsl line number in the
commas, or no variable names. It there are no names listed, the last 30 PRINT "TOO HIGH":GOTO 10 lisl (50) When X - 2.
loop started is me one being completed H the variables are given, they 50 PRINT'TOO LOW'rGOTO 10 ON sends control to
are completed In order trom left to right l ;
70 END the second line (30),
etc.
f

EXAMPLE:

10 FOR L «
1 TO 10:NEXT
20 FOH L <
1 TO 10:NEXT L OPEN
30 FOR L 1 TO 10:FOR M = 1 TO 10: NEXT M, L
I
OPEN Me [.device # (.secondary address f.
"filename, type, mode"]|l

f
The OPEN statement allows your Commodore 16 lo access devices
such as the Datassette recorder and disk for data, a primer or even the
f ! monitor screen The word OPEN is followed by a logical file number,
ON which is the number to which all other BASIC statements will refer This
I number is from 1 to 255. There is normally a second number after the
first called Ihe device number Device number is the Commodore 16
ON expression <GOTO/GOSUB> line #1 [. line #2,
I
keyboard. 3 is Ihe screen, 1 is the Datassette recorder (default), 4 is the
printer. 8 is usually the disk. A *ero (0) may be included in tront of the
device number digit (e g 08 to* 8. which are interchangeable as far as
This command can make GOTO and GOSUB statements mlo
the I
,

your Commodore 6 is concerned). It Is often a good Idea lo use the


1

special versions ol the IF statement The word ON is followed by a


same file number as the device number because it makes it easy to
formula, then either GOTO or GOSUB. and a ol line numbers list I
remember which Is which. Following the second number may be a
separatee by commas. If the result ol the calculation of the formula third number called the secondary address. In the case ol tne cassette,
(expression) ts 1 line in the list is executed. II Ihe result is 2.
the first
this can be
.
I
fo' read. 1 lor write, ana 2 lor write with end-of-lape
the second line number is executed, and so on. If the result is 0. or marker at Ihe end. In the case of the disk, Ihe number refers to the
larger than the number of line numbers in the list, the next line executed
I
channel number. In the printer, the secondary addresses are used to
is tne statement following the ON statements II Ihe number is negative,
set Ihe mode of the printer See the Commodore 6 Programmer's1

an ILLEGAL QUANTITY ERROR results Reference Manual or the manual lor each specific device for more
I
(
information on secondary addresses There may also be a string
following the third number, which could be a command to the disk
I I
drive or the name ol the file on tape or disk. The type and mode refer

i r

^26 127
to disk dies only. (File types are prg.seq, rel, and usr; modes are mode. .0 = paint an area detmed by the colour source
read and write.) f selected
1 - paint an area defined by any non-background
f source
EXAMPLES:
l The PAINT command lets an area with colour It tills m the area
you fill

10 OPEN 3,3 OPENS the SCREEN as around the specified point until a boundary ot the same colour (or any
device. non-background colour, depending on which mode you have chosen) Is
encountered The final position of the PC will be at the starting point
10 OPEN 1,0 OPENs the keyboard as f <a b).
(

device.
I
NOTE: the starting point is already the colour ot colour source you
If

20 OPEN 1,1,0,"UP" OPENs the cassette tor


name (or any non-background when mode t is used), there is no
reading, tile to be searched i
change
lor is named UP
i

OPEN 4,4 OPENs a channel to use the EXAMPLE:


i
printer.
10 CIRCLE, 160.100.6S.50 draws outline of circle
I 20 PAINT 160,100 in the circle with colour
OPEN 15,8.15 OPENs trie command ,

channel on the disk


i i

5 OPEN 8,8. 12,"TESTFILE,SEQ, WRITE" creates a sequential disk tile i

tor writing.
POKE
r !

See also CLOSE, CMD, GET.*, INPUT*, and PRINT* statements, POKE address, value
system variable ST, DS, and DS$. I

The POKE command allows you to change any value In the


I
Commodore 16 RAM memory, and lets you modify many of the
Commodore 16 InpuVOutput registers. POKE is always followed by
!
two numbers, (or equations). The first number is a location inside your
PAINT computer's memory. This could have any value Irom to 65535 The
I ( second number is a value from to 255, which is placed tn the locat<on,
PAINT [colour source] [,[a,bl (.model replacing any value that was there previously This command can be
|

I
used to control anything on the screen, from placing a character at that
location to changing the colour there.
Colour source (0-3); (default is foreground colour)
l ,

a.b. starting coordinate, scaled (detaull is at the PC) r

EXAMPLE:

f '
f
10 POKE 16000,8 Sets location 16000 to 8

12B 129
20 POKE 16*1000,27 Jelt. ocation I6000to27 PRINT
Nole; PEEK, a function related lo POKE, ts listed under FUNCTIONS.
PRINT* file*, print list

There are a few differences between this statement and the PRINT.
First of Ihe
all. word PRINT#
followed by a number, which rotors to
is
PRINT
the device or data file previously OPENed. The number is followed by
r a comma, and a list of things to be PRINTed. The semicolon acts In the
PRINT printilst same manner for does in the PRINT staiemenl The
spacing as it

comma will send spaces to most printers and can be used as a


1

The PRINT statement is the major output statement In BASIC. While separator for disk files (see the Programmer's Reference Guide and ihe
the PRINT statement is the lirst BASIC statement most people learn to Disk Drive Manuai). Some devices may not work with TAB and SPC.
use. there are many subtleties lo be mastered nere as well. The word
PRINT can be followed by any combinations ol Ihese items, which is
considered the phntlist EXAMPLE

f 100 PRINT* l "HELLO THERE!", A$,B$,


f

Characters inside of quotes {"text lines")


Variable names (A. B. A$, X$>
Functions <SIN<23), ABS(33))
Punctuation marks

PRINT USING
Tne characters inside ol quotes are often called
because they
literals
are printed exactly as they appear. Variable names have the value they
PRINT i^filenumber.] USING formal list, prml list
contain (either a number or a string) pnnted Functions also nave their
number values primed. Punctuation marks are used lo help format the
These statements let you define the format of string and numeric Items
data neatly on the screen The comma divides the screen into 4
you want to print to the screen, pnnter, or another device. Put the
columns for data, while the semicolon doesn't add any spaces. Either
format you want in quotes This is the format list. Then add a
mark can be used as the last symbol in the statement. This results in
semicolon ana a list of what you want printed in the format lor the print
the next PRINT statement acting as if is continuing the last PRINT
list The list can be variables or the actual values you want printed. For
it

statement.
example:

EXAMPLE: 5 X-32: Y=100.23: AS = "CAT"


RESULT 10 PRINT USING "S##.##";13.2S,X,Y
20 PRINT USING "##i*>#";"CBM",A$
10 PRINT "HELLO" HELLO
20 A$-"THERE":PR1NT "HELLO/AS HELLO.TMERE When you RUN this, line 10 prints out:

30A=4:B = 2:PRtNTA+B 6 $13 25532.00 $••••• prints ••• instead of Y


50 = 41:PRINT I;:PRINT 1-1
J 41 40 value because Y has 5
60 C«A+B;D=A-B:PRINT A;B;C,D 4 2 6 2 which does not
digits,
See also: POS( ), SPC( j andTAB( (FUNCTIONS conform to tormat list (as
i
explained below)

130 131
[
Line 20 prints this: ifyou use a minus sign and the number is positive, a blank is printed in
I the character position indicated by the minus sign
CBM CAT leaves three spaces before printing "CBM" as
defined in format list If you don't use either a plus or minus sign In your formal field for a
I

numeric data Item, a minus sign is printed before the first digit or dollar
CHARACTER NUMERIC STRING I
symbol if the number is negative and no sign is printed If the number Is
positive. This means that you can print one character more If Ihe
Hasn Sign (#) X X
Plus(+)
number is positive. II (here are too many digits to fit into the field
X + an overflow occurs and the
specified by the # and / - signs, then field
Minus {-) X is filled with asterisks (•).
Decimal Point f.) X f

Comma (.) X
Dollar Sign ($) X A decimal pointsymbol designates the position of the decimal point
f
)
[
Four Carets (TTTt) X in the number You can only have one decimal point in any format
Equal Sign (*=) X field. If you don't specify a decimal point In your format field, the value
I
Greater Than Sign <>) X is rounded to the nearest integer and primed without any decimal

places.
f

The hash sign (0) reserves room lor a single cha.'acter In the output
field. the data item contains more characters lhan you have
If in your I
When you specify a decimal point, the number of digits preceding Ihe
format field, the following occurs: decimal point (including the minus sign, if the value is negative) must
nol exceed Ihe number of * before Ihe decimal point. If there are too
f
many digits an overflow occurs and the field is filled with asterisks {*).
For a numeric Hem. the entire field is filled with asterisks <). No f
numbers are printed.
A comma (,) lets you place commas in numeric fields. The position of
Ihe comma in Ihe format lisl indicates where me comma appears In a
r
printed number Only commas within a number are printed. Unused
For example:
commas !o the left of the first digit appear as the filter character. At
[
least one must precede the first comma in a field.
10 PRINT USING "0000")%
I

For these values for X, this format displays: If you specify commas in a field and the number is negative, then a
minus sign is printed as the firs! character even if Ihe character position
A -12.34 12 i
is specified as a comma.
A = 567.89 568 i
EXAMPLES:
A -123456 ••**
f FIELD EXPRESSION RESULT COMMENT
For a STRING item, the string data Is truncated at the bounds ol the ##.# + -.01 0.01- Leading zero added.
field. Only as many characters are printed as there are hash signs (#) in f
00.0 1.0
1 Trailing zero added.
the format item. Truncation occurs on the right
0000 -100.5 -101 Rounded to no decimal
places.
The plus f +) and minus
(-) signs can be used in either the first or last 0000 -1000 Overflow because four digits
position of a format field but nol boih. The plus sign is printed if the i and minus sign cannol fil in
number is positive. The minus sign is printed If the number is negative. field.

132 i
133
##*. 10 1 Decimal point added. PUDEF lets you redefine up to 4 symbols in the PRINT USING
#%#* 1 SI Leadings sign statement. You can change blanks, commas, decimals points, and
dollar signs into some other character by placing Ihe new character In
A symbol shows that a dollar sign will be printed m Ihe
dollar sign (S) the correct position in the PUDEF control string.
number you wani
If the dollar sign to float (always be placed before trie
number), you mus! specify at least one # before Ihe dollar sign If you
Position 1 is the filler character. The default is a blank Place a new
specify a dollar sign without a leading 0, the dollar sign is printed in the
character here when you want another character lo appear in place of
position shown in the format fietd.
blanks.

If you specify commas and/or a plus or minus sign in a format field with
a ooilar sign, your program prints a comma or sign before the dollar Position 2 is Ihe comma character. Default is a comma
Position 3 is the decimal point

The lour up arrows or carels (tnt) symbol Is used to specify mat the Position A is the dollar sign.
number is to be printed In E + format. You must use # >n addition to
the Iff T to specify the field width. The TTT1 must appear after the # in
the format field
EXAMPLES

10 PUDEF " p- ispace PRlNTs " in the place of blanks.


You must when you want to print a number
specify four carels (tTTT) in 20 PUDEF "'&" PRINTS & in place of commas.
E -fo'mat (scientific notation) If you specify more than one but fewer 30 PUDEF" ," space PRINTS decimal points in place ol
lhan four carets, you get a syntax error. you specify more than four If
commas, and commas in place of
carels only the first four are used The llfth caret (and subsequent decimal points
carets) are interpreted literally as no text symbols 40 PUDEF "T.E* PRlNTs English pound sign in place of $,
decimal points in place of commas, and
An equal sign (») is used 1o centre a string in the field. You specify the commas in place of decimal points.
fieldwidth by the number of characters (# and ») in the lormal field If
the string contains fewer characters than the field width, the string is
!
centreed in the field. If the string contains more characters than can be
fit Into the field The right-most characters are truncated and the string
fills the entire field. READ

A greater than sign ( > ) is used to right justify a string in a field. You READ variable list

specify the field width by the number of characters (# and =) In the


format field. If the string contains fewer characters than the field width, This statement is used to get information DATA statements into
from
the string is right justified in the field. If the string contains more variables, where the data can be used. The READ statement vaiiabte
characters than can be lit into the field, the right-most characters are list may contain both strings and numbers. Care must be taken to avoid
truncated and the string tills the entire field reading strings where the READ statement expects a number, which
produces an ERROR message
EXAMPLE:
PUDEF READ AS, GS, Y

PUDEF "1 through 4 characters"

.VI
I
135
REM Usea to return to execution after TRAPping an error. With no
arguments. RESUME attempts lo re-execute the line in which Ihe error
occurred. RESUME NEXT resumes execution at Ihe next slatement
REM message following the slatement containing the error; RESUME line will GOTO
the specific Ime and begin execution the/e.
The REMark a nolo (o whoever Is reading a LIST ol Ihe program
is jus!
ll may explain a section of Ihe program, give informalion aboul Ihe
aulhor, elc.REM stalemenls In no way effort Ihe operation of Ihe
program, except to add to ils length (and therefore slow il down) The
word REM may be followed by any text, although use of graphic
characters gives strange results.
RETURN

RETURN
EXAMPLE
This statementis always used with the GOSUB statement Whan Ihe

10 NEXT X: REM THIS LINE IS UNNECESSARY program encounters a RETURN statement, goes to trie statement
II

immediately following the lasl GOSUB command executed. If no


GOSUB was previously issued, then a RETURN WITHOUT GOSUB
ERROR message is delivered, and program execution is stopped

RESTORE

RESTORE [line #]
SCALE
When executed in a program, the pointer to Ihe item in a DATA
slatement which ts lo be read next is reset to the first ItBm in the Irst SCALE <l/0>
This gives you the ability to re-READ the information II a pine #]
follows the RESTORE statement, the pointer is sat to that line
The scaling of Ihe bit maps in multicolour and high resolution modes
Otherwise the pointer Isreset lo the first DATA statement In Ihe
can be changed with Ihe SCALE command. Entering:
program.

EXAMPLE: SCALE 1

RESTORE 200 turns scaling on. Coordinates may then be scaled from lo 1 023 In
both X and Y rather than the normal scale values, which are.

multicolour mode X - to t59 Y =• lo 1 99

high resolution mode. ... to 31 to 1 99


RESUME
Scaling can be turned off by entering 'SCALE 0'.

RESUME [line* | NEXT)

136 137
SCNCLR SSHAPE/GSHAPE
I

SCNCLH SSHAPE and GSHAPE are used to save and restore rectangular areas
of multicolour or high resolution screens using BASIC string variables.

Clears the current screen, whether graphics, text, or both (split screen). The command lo save an area Is;

SSHAPE string variable, a1 ,bt t.a2,b2|

stnng variable .Siringname to save data In


SOUND a1.bl ... . .Corner coordinate (scaled)
a2,b2 .... . .Corner coordinate opposite (at ,bl ) (default «s the
SOUND voice #, frequency control, duration PC)

This statement produces a SOUND using one at three voices with a Because BASIC limits siring lengths to 255 characters, the size of the
frequency control in the range 0-1023 lor a duration ot - 65535 60ths area you may save is limited. The string size required can be
oi a second calculatea using one of (he following (unsealed) formulas:

Voice
L<mcm) - INT( (ABS(a1-a2) + 1) I 4 + 99) • <ABS(b1-b2> + 1) + 4

1 Voice 1 (tone) Uh-0 - INT((ABS<ai-a2) + 1J/8+ .99) • (ABS(b1-b2> + 1) + 4

2 Voice 2 (tone)
3 Voice 2 (white noise) (mem) refers lo multi-colour mode; (h-r) Is high tesolulion

It SOUND (or voice N is requested, and the previous SOUND tor


a the The shape saved row by row. The last four bytes ol the string
is

same N is still playing. BASIC watts for the previous SOUND lo contain the column and row lengths less one (I.e.: A8S (a1-a2) ) in low/
oomplete. SOUND with a duration of is a special case. causes It high byte format (if scaled divide the lengths by 3.2 (X) and 5.1 2 (Y) ).
BASIC to turn oft the current SOUND for that voice immediately,
regardless of the time remaining on the previous SOUND See the The command lo display a saved shape on any area of the screen
MUSIC NOTE TABLE In the appendix for the frequency control values
that correspond to real notes
GSHAPE string variable name [. la.b] [.mode] J

EXAMPLE: string . . Contains shape to be drawn


a.b . .Top let! coordinate telling where to draw the shape
SOUND 2, 800, 3600
Plays a note using voice 2 with (scaled - the default is the PC)
frequency set at 800 for one mode Replacement mode:
minute 0. placeshape as is (default)
1 place field Inverted shape
:

2; OR shape with area


3; AND shape with area
4: XOH shape with area

138 (
139
EXAMPLES:
TRAP
SSHAPE "VARIABLES", 0, Saves screen area from me upper
left corner lo where me cursor is
TRAP (lineal
positioned under me name
VARIABLES. When turned on TRAP intercepts all error conditions (including Ihe
ntm/STOP key) except "UNDEF'D STATEMENT ERROR" Intneeveni
GSHAPE "VARIABLES".,,! of any execution error, tne error flag is set, and execution is transferred
DisplaysVARIABLES shape with
background and foreground colours lo the line number named in the TRAP statement. The line number in

reversed, with me loo left ol me which Ihe error occurred can be tound by using me system variable EL.
snope positioned at the cursor The specific error condition is contained In system variable ER. The
string function ERRSfER) gives the error message corresponding to any
error condition ER,

NOTE: An error m a TRAP routine cannot be trapped The RESUME


STOP statement can be used loresume execution. TRAP with no line*
argument turns oft error TRAPping.
STOP

This statement halls the program. A message. BREAK IN LINE *


where the # is the line number containing me STOP The program can
be re-slarted at the statement following STOP you use the CONT
It

command. The STOP statement is usually used while debugging a TRON


pfogram.

TRON

TRON used in program debugging This statement begins trace


is

mode When you are in trace mode, as each statement executes, the
line number of Ihat stalement is printed
SYS

SYS address

The word SYS is followed by a decimal number or numeric variable m TRQFF


the range to 65535. The program begins executing me machine
language p'ogram stantng at thai memory location. This is similar lo
the USR function, but does not pass a parameter. See the TROFF
Programmer's Reference Guide tor information about machine
language programs. This statement turns trace mode off.

140 141
VOL LOCATE +100,-23 moves the PC right 1 00 pixels and up
25
VOL volume level
DRA Wl + 10, + 10TO100, 100
,
draws a line 1 pixels right and 1
pixels below Ihe current value of Ihe
Seis Ibe current VOLume level (or SOUND commands. VOLume may PC to the absolute point 100.100
be set from to 8, where 8 is maximum volume, and is off. VOL
affeels both voices
I
You can also specify a distance and and angle relative to the current
PC by separating the two parameters by a semicolon
f
For example:
WAIT (
LOCATE 50;45 moves the PC from its current location
by a distance of 50 dots at an angle of
WAIT address, value 1 (. value 2]
I ( 45 degrees.

The WAIT statement is used to halt the program until the contents ol a I

location in memory changes in a specific way The address must be In


the range from to 65535 Value 1 and value 2 must be in the range
from to 255.
(
FUNCTIONS
f

The content of the memory location is first exclusive-ORed with value 2 Numeric Functions
(if and Ihen logically ANDed with value 1
present), the result is zero,
It

the program checks the memory location again When the result is not I
Numeric functions are classified as such because Ihey return numbers.
zero, the program continues with the next statement. The functions they perform range from calculating matnematical
! functions lo specifying a screen location Numeric functions follow the
form.
f

Additional Graphic Statement Information FUNCTION (argument)

There are a few concepts that apply to ail ol the bit map graphics where the argument can be a numerical value, variable, or string

statements First is the concept of the Pixel Cursor (PC). The PC Is


similar to the cursor in text mode; it is the position where the next dot is
to be drawn. Unlike the text cursor, the PC is invisible. All drawing ABS(X) (absolute value)
commands use Ihe PC In addition, the locate command allows you to
reposition Ihe PC without drawing anything argument
The absolute value function returns the magnitude of the X.

Wherever you would use X, V coordinates in a drawing command, you


can use RELATIVE coordinates instead. Relative coordinates are based ASC(X$>
on the current value of the PC To use relative coordinates, just place a
+ or - in front of your coordinates. A plus sign before the X value This function returns the ASCII code (number) of the first character of
moves the PC to Ihe right A minus sign before the X value moves the
X$.
PC to the left. Similarly, a minus sign before Ihe Y coordinate moves
the PC up, while a plus sign moves the PC down. For example:

I
142 143
INSTB string 2 [.starting-position])
ATN(X) (arclangeni) (string 1 .

Returns position of string 2 in string 1 ai or after Ihe (starting-position]


Returns the angle whose tangent is X. measured in radians.
The starting-position defaults lo the beginning of string 2 If no match is

found, a value of is returned

EXAMPLE:
I

COS(X) (cosine)

PRINT INSTR("THE CAT IN THE HAT", "CAT")


Returns the value of the cosine ol X, where X is an angle measured In
radians.
I
Ihe result is 5, because CAT starts at the fifth cnaracter in string

DEC (he*adecima>-string) INT(X) (integer)

Returns decimal value of hexadecimal-string (0< nexadeclmal- Returns Ihe integer portion of X. with all decimal places to the right of
slrlng<FFFF)
I
the decimal pc-nl removed. The result is always tess-than or equal to
X, Thus, any negative numbers with decimal places become
the
EXAMPLE:
Integer icss-than their current value (e.g. INT(-4.5)--5)
I

N=DEC("F4")
f
If the INT function Is to be used lor rounding off, Ihe form is INT(X + .5)

or INT(X - .5).

EXAMPLE;
EXP(X)

X = INT(X-100 + .5J/10O Rounds to the next highest penny


Returns Ihe value of the malhemaOca! constanl o (2.71 8281 83) raised
lo the power of X.

JOY <n)
(
FNxx(x)
When n - 1 Position of joystick #1
n 2.. - Position ofioystick #2
a DEF FNxx
-
Returns Ihe value ol Ihe user-delined lunction xx created In
statement
Any value of 1 28 or more means Ihe fire button is also depressed. The
-

direction is indicated as loPows .

144 I «S
r
UP N-OtorXPOS
fire= 128 + I for YPOS
1

8 2 colour source
LEFT 7 3 RIGHT
6
5
DOWN RGB(X)
EXAMPLE: (

Returns current grannie mode (X Is a dummy argumenl and can be any


IOY{2) with value value.)
ol 135 fires joystick #2 lo the lett I

[ I RLUM(N)
LOG(X) (logarithm)

Returns current luminance level assigned to colour source N


I I

This returns the natural log of X The natural log is log to the base e
(see EXP(X)J To convert to log base 0, divide by LOGO 0).
1

I
I RND(X) (random number)

PEEK(X) Thi6 function returns a random number between and 1 This is useful .

1 ,11
in games, to simulate dice roils and other elements of chance, and is

This (unction gives tne contents ol memory location X, where X is also used ir some statistical applications. The first random number
I I
located in the range ol should be generated by the formula RND(-TI), to stan things off
to 65535, returning a result from to 255. This
differently every time. After this, the number In X should be a 1 or any
is often used in conjunction with the POKE statement.
.

I
I
positive number. (X represents the seed, or what the RaNDom number
is based on If X is zero. RND is re-seeded from the hardware clock
)

I
i
every time RND is used. A negative value lor X seeds the random
number generator using X and gives a random number sequence. The
RCLR(N) [ ( use o' the same negative number for X as a seed results in the same
sequence of random numbers. A positive value gives random numbers
Returns current colour assigned to source N (0 =< N=< 4) I I
based on the previous seed.
(0-background, -foreground. 2=multicolour
1 1, 3=multicolout 2.
4= border)
1
I
To simulate the rolling of a die, use the formula INT(RND<1 J*6+l ). First
the random number from 0-1 Is multiplied by 6. which expands the
1 1 range lo 0-6 (actually, grealer than zero and less then six) Then 1 is

added, making the range 1 to under 7 The INT function chops off all

RDOT(N) 1 t the decimal places, leaving the result as a oigit from 1 to 6

Returns Information about the current position of the pixel cursor (PC) at
1 1
To simulate 2 dice, add two of the numbers oblained by the above
XPOS/YPOS. lormula together
i r

i
46 i i
1 47
f

EXAMPLE. USR(X)
'

100X=lNT(RND(l)-6)+INT(RND(l)*6)+2 Simuiales 2 dice. When used, the program lumps to a machine language
this function is
program whose starting point is contained in memory locations 1281
I

100 X = rNT(RND(l)'1000)+l Number from 1 -1 000.


100X+INT(RND<1)*150) + 100 Number from 100-249. and 1 282 The parameter X Is passed to the machine language
I
program in ihe floating point accumulator. Another numoer is passed
back to the the calling variable. In other
BASIC program through
I words, this allows you to exchange a variable between machine code
and BASIC. See the Programmer's Reference Guide lor more details
! on this, and on machine language programming
SGN(X) (sign)

This function returns the sign, as In positive, negative, or zero, ot X. The


result is + 1 it positive. II zero, and - 1 it negative
I

VAL<XS)
I

This function converts Ihe string X$ Into a number, and Is essentially


I the inverse operation trom STRS The string is examined from Ihe left-

SW<X) {sine) most character lo Ihe right, tor as many characters as are In recognizable
f number format. If the Commodore 16 lirvds illegal characters, only the
portion ol the siring up to that point Is converted
This Is the trigonometric sine tunction. The result is the sine of X.

where X is an angle In radians,


EXAMPLE:

10X«VAL("123.4S6") X-123.456
SQR(X) (square root)

10X=VAL("3E03") X=3000
This function returns the square root of X, where X is a positive
number or It X is negalive. an ILLEGAL QUANTITY ERROR results.
10X*VAL{"12A13B") X-12

10X = VALTRIUO17-") X=0

TAN(X) (tangent)
10X-VALT-1.23.23.23") X— 1 .23

This gives the tangent of X. where X is an angle in radians.

US 149
String Functions MIDS(X$,N,X)
I

This returns a string containing X characters, starting from the Nth


String luncnons differfrom numeric functions in thai Ihey return
character in XS. MIDS can also be used on the left side of assignment
characters, graphics or numbers from a stnng (defined by quotation I

statement as a pseudo-variable as well as a function. MIDS {string


marks) instead of a number.
I
variable, starting position, length) = source siring.

This function reassigns values of positions (starting position) through


CHR$(X) (starling position+ length) of source string to the characters of string
I

variable in corresponding locations. Length defaults to the length of


This function returns a string character whose ASCII code is X. string variables, and an error results If (starting position + length) is
[
greater than the length of the source string.

EXAMPLE
ERR$(N) I

Returns string describing error condifion N (see TRAP) I 10 A$-"THE LAST GOODBYE":
20 PRINT AS
f
30 MIDS(AJ,6,3>="ONG"
40 PRINT AS

HEXJ(N)

Returns a 4 character string containing the hexadecimal representation


of value N (0 < N < 65535)
I
RIGHTS(XS,X)

This returns the right-most X characlers In XS


LEFT$(X$,X)

This returns a string containing the leftmost X characters of X$.

STR${X)

LEN(X$)
This returns a string which is identical to the PRINTed version of XS.

Returns the number of characters (including spaces and other symbols) EXAMPLE
in tne siring X$
AS=STR$(X)

1
50 15i
i

Other Functions Normal NUMERIC VARIABLES, also called floating point variables.
can have any value Irom 30 to * M with up to nine digits of accuracy.
,
i
When a number becomes larger than nine digits can show, as In
FRF. (X) 10' ,0 or 10 *'° your computer displays In scientific notation form,
It
,
l
wilh the number normalized to 1 digit and eighl decimal places,
This function returns the number ot unused bytes available in memory, followed by the letter E and the power ot ten by which the number is
X is a Gummy argument. multiplied. For example, the number 1 2345678901 is displayed as
1.234356789E + 10.

POS (X) INTEGER VARIABLES can be used when the number Is trom +32767
to -32768, and with no fractional portion An integer variable is a
number of the column (0-39) where the next
This function returns the number like 5, 10, or -100. Integers take up less space than floating
l

PRINT staiement begins on the screen X Is a dummy argument. po«nt variables when used in an array.

STRING VARIABLES are those used for character data, which may
SPC(X) ( contain numbers, letters, and any other character that your Commodore
1 6 can make. An example of a string variable is "COMMODORE 1
6".

(
This is used in the PRINT staiement to skip over X spaces. X can have
a value trom 0-255 VARIABLE NAMES
Variable names may consist ol a single letter,a letter followed by a
number, or two letters Variable names may be longer than 2
I
traders, but only the first Iwo are significant
TAB (X)

This used in the PRINT statement. The next item to be


is printed is in An by using the percent f %) sign after the
integer variable is specified
column number X. X can have a value from to 255. I
variable name. String vanaoles have the dollar sign (S) after their
names
I

TT (PI)
EXAMPLES:
The pi symbol, when used in an equation, has the value ol 3.1 41 59265, I

Numeric Variable Names: A. A5, BZ


(

Integer Variable Names: A%. A5%. BZ%


VARIABLES & OPERATORS String Variable Names: AS A5S. BZ$
[

Variables
ARRAYS are lists ot variables with the same name, using an extra
!
number (or numrjets) to specify an element ot tne array. Arrays are
Your Commodore 16 uses three lypes ol variables in BASIC. These defined using the DIM statement, and may be floating point, integer, or
are: normal numeric, Integer numeric, and string (alphanumeric) [ string variables arrays. The array variable name <s followed by a set of
variables. parentheses ( } enclosing the number of the variable in the list

I I
153
1

1
1

1 1
EXAMPLES: A(7).BZ%<1 1),AS(87)
The variable DS reads the disk drive command channel, and returns the
Arrays may have mote lhan one dimension. A two dimensional array 1 current status of the drive. To gel this Information In words. PRINT
may be viewed as having rows and columns, with the first number DSS. These status variables are used after a disk operation, like a
Identltylng the column and the second number in the parentheses 1 1 DLOAD or DSAVE. to find out why the red error light on the disk drive
is blinking.
Identifying the row {as it specifying a certain grid on a map)
1 1

EXAMPLES: A(7.2) BZ%(2.3,4)7S<3.2) ER, EL. and ERRS are variables used in error trapping routines. They
are usually only useful within a program ER returns the last error
1
1
encountered since the program was RUN. EL is the line where the error
RESERVED VARIABLE NAMES occured. ERRS is a function which allows your program to prinl one of
There are seven variable names which are reserved for use by the 1 1
the BASIC error messages. PRINT ERRS(ER) prints out the proper error
Commodore '6. and may not be used for another purpose. These are message.
the variables DS, DSS. ER, EL. ST.TI, and TIS. You also can'i use 1
1

KEYWORDS such as TO and IF, or any names that contain BASIC OPERATORS
KEYWORDS, such as SRUN. RNEW, or XLOAD as variable names. 1 1

Tne ARITHMETIC operators include the following signs


1 1
ST a status variable lor Input and output (except normal screen/
is

keyboard operations). The value of ST depends on the results of the


+ addition
last input/output operation. A more detailed explanation of ST is In the
1 1
- subtraction
Series 264 Programmer's Reference Guide, bul in general, the value
if * mu Implication
of ST is the operation was sucessful 1
1
/ division
T raising to a power (exponentiation)
1 !
Tland Tis are variables that relate to the real-time clock built Into your
Commodore 1 6 The system clock <s updated every /60th of a On a line containing more lhan one operator, there is a set order in
I
which operations always occur. If several operators are used together,
secooa starts at
It when your Commodore 1 6 Is turned on and is
the computer assigns priorities as follows; First, exponentiation. Ihen
reset only by changing (he value of Tl$. The variable Tl gives you the
I multiplication and division, and last, addition and subtraction If two
current value of the clock in 1 /6Qlhs of a second. (
operations have the same priority, then calculations are performed in
order from left to right. If you want Ihese operations to occur In a
f 1
different order, Commodore 16 BASIC allows you to give a calculation
TIS is a reads the value of the real-time clock as a 24 hour
string that
a higher priority by placing parentheses around it. Operations enclosed
clock The first two characters
of TIS contain the hour, the 3rd and 4th (
in parentheses will be calculated before any other operation. You have
1

characters are the minutes, and the 5th and 6th characters are the
to make sure that your equations have the same number of left
seconds. This variable can be set to any value (so long as all characters
I
I
parentheses as right parentheses, or you will gel a SYNTAX ERROR
are numbers), and will be automatically updated as a 24 hour clock
message when your program is njn.
1 !<
There are also operators for equalities and inequalities, called
EXAMPLE: TIS = "101530" sets the dock to 10 1 5 and 30 seconds RELATIONAL operators Arithmetic operators always take priority over
(AM) 1 1

relational operators.
'

The value your Commodore 16 is turned off It


of the clock is lost wnen I
is equal to
slarts at zero when your computer is turned on, and is reset to zero
< is less than
when the value of the clock exceeds 235959 (23 hours. 59 minutes and 1 > greater than
1
is
59 seconds). <= or <
= < Is less than or equal to
I 1

f
1 155
>= o, => | S greater lhan or equal to
<> or >< is noi equal lo
BASIC Abbreviation and Reference Chart
Finally, there are three LOGICAL operators, with lower priority than KEYWORD '.V-i.f ./|.^ ON TYPE
both arithmetic and relational operators; ABS a SHIFT 6 tunction— numeric
AND ASC a SHIFT s function— numeric
OR ATN 3 SHIFT T luncllon— numeric
NOT AUTO a SHUT U command
BACKUP b SHUT A command
BOX b SHIFT statement
These are used most often lo Join multiple tormulas in IF . . .
THEN CHAR ch SHIFT A statement
statements. When they are used with arithmetic operators, they are
CHR$ c SHIFT H lunctton— string
evaluated last {i.e after + and -)
CIRCLE
,
i
c SHIFT 1 statement
CLOSE cl SHIFT statement
EXAMPLES; CLR c SHIFT L statement
CMD c SHIFT M statement
IFA=BANDC=DTHEN100 requires both A-B & C-D to be l COLLECT col SHIFT L command
true COLOR CO SHIFT L statement
CONT c SHIFT command
IF A = B OR C=D THEN 100 allows either A=B or C-D to be COPY CO SHIFT P command
true COS none (unction— numeric
DATA d SHIFT A statement
A-S:B-4:PRrNTA=B displays a value ot
DEC f Or e function— numeric
A-9:B«4:PRINTA>B displays a value ot -1
DEFFN d SOTT E statement
DELETE de SHIFT L command
PRINT 123 AND 15:PRINT 5 OR 7 displays 11 and? DIM d SHIFT 1 statement
I DIRECTORY di SHIFT R command
DLOAD d SHIFT L command
DO none statement
DRAW d SHIFT R statement
DSAVE d SHIFT S command
END e SHOT N statement
ERRS e SHIFT R tunction— string
EXP e SHIFT X (unction- numeric
•. j«_ p.
FOR I SHOT statement
FRE f SHOT R tunction- numeric
GET g SHIFT E statement
GETKEY getk SHIFT E statement
GET* none statement
GOSUB go SHOT S statement
GOTO g SHIFT statement
GRAPHIC SHIFT R statement

i
SB :
'

157
I

KEYWORD ABBREVIATION IYPC KEVWOHU A.BBfiEViA uon TYPE

GSHAPE wttn
I I RENAME re SHIFT N command
S statement
HEADER
g
he SHIFT A command RENUMBER ren FT U command
SHOT
I I
RESTORE re SfflFT S statement
HEXS h E function— string
RESUME res JHHFT U statement
IF.. GOTO none statement
..THEN none
i
:
i
RETURN re SHUT T statemenl
IF ELSE statement
INPUT none statement RGR SHIFT G function— numeric
INPUT* wmrr mem
i i
RIGHTS SHIFT (unction— string
( N state 1

INSTR in SHIFT S function— numeric


RLUM SHIFT L (unction— numeric
INT none function— numeric
i ,.|< RND SHOT N function— numeric
JOY SHIFT function— numeric
RUN SHFT U command
1

KEY SUFT command


i i
SAVE s SUFT A command
k E
LEFTS le SHOT F function— stnng
SCALE sc SHIFT A statemenl
none
i i
SCNCLR s SHIFT C statemem
LEN funct'on--numeric
LET SHIFT statement
SCRATCH sc SHIFT R command
1 E
LIST 1
SHIFT 1 command
1 1
SGN s SHWT G function— numeric
SIN s SHIFT function— numeric
LOAD I SHIFT command 1

LOCATE to SHIFT c statement


1 1
SOUND s SUFT statement
SPC( s SJHFT P (unction— special
LOG none function— numeric
LOOP lo SHIFT statement
1 1 SQR s SHIFT function— numeric
MID$ m SHIFT 1 function— string SSHAPE s SHIFT s statement
MONITOR m wan statement
1 1
STatus none reserved— numeric variable

NEW none command STOP s SHIFT T statement


NEXT n SHOT E statement
1 1
STRS St SUFT R function— string
ON...GOSUB on., go SHIFT s statement SYS s SUFT Y statement
1 TAB(
ON... GOTO on. .g SHUT statement
( 1 SHUT A (unction— special
OPEN SHITT P statement TAN none function— numeric
PAINT P SHIFT A statement
f I
Ti none reserved — numeric variable
PEEK P SHIFT E function — numeric ris
TRAP
none reserved— string variable
POKE P SWFT statement
I 1
t SHIFT R statement
POS none function— numeric TROFF (ro SHIFT F statemenl
PRINT ? statement
I 1 TRON tr SUFT statemenl
PRINT* P SHIFT R slatemenl UNTIL u SHIFT N statement
PRINT USING ?us SHIFT 1 statement
1 1
USR u SHIFT S function —special

PUDEF SHIFT U statement VAL none function— numeric


P
*
1
RCLR SUFT (unction— numeric
1
VERIFY V SHIFT E command
r C
RDOT r SHIFT D function —numeric VOL V SUFT statement
READ r SHIFT E statement
1
WAIT w SHIFT A statement
REM none statement
WHILE w SHIFT H statement
( (

1 (

1 58
1 f 1 S9
I

1 r

[ APPENDICES
1 ( Error messages

[ i
Disk error messages
i
Deriving mathematical (unctions
1

1 l
Musical note lable

1
[
• Screen display and ASCII codes
i
1

Book list

1 i

1 (

1 (

1 (

1
i

1 r

1 (

1 (

1 (

1 f

1 (

l
1

(
1

1
i

160 f '
161
F |t

1
1
APPENDIX A because of missing or extra
Error Messages 1 parenthesis, misspelled
These messages are printed by BASIC You can also PRINT
error keyword, etc
1

Ihe messages through the use of the ERRS() lunclion. Ttie error RETURN WITHOUT A RETURN slatement en-
1
12
number refers only to the number assigned to the error for use with GOSUB countered when no GOSUB
mis function 1
i statement was active

13 OUT OF DATA A READ statement en-


i
countered, without data
ERROR # ERROR NAME
left unREAD
1 TOO MANY FILES There is a limit of 10 files
OPEN at one lime
1
14 ILLEGAL QUANTITY A number used as ihe
argument of a lunction or
2 FILE OPEN An allempt was made to open 1 i statement is outside the
a file using Ihe number ol an allowable range
already open Tile. 1

1 1
15 OVERFLOW The result of a compu-
3 FILE NOT OPEN The file number specified In lation is larger than the
an I/O statement must be ( [ largest number allowed
opened belo'e use (1 70141 1833E+38)
4 FILE NOT FOUND No file wilh that name exisfs 1 (
16 OUT OF MEMORY Either there no more room
is
(disk) for program and program
5 DEVICE NOT PRESENT The required I'O device not
1 ( variables, or there are loo

available many DO, FOR, or GOSUB


1 I statements in effect
6 NOT INPUT FILE An attempt made to GET or
INPUT data from a file thai 17 UNDEF'D STATEMENT A line number referenced
was specified as output only 1 [ doesn't exist in the program

NOT OUTPUT FILE An attempt made to send ( f


16 BAD SUBSCRIPT The program tried to refer-
data to a file that was speci- ence an element of an array
fied as input only out ol the range specified by
1 ( ihe DIM statement
8 MISSING FILE NAME An OPEN, LOAD, or SAVE to
Ihe dis* drive generally re
f
19 REDIM'D ARRAY An array can only be DIMen-
os a filename.
1
stoned once. If an array is
referenced before that array
ILLEGAL DEVICE An attempt made to use a
is DIMd. an automatic DIM (to
f 1

NUMBER device improperly (SAVE to


10) is performed
the screen, etc.)
1 1

20 DIVISION BY ZERO Division by zero is not allowed


10 NEXT WITHOUT FOR Either loops are nesled in-
correctly, or there a variable
is f 21 ILLEGAL DIRECT INPUT or GET statements are
(

name in a NEXT slatement only allowed within a program.


that doesn correspond
t wilh
( f
one in a FOR
11 SYNTAX A slatement is unrecogniza- I I
ble by BASIC Thts could be

I
r

162 f f 163
.

i
K
!

22 TYPE MISMATCH This occurs when a number GRAPHIC command


is used in piace ot a siring or ( 1 was executed
vice-versa
36 BAD DISK An attempt failed to HEADER
23 STRING TOO LONG A string can contain up to 255 1 1
a diskette, because Ihe quick
characters. heaaer method {no ID) was
24 FILE DATA Bad data read trom a tape liie. ' 1 attempted on an unformatted
diskette. o r the diskette is bad.
25 FORMULA TOO Simplify the expression
COMPLEX (breaK inlo 2 pads or use
1 1

(ewer parentheses)
1 1
26 CANT CONTINUE The CONT command does
not work If the program was
not RUN, there was an error, 1 '

or a line has been edited.


1 1

27 UNDEF'DFUNC A user defined function refer-


enced that was never defined.
1 1

28 VERIFY The program on tape or disk


does not match the program 1
in memory
29 LOAD There was a problem loading 1 (

Try again

30 BREAK The stop key was hit to half 1 1

piogram execution
31 CAN'T RESUME A RESUME statement en- 1 1

countered without TRAP


statement in elfecl I
1

32 LOOP NOT FOUND The program has encoun-


tered a DO slatemenl and 1 1

cannot find the correspond-


ing LOOP 1 I

33 LOOP WITHOUT DO IOOP encountered without a


DO slatemenl active ( (

34 DIRECT MODE ONLY This command ts allowed


only in direct mode, not from
'
(

a program
35 NO GRAPHICS AREA A command (DRAW, BOX. 1 (

etc. ) to ceate graphics


encountered befo'e the 1 1

(
1

l 1

164 ( 1 166
1 !

1 r
APPENDIX B byte This message may also
indicate grounding problems.
Disk Error Messages 1 r
These error messages are relumed through the DS and DS$ 25 WRITE ERROR This message is generated il the
1 i
reserved variables (write- verify error) controller detects a mismatch
between the written data and ihe
NOTE ;
Error message numbers less lhan20 should be ignored
1 i
data in the DOS memory
with the exception ol 01 which gives inlormation about the num-
,
1 i 26 WRITE PROTECT ON This message is generated when
ber of tiles scratched with the SCRATCH command Ihe controller has been requested
1 to write a data block white the

20 READ ERROR The disk controller is unable to lo- write protect switch is depressed

(block header not found)


'
Typically this is caused by using
cate the header ol the requested 1 )'
data block Caused by an illegal a diskette with a write protect
sector number, or the header has lab over the notch
1 i

been destroyed
27 READ ERROR The controller has delected an
i header
21 READ ERROR The disk controller is unable to
1

(checksum error error in the ol the re-


(no sync character) detect a sync mark on the desired in header) quested daia block The block
track Caused by misalignment of 1 i has not been read into the DOS
the read/writer head, no diskette memory This message may also
ispresent, or unformatted or im- 1 ( indicate grounding problems
properly sealed diskette. Can
also indicate a hardware failure ! i
28 WRITE ERROR The controller attempts to detect
(long data block) the sync mark ol the next header
22 READ ERROR The disk controller has been re-
after wnting a datablock. If the
( i
(data block not present) quested to read or verify a data sync mam does not appear within
block that was not property writ- a pre -determined time. Ihe error
ten This error message occurs
1 I
message is generated The error
is caused by a bad diskette formal
In conjunction with the BLOCK
commands and indicates an ille-
1 i
(the data extends into the next
gal track and/or sector request block), or by hardware failure.
1
i

23 READ ERROR This error message indicates that 29 DISK ID MISMATCH This message is generated when
(checksum error Ihere is an error in one or more ol 1 i
Ihe controllei has been requested
.n data block) Ihe data byles The data has been to access a diskette which has
read Into the DOS memory, but not been initialized. The message
the checksum over the data is tn
1
can also occur II a diskette has a
error This message may also in-
bad header
1
r
dicate grounding problems.
30 SYNTAX ERROR The DOS cannot interpret the
24 READ ERROR The data or header has been read 1 i
(general syntax) command sent lo the command
(byte decoding error) into the DOS memory, but a hard
channel Typically, this is caused
1
ware error has been created due I

lo an invalid bit pattern in the data


1 f

1 i
167
i

by an illegal number ol 'tie names,


turn which is senl as a record ter-
minator is counted in the record
oi patterns are illegally used For
size, this message will occur the
:

example, two file names may if

totalcharacters m the record (in-


appear on the left side ol the
cluding the final carriage return)
COPY command
exceeds ihe defined size.
31 SYNTAX ERROR The DOS does not recognize the i|

(invalid command) command The command must 52 FILE TOO LARGE Record position within g relative
start in Ihe first position. file indicales that dish Overflow
will result.
32 SYNTAX ERROR The command sent is longer than
(Invalid command) 58 characters 60 WRITE FILE OPEN Thismessage is generaied
when a write file lhat has not
33 SYNTAX ERROR Pattern matching is invalidly used been closed is being opened
(invalid die name) m the OPEN or SAVE command I' for reading
f

34 SYNTAX ERROR The name was left oul of a


file 61 FILE NOT OPEN This message is generated wn en
(no file given) command or Ihe DOS does not a being accesseq that has
file is

recognize il as such. Typically, nolbeen opened in the DOS.


a coion(;) has been left out of I
Sometimes, in this casft. a mes-
the command sage is not generated; the re-
quest is simply ignored.
(
.-" SYNTAX ERROR may result the com-
This error if

(invalid command) mand sent to command channel 62 FILE NOT FOUND The requested file does nol exist
(secondary address 15) is unrec- I
on the indicated drive.
ognized by the DOS
63 FILE EXISTS The file name of the file being
(
50 RECORD NOT PRESENT Result of disk 'eading past the created already exists on the
last record through INPUT*, or diskette.
I

GET# commands This message


FILE TYPE MISMATCH The lype does not match the
file
will also occur after positioning to
f file lype in the direciory en fy for
a record beyond end of file In a
|

the requested file


relative file II the intent is to ex-
f
pand the file Dy adding Ihe new 65 NO BLOCK This message occurs in conjunc-
record (with a PRINT* com- tion wilh ihe B-A command It

mand), the error message may be I


indicates that the block | be allo-
ignored. INPUT or GET should not cated has been previously allo-
be attempted after this error is de- cated The paramelers indicate
tected without first repositioning. the track and sector available
with the next highesl number If
51 OVERFLOW IN RECORD PRINT* statement exceeds the parameters are zero (0). then
record boundary. Informalion is all blocks higher in number are
truncated Since the carriage re- muse

168 169
66 ILLEGAL TRACK The DOS has attempted to ac- attempt is made to write upon a
AND SECTOR cess a track or block which does disk which has been formatted in

not exist in the format being used a non-compatible formal. (A utility

This may indicate a problem read- routine is available to assist in


ing the pointer to the next block converting Irom one format to
another) This message may a(so
67 ILLEGAL SYSTEM This special error message appear after power up.
TORS indicates an illegal system
track or sector 74 DRIVE NOT READY An attempt has been made to
access the Floppy Disk Drive
70 NO CHANNEL The requesied channel is not without any diskette present
(available) available, or all channels are in
use A maximum ol five sequential
files may be opened al one lime to
the DOS Direct access channels
may have six opened tiles

71 DIRECTORY ERROR The BAM does not match the


internal count Tiere is a problem
in BAM allocation or the BAM
the
has been overwritten -n DOS
memory To correct this problem
the diskette to restore
reinitialize
the BAM in memory Some active
files may be terminated by the

corrective action NOTE BAM =


Block Availability Map
72 DISK FULL Either tne blocks on the diskette
are used or the directory is at its
enlry limit. DISK FULL is sent
when two blocks are available
on the 1541 to allow the current
Me to be closed
73 DOS MISMATCH (73, DOS and 2 a»e 'ead compatible
1

CBM DOS V2.6 1541) but not write compatible. Disks


may be interchangeably read with
either DOS, but a disk formatted
on one version cannot be written
upon with the other version be-
cause the format is different This
error is displayed whenever an I

170 171
t

APPENDIX C APPENDIX D
Deriving Mathematical Functions Musical Note Table
Functions thai are nol intnnsic lo BASIC 3 5 may be calculated as 1
1 NOTE SOUND REGISTER VALUE ACTUAL FREQUENCY (HZ)
follows;
A 7 110
B
1

FUNCTION BASIC EQUIVALENT 118 1235


C 169 1308
SEC AN SEC<X)-i/COSW 1
D 262 146.8
COSECANT CSC<X)-1/SIN(X)
COTANGENT COT(X)-l/TAN(X)
E 345 164.7
INVERSE SINE ARCSIN<X)=ATN(X,<SOfi(-X-Xtl)) 1 f F 383 174.5
INVERSE COSINE ARCCOSIX)- -ATNiX/SQR G 453 195.9
( X'X.i;j.a.'2
[
I A 516 220.2
INVERSE SECANT ARCSEC<X>=ATN<X/SGR{X*X-l)> B 571 246.9
INVERSE COSECANT arccsc(X)=atn:x<sor<x-«
-|-)GN{X(-I'ai2)
. i

!
'

1
C 596 261.4
INVERSE COTANGENT ARCOT!X)-ATN(X).ir'2 D 643 293.6
HYPERBOLIC SINE SINH(X) E (EXP(X)-EXP|-X)K2 E 685 330
HYPERBOLIC COSINE I I
COSH(X)=<EXP(X)- *EXP( X]V2 F 704 3496
HVPERBOUC TANGENT TANH(X)-EXP(- X)/(EXPI«) - EXP
l-Wt+1
G 739 392.5
HYPERBOLIC SECANT SECH(X)-a(EXP(X).EXP( X))
1 1
A 770 440.4
HYPERBOLIC COSECANT C5CHtX)=?J (EXP(X)-EXP(-X)) B 798 4949
HYPERBOLIC COTANGENT COTH(X)-EXP( - XHEXP(X) 1 r C 810 522 7
INVERSE HYPERBOLIC SINE
-EXPt-X))*:-'-
ARCS1NH(X) = L0G(X SORfX'X • 1»
D 834 588.7
i

INVERSE HYPERBOLIC COSINE ARCCOSH(X) LOG(X. SORlX'X - 1)|


-
1 i E 854 658
INVERSE HYPERBOLIC TANGENT ARCTANH<X)=LOG(|l »X^i X))/2 F 864 699
INVERSE HYPERBOLIC SECANT ARCSECH(X)-LOG(*SOP '
i G 881 782.2
(
- X'X 1 !)• ll'X) A 897 880 7
INVERSE HYPERBOLIC COSECAN' ARCCSCH(X)-LOGl(SGN(XrSOR B
>'..H> i
911 989 9
1
INVERSE HYPERBOLIC COTANGENT ARCCOTH(X)-LOGl(X.U'|. \\y3
C 917 1045
D 929 1177
i
1
E 939 1316
F 944 1398
1 I G 953 1575

i The above table conlains the sound regisier values of toui octaves ot
notes The sound registei values are used as ihe second parameter
i :
ol the SOUND command To use the first note In the table (A — sound

'

1 (

i
[

1 f

172 1 1 173
register value 7) use The 7 as the second number afler the SOUND APPENDIX E
command—SOUND 1.7.30
Screen Display Codes
Use the following formula fo find the sound register values lor frequen-
The following chart lists all ol the characters built into the Commodore
cies other than those in the table:
character sets shows which numbers should be POKEd Into screen
It

SOUND REGISTER VALUE - 1024-(111860 781/FREQUENCY) memory (locations 3072 to 4095) to gel a desired character (Remem-
ber lo set color memory —2048 to 3071 ) Also shown is which char-
Both the table of sound register values arid the above formula are lor acter corresponds to a number PEEKed Irom the screen
NTSC televisions This Is the television standard used throughout the
United States and all ol Canada If you are in a country where PAL is Two character sets are available, but only one set at a time. This means
the television standard, you should use the following formula to calcu- that you cannot have characiers from one set on the screen at the
late new sound register values for the entire table same lime you have characters from the other set displayed. The
SOUND REGISTER VALUE = 1024— (11T840.45/FREQUENCY) sets are switched by holding down the shift and O keys
simultaneously.

From BASIC, PRINT CHR$(142) will switch to upper-case/graphics


mode and PRINT CHRS(14) switches to upper/iower-case mode.

Any number on the chart may also be displayed in REVERSE The


reverse character code may be obtained by adding 128 to the
values shown

174 175
SET I SETS POKE 5ET1 9ET? KKf SETI SET1 POKE SET! 5£T2 POKE sen SET 2 POKE SET! WT* POKE

(<> T 1 20 ( 40 < 60 D T 84 108

A a 1 U U 21 >
41 - 61 a U 85 109

B o 2 V V 22
*
42 > 62 & V 86 h! 110

c c 3 w w 23' f 43 7 63 o W 87 111

D a A X X 24 . 44 B 64 i* X 88 H 112

E B 5 Y y 25 - 45 a A 65 a V 89 ^ 113

F ( 6 z Z 26 , 48 m B 66 si z 90 ^r 114

G g 7 I 27 / 47
B C 67 b 91 H 115

H h 8 f 28 48
B 68 E 92 II 116

1 i 9 I
29 1 49 H E 69 ;i 93 LI 117

J i
10 I 30 2 50 F 70 s 8 94
-1 118

K k 11 - 31 3 51
D G 71 H K 95 119

L 1 12 SPACE 32 A 52 a H 72 SPACE i

96 H 120

M m 13 I 33 5 53
B I 73 E 97 U 121

N n M >
34 6 54
a J 74
B 98 j y
# 35 7 55 K 75 99 123
15 .
P P 16 1 36 8 56 L 76 D 100 a 124

Q Q 1? % 37 9 57
s M 11 101 Fl 125

R r 18 & 38 58 N 78 m 102
B 126

S s 19
i
39 i
59 79 a 103
B 127

P 80 a 104

B1 105

R 82 106

§ S B3 CB 107

Codes Irom 128-255 are reversed Images ol codes 0-127.

176 177
If

PRINTS CHRI PRINTS CHR» PRINTS CHRS PRINTS CHHS


APPEND
r* ^» r

ASCII ai id CHR- Codes


D 68
m 97
E 126
ffl
lfi5
i*»*v

E 69 i. 98
H 127 Ml 156
This appendix shows you what characters will appear [you PRINT ii

CHR$(X). (or all possible values of X li will also show the values ob-
F 70
B 99 128 157

tained by typing PAINT ASC(">'"). where X is any character you can G 71


B 100
f «
129 m 158
type. This useful in evaluating the character received in a GET
i
FLASR
ts H 72 '01 ON 130 CYN 159
statement converting upper/ lower-case, and printing c haracler
.

based commands (like switch to upper/lower-case) that could not 1 73


a 102
FLASH
OFT 131 5 PACE
J '» ^ - »
160
be enclosed in quotes J 74 ii
103 132 c 161

i
K 75
a 104 H 133 a 162

L 76 105 134 163


PWNT5 CHRS PRINTS CHRJ PRINTS CMRS PRINTS CMRS M 77 106 f5 135 164
"
17 34 3 51 N 78 107 136 165
i • 18 # 35 4 52 I 79 108 * 137 166
j >

2 SL P
s 3
3 K 19

20 %
S 36
37
5
6
53
54
|
,

Q
BO
81
109

110
'*

«
138
139 B
167

168

4 21 4 38 7 55 ' R 82 111 HELP 140 B 169

Bt 5 22 39 8 56 i
I
s 63
L] 112 «" «T™» '41 170
SWITCH TO
6 23 ( 40 9 57 T 84 113 UPPERCASE '42 CB 171

7 24 41 1
* 58 I U 85
- 114 143 . 172
DISABLES BITOT O 8 25
!

42 59 , V 86
Ii 115 1L» 144 ^ 173
ENABLES rairt O 9 26 + 43 < 60 *
w 87 116 1 145 v 174

10 ESCAPE 27 i 44 - 61 I
X 88 Lr 117 8S 146 _ 175

11 — 2B - 45 > 62 r v 89 118 147 r 176


'2 » 29 46 ? 63 z 90 D 119 148 S 177
imm 13 ~ 30 47 @ 64 I
1
91 +1 120 3 149 Q 178
SWITCH TO
LOWER CASE
, , m, 31 48 A 65 r c 92 CD 121 X 150 3.! 179
15 space
32 1 49 B 66 ] 93 122 a 151 1 180
16 1

33 2 50 C 67 T 94 ffi 123 m 152 181

95 E 124 i: 153 a 182


I L

i
i 96
CD 125
ES 154
n 183

178 1
179

a
29 J 1 6

APPENDIX G
INDEX
Books For Commodore Products
Conociing M slakes
The following lisis Include a sampling ol ihe computer and program- Abbreviations 62, 157-199 Erasing Ihe Screen 50
ming books available The title of ihe book is listed first, followed by the Addition 54 Une Earwig 46-49. 61-52
author and publisher. Animation 87-70
Airays 153-154
Commodore Books ASCII Codes APPENDIX F

VIC 20 Programmer's Reference Guide AU'Q Command 98 DATA Statement 11 3-1 U


t Dotasette Tape Recorder, 13. 31-32
Commodore 64 Programme' s Reference Guide DEF FN Statement 1 14
Commodore Plus/4 Programmer's Reference Guide DELETE Command 99
B Deleting Leller8 2Q,?1. 47-48
Mastering Your VIC 20
BACKUP Command 97 Denizing Mainemai«cai Functions
Four VIC 20 Computer Books
BASIC Encyclopedia 93-1 56 APPENDIX C
VIC Revealed, Nick Hampshire I

BASIC Ablxevialion and Reference Chart D<M Statement 1 1


VIC Games. Nick Hampshire 157-169 D -ucl Mode 46
VIC Graphics, Nick Hampshire BOX Siatement 77-76, 109-110 DtRECTOFlV Command 28. 39. 99- 100
Stimulaling Simulations for the VIC. C.W Engel 0r> Enor Messages appendix b
Disheltes 34-38
Introduclcn to BASIC, Part 1 and 2. Andrew Colin DIRECTORY Command 27. 39. 99-1 00
Commodore Software Encyclopedia. Third Edition Headenng 36-38, 101-102
Calculations 54. 56-57
Loading 35-36, 104-105
Order or Catainaiions 57
BASIC Programming Saving 38. 107-108
paienrhMes 57
Armchair BASIC. An Absolute Beginner's Guide lo Programming OlwWton 54
Cartridges 30-31
BASIC. Fox & Fox, Osbome/McGraw-Hii)
in Loading Cartridges 30-31
OLOAD Command 26, 36-38. KXH01
DO/LOOP; WHILE/UNTIL/EXIT 115-116
BASIC Handbook. Second Edition. Lien, Compusofl Memory E*pansion Port 6
DRAW Statement 74-75, 116
Basic Commodore 64 BASIC, Coan Hayden CwselWn 31-34 Di awing
Cassette Port 8,
Elementary BASIC, Leogard & Singer, SRA Loading Cassettes 32-33
Circles 78-80
Lines 74-76
How to Build a Program, Emmerichs, Dililhium Presa Saving an Cassette 33-35
Points 74-75
Instant Freeze-Dried Computer Programming in BASIC, Brown CHAR Siaiemenl 76-77, 110 Polygons 79-80
My Computer Likes Me When Speak in BASIC. Albrechi.
I
CHP4 Codes APPENDIX F Rectangles 77-78
CIRCLE Statement 78-80, 1 1 0l 11 DSAVE Command 26.
DilifhKim Press 38. 101
CLEAR/HOME Key 21. 50. 51
a Tree, Willis & Danley, DiMhium Press
Nailing Jelly lo Clearing the Screen 21 , 50, 73
The Programmer's Book of Rules, Ledin & Ledin, Lileti'iie CLOSE Slatemenil 12
Learning Publishers CLR Siatement 1 1
: ng {See Screen Editing)
Technical BASIC Kassab, Prentice-Hall
CMD Statement 1 1 2-1 1
I

END Stalemer.l 1 1 T
COLLECT Command 97-08 Entering Commands 46
Colour
Machine Language Programming Erasing Cnatacwa (See Screen Editing)
ChangmgColou'843-44, 70- '2 Erasing L'nes (See Screen Enilirig)
Machine Language 'or Beginners, Mansfield, COMPUTE 1
Books COLOR Statement '0-71.113
Error Messages 38. 38. APPENDIX A
Programming the 6502, Zaks, Sybex Colour Kays 23-25. fij-44
ESC Key 23, 51
6502 Assembly Language Programming. Leventhal, Osborne/ L drrnnance 71 Exponentiation 65
Mulb-colou' ModeSi -32
McGraw-Hill PAINT Siatement 80-81 , 1 28-1 29
I
6502 Micro Chart, Micro Logic Corp. Reverse 22 43-44
Printing
6502 Software Design. Scanlon. Sams COLOR Statement 70-71 113 Floating Poinl Variables GO-61 . 1 53
The &S02 Software Gourmet Guide & Cookbook. Findlay. Hayden I
Connectflo the Computer 9-1 FOR .
TO . . . STEP Siaiemenl
CQPV Command 93-39 117-118
(

'80 I 181


1 89 9 1

I (
Formatting a Diskette 36-38. 10 Numbera RETURN Key 1

Fractions 55 Decimals 55 Reverse Priitng 22 43-46


Joysticks 7
Functions Denying Mathematical Functions RF JarhS. 10
NL(nerc8l-62. 143-149 APPENDIX C RUN Command 106-107
Special 152 Fractions 55 RUN/STOP Key 19
Strrtg 150-151 Numenc Functions 6 1-62 143-149 RVS ON,OFF Keys 22. 43-4G
User Defined 82 KEY Command 102-103 Operators 54, 155-156
Function Keys 26-27 Older of Precedence 57
O Key 22. 45 Parentheses 57
Performing Caoulatlons 54. 56-57
CLEAR/HOME Key 21 SO .
51
Scientific Notation 55-56
Colour Keys 23
CTRL Key J^« -Defined Functions 62 S
GET Slalemenl 118-119 21
VanaOlas 60-61, 152-155
GETKEY Slalemenl 119 Cursor Keys 20 SAVE Command 33-34 38. 107-1 0B
GET* 5la!emenl r 9-1 20 ESC Key 23. 6t Saving p-ograms
GOSUB Statement 20 1
=LASH ON/OFF Keys 23, 46 On Cassette 33-34
GOTO Statement 44 120-121 Function Keys 28-27 On Diskette 36
G'apnic Modes Graphics Keys 25-26, 64-67 ON Statement I 26-127 SCALE Slalemenl 137
High Resolution 72-82 HELP Key 27 OrvOH Switch 7 Soeniil* Noiaion 55-58
I

Multi-coioui 81-82 INST/OEL Key 20-21, 47-48 OPEN Statement 127-128 SCNCLB Command 50. 73. 1 38
GRAPHIC Statement 72-73. 121 RETURN Key 19. *7 Operatois SCRATCH Command 108
GRAPHIC CLR Statement 122 RUN/STOP Key 19 I Logical 155-156
Scieen Display 42
OnpNn RVS ON/OFF Keys 22. 43-48 Mathematical 54. 155-156
Screen Deploy Codes APPENDIX E
Animation 67-70 SHIFT Key 1 8-1 Relational 54. 155-' 58
Screen Editing
BOX Siatemeni 77-78 SHIFT LOCK Key 19 I
Correcting Mistakes 46-49
CHAR Slalomont 76-77 Typing Mode 1
CLEAR/HOME Key 21 50.51
CIRCLE Stelement 78-80 I Clearing the Screen 50
DRAW Statement 74-75 PAINT Statement B0-8V 128-129 ESC Key 23. 51
H gn Resolution 73-82 Penaherats 12-10 INST/OEL Key 20-21. 47-48
Muttl-Co>omB1-82 LET Statement 1 24 Pi 19,55 Printing On the Screen 58-60
PAINT Statement 80-81 Commano 27. 103-104
LIST
P<*eiCurso* {PC) 142-^43 Scieen Wmoows 51-52
and Labels 74-76
Po-nis. Lines LOAD Command 32-33. 104-105 POKE Statemem 1 29-1 30 Serial Socket 9
I
Cuctesana Polygons 77-80
Srjjates. Loading Setting Up the Computer 9- 2
Power Supply 7-10
Us*ig Graph»c Keys 25. 64-67 Cartridges 30 Software
PrinivniG
QSHAPE Slalemenl 39 ' 40 1 Cassettes 31-33 I Printing on the Screen 43-49. 58-60 CaMrtrtge 30-31
Diskettes 35-36
PRINT Statement T30 Cassette 31-34
LOCATE Statement 125. 142-143 PRINT* Statement 1 31 Diskette 34-38
H Luminance. 71 l
PRINT USING Statemem i31-'.34
Souno
HEADER Command 38-38. Prim Zones 58-60
I0>-102 Musica Nole Table APPENDIX D
HELP Command 102 Programming Mode 46
M SOUND Slalemenl 85-87
HELP Kay 27 PUDEF Sialement 134-135
VOL Slalemenl 84
High Resolution Graphics 73-82 Mathematical Opetaiois 54. 155-156 Sound Effects
Memory Eipanslon Pod 8. 30 Music 87 88
MONITOR Statement - 25 Noise 67-88
I Monitors 10. 14 READ Statemem 1 35 SOUND Siatemeni
Mult<-<:olour Graphics 91-82 inai Operators 54. 55-1 56 Duration 86-67
IF THEN ELSE Statement 1

122-123 Multiplication 54 REM Slalemenl 1 36 Nole Frequency 85-86, APPENDIX D


Muse 87, 86-91 (See also Sound) RENAME Command 105 Voices 64-87
Immediate Mode 46
M'-scal Note Table APPENDIX D RENUMBER Commano 106 SSHAPE Slalemenl 139-t 40
lnc*iect Mode 46
INPUT Statement 23 1
Reso'vod Variable Names 1 54-1 55 STOP Statement 1 40
INPUT* Statement l 24
I
Reset Button 7, 50 Subtraction 54
Inserting Letters 20-21. 47-48
N RESTORE Statement 138 Switctws ana Sockets
INST/OEL Key 20-21, 47-48 NEW Command 50, 105 RESUME Statement 136-137 Cassette Poil 3-9
mlsger Variables 60-81 152-153 , NEXT SUIement 1 25-1 26 RETURN Statement 37 1 HlgruL ow Switch 8

182
I
(

I
Swlcnes and Sockets— cont TVCaW«6. 10
Joystick Sockett 7
II
Memory Expansion Port 9. 30 l

On/On* Switch 7
Uwt Defined Functions 62
Power Socket 7-9
Reset Bumy, 7. 50 V I

BF (TV) jack 8. 10 Variables


Serial Socket
B-9 Ftoatmp, Point Numeric 60*1 , 1 53 i

V>OeoSoctiel8,9. 11 Integei 60-61 . 153


SYS Statement UQ Tail String 6041 , t S3
Variable Names 1 52-1 53 I

VERIFY Command 08-109 1

VideoSocKeI8.9. 11
~BKt Siring Variables 50-61 , 1 S3
VOlume Statement 64-65. 142
fRAP Statement 141
rnoFF Statement 141 W I

TRON Statement '4' WAIT Stater^ent 1 42


Tioub«fihoctng Chart 11-12 Widows Si -52

184

You might also like