Skip to main content

Full text of "Commodore 16 User Manual (1984)(Commodore)"

See other formats


ig 



i i Cz commodore 

i ; USER MANUAL 



»: ■ 



a ■ 




Mh ' 

I ninni nioivFI ■ -.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. 

f S commodore 



I HHnK'R.Ruwt.\\vlil.iii.( orliY.NoriluHf.NNI7 IU\ 




£z commodore 



COMMODORE 16 
USER MANUAL 



Copyloitl (C» '964 by Commodore Electronics Limited 
All rights 'eservec 



Tils manua eorfaino copv'lQhtea and proprietory into'matton 
No pm! ol lite imliicaiion T\ay be reproduced stored in a 
reHleval system, or transmitted in any torm 01 by ary means, 
electronic, mechanical, photocopytnp,, roco'dmg 01 otherwise, 
without the prior written permission of Commodore 
0ectn)nM3 UmllM 



Commodore BASIC v 35 

Copyflhl (c) 1984 by Commodore Electron.cs Umtiod 

a" i Ignis reserved 

Copyr-gfii (c; 1977 by Microsoft, aJI lights rese'ved 



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 

Statements 109 

Fjnctlons 143 

Variables and Operators ... 152 

Abbreviation and Reference Chan 157 

APPENDICES .161 

Error Messages 1 62 

Disk Error Messages . 166 

Deriving Matnamatlcai Functions 1 72 

Musical Note Table 1 73 

Screen Display Codes , ... .178 

ASCII and CHRS Codes 178 

Booklist tag 



INDEX 



....... 1 



■ 



IB' 



■ 
I 












I 

I 



I 



I 



I 
I 
I 

I 

I 
I 
I 



I 



CHAPTER 1 



SETTING 

UP 



Unpacking your Commodore 1 6 



Getting to know the switches and sockets 



Setting up your Commodore 16 



Troubleshooting chart 



• Peripherals 



( 



t I 

I 
I 
I 



1 



r r 



UNPACKING YOUR COMMODORE 16 



Now ihat you've opened lie box containing your new Commodore 1 6 
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 6 

2 The power supply 

3 The TV cable 

A. The user manual (You've probably tound this, since 
you're reading il rlgnt now.) 

5. Olher assorted literature: 
Warranty card 



It you don't find ail these items in the box. check with your dealer 
immediately for replacements. 

Betore you connect anything, you should overtook these pictures of 
your computer. You can familiarize yourself with all trie outlets ana 
switches, so you can set up your computer system quickly and easily 



I 



GETTING TO KNOW THE SWITCHES AND SOCKETS 




The Right Side Of Your Commodore 16 



THE ON/OFF SWITCH 

Your Commodore 1 6 should be turned OFF when you install or remove 
cartridges or any peripheral device such as a printer or Datassette. 
There is a red power light located above the keyboard on the right, 
which lights up when power is on. 

THE JOYSTICK SOCKETS 

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. 

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 
any BASIC programs that were typed m. There are other ways lo reset 
your computer without erasing programs. These will be discussed in 
Chapter 4. 



6 



I 



1 



THE POWER SOCKET 

The end ol the power supply cable Ills in here Plug the other end into a 
standard electrical wall socket AFTER connecting the first end into your 
computer. 




The Back Of Your Computer 



THE MEMORY EXPANSION PORT 

Commodore 16 software cartridges plug in here. Before you insert or 
remove cartridges, make sure the power is OFF 

THE RF JACK 

This is where you plug in one end of the TV cable (the thin black cable). 
Only one end fits into this lack; the other end fits Into the TV serial 
socket. 

THE HIGH/LOW SWITCH 

This switch controls which television channel your Commodore 1 6 is 
on. This is primarily used for American TVs. 



8 



THE VIDEO SOCKET 

This Is where you plug in Ihe cable thai connects a monitor to your 
Commodore 16. If you hook up your computer to a television set. you 
won't need to use this. 

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 1 531 Datassette 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 
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 
power on everything (computer, TV, etc.) should be turned OFF until 
you are completely set up and ready lo go. 



1: Connecting The Power Supply 

• FIRST plug Ihe round end of the POWER SUPPLY into the power 
jack on me right side ol your computer. 



• THEN plug Ihe other end into an electrical socket on the wall. 



I 



9 



' 




2: Plugging In The TV Cable 

• Plug ore end of the TV cable (only one will fit) mlo Ihe serial socket 
on your TV 

• P'ug Ihe other end or me cable Into the RF fack on the back of your 
computer 




10 



' 






i 






I 



Connecting Your Commodore 16 To A Monitor 

If you'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 all wen| well, the red POWER light goes on, and this message 
appears on your screen 

COMMODORE BASIC V3 5 12277 BYTES FREE 
READY. 



The flashing cursor unoer ihe READY message tells you that your 
Commodo'e 1 6 is wailing lor you lo start typing The background 
colour is white, while Ihe letters are printed In black, with a light purple 
border around the screen 



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



TROUBLESHOOTING CHART 



Symptom 



Cause 



Remedy 



Indicator light nol 
ON' 



Computer not turned Make sure power switch is 



ON 

Power cable not 
plugged in 



Power supply not 
plugged in 



in ON posilion 

Check power socket tor 
loose or disconnected 
power cable 

Check connection with wall 
outlet 



Bad fuse m computer Take system lo authorised 

dealer for replacement of 
fuse 



11 



Symptom 



Cause 



Remedy 



No picture 



TV cable nol 
plugged In 

TV nol on 



Check TV cable connection 



Turn TV on 



Jom patlern on Cartridge nol 
TV with cartridge properly inserted 
in place 

Picture without Poorly tuned TV 

colour 

TV nol connected 
property 

Colour sei too low 
on TV or computer 



Reinsert cartridge after 
turning OFF powet 



Retime TV 



Cneck connections 



Adjust colour setting 



Picture OK, but no TV volume loo low 
sound 

Poorly tuned TV 



Adjust volume ol 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 this isn't possible, you can deal with the problem by pressing the 
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 
Commodore 16 that increase what you can do with your computer 
These accessories are available al your Commodore dealer, and allow 
you to use your computer lo the fullest. 






( 



r 



Peripherals give you the capability to save and store data, print out 
what appears onscreen (in black and white or colour), use software 
programs that are stored on cassette tape and tioppy diskelte. and give 
you a sharp, clear picture of your computer's display. 





To save or recall programs, you'll need a device lhai stores data 
can be recorded on and retrieved from both cassette tapes and 
diskettes. To use cassette tape software (and to record your own 
programs on cassettes), you'll need the Commodore 1 531. 



I lata 



12 



\ \ 



13 



DATASSETTE lape recorder For diskettes, Ihere are several DISK 
DRIVES that are suitable. Disk drives are typically fast and efficient lo 
use Disk drives that are compatible with your Commodore 1 6 are the 
Commodore models 1 541 and 1 551 




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 1 803. 





14 



I 



I 
) 
1 
f 



I 
I 
! 






When us»ng a wordprocesslng program or a graphics package on your 
Commodore 16. a printer will reproduce what is on the screen on 
paper Tnere are several models of Commodore printers available that 
work with your computer These include the MPS-801 , MPS-802, MPS- 
803 (with optional tractor-teed), and DPS-1 101 (letter quality) 









15 



! 
J 
J 

1 
! 
: 
I 
! 
I 
J 
1 
I 
J 
I 
( 



16 



I 
( 
I 
I 

f 

f 

I 

I 
f 

I 
I 

I 

I 
f 
1 



CHAPTER 2 



THE KEYBOARD 

• A tour of the keyboard 

• Special keys 

• Graphic keys 

• Function keys 

• The HELP key 



17 



A TOUR OF THE KEYBOARD 




Mosl ol the keys on your Commodore 16 keyboard are identical lo Ihe 
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 
the four separate cursor keys. This section will show you the extra 
features ol every key. including how to use the graphic symbols 
pictured on the fronts of many ol me keys With each explanation of 
Ihe different keys on your computer keyboard, you should find the keys 
ana pracfice using them. 

Using Your Keyboard Like a Typewriter 

When you ftrsl type letters on your computer, they appear as capitals 
on the screen The letters and numbers appear on the screen exactly 
as they appear on the face of Ihe key when you press the key by itself. 
Also, several olher keys {+. -. ■, @. *, and E ) may be typed 
alone. Most punctuation marks need lo be typed with Ihe shift Key If 
you want to do some "regular" typing, you can type in capital and 
lowercase letters {like you would on a typewriter) by pressing the 

shift key and the O -,ey at the same time. After you do this, all 
l etter k eys typed alone are printed in lowercase. When you press the 
start key along with a letter, you get a capital letter. Numbers and 
punctuation keys work the same as they would in regular (non-typing) 
mode To gel out of typing mode, just press the two keys shift and 

C* ) together again. 



KEY 



+ KEY = 



+ A 
+ A 



ENTER OR EXIT TYPING 
MODE 



= A 

- r 



SHIFT 



— Ebb\ 



1 

: I 

I 

I I 
1 ) ( 

I i I 

I I f 



I 

r 

i 

i 



18 



I 


■ 


1 1 


i 


i ; 


i 


I 


i 




I 




i 




1 


1 


i 


S 1 


I 



Special Keys 

Several keys on your Commodore 16 keyboard behave quite differently 
than any well brought-up typewriter key would even think of acting. 
These keys act lo enable other keys lo do things they wouldn't 
ordinarily do. or perform luncllons related lo Ihe business of computing. 
Your Commodore 1 6 keyboard also conlains special symbols not found 
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. 

RETURN 

You nave lo press Ihe BETtraM key at the end of each line of 
instructions you enter on your Commodore 16 keyboard You might 
think of this key as an ENTER key because ■WORK actually enters 
information and Instructions into your computer 



You've already come across an example of me SHIFT Key in aclion In 
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 
anything by Itself (Always the bridesmaid, never the bride ) The 
shift key allows you lo type capita! letters, graphic symbols, 
punctuation marks, and a few olher things— with a little help from 
another key You'll be seeing more of Ihe SOFT key's functions 
Ihroughout Ihis section, for things such as getting graphic symbols 

Tne shift lock key ig the same as the shift key. except lhal ll is 
locked into place, so you don't have lo hold it down. When 
SHFT LOCK is on, every character you type Is SHIFTED. To release 
the lock, |ust press SHIFT lock again, and everything you type is back 
to normal 

RUN/STOP 

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

When you hold down me SHIFT and roh/stop keys simultaneously. 
Ihe Commodore 16 loads and runs the first program on a disk in the 
disk drive. 



19 



The Cursor Keys 



(§@R 



I 



v 






The cursor, the (lashing block thai marks where you are on the 
computer screen, can be moved quickly and eas>ly around the screen 
by using the CURSOR KEYS. There are four separate cursor keys, 
each with an arrow pointing out the direction the key moves the cursor 
up, down, ielt. or right. You can use the cursor keys lo move the 
cursor over anything on the screen without affecting those characters. 
Like all keys on the Commodore 1 6 keyboard, each cursor key can 
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- 
press"). 



INST /DEL 



You can INSERT and DELETE letters and numbers from Ihe line you are 
typing with thts key. When you press (his key by itsell, the typed 
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 
erase a letter. When you do this, the letter to the left is deleted, and the 
rest of the letters on Ihe line move over one space to the left to close 
the gap. 



To o pen up space lo insert letters and numbers, type this key along 
with SHOT Space opens to the right of the cursor; the cursor tiself 
does not move When you insert space In the middle of a line of letters. 
Ihe rest of the line moves lo the right 



The ART/DEL «ey saves a lot of time when you want lo edit or change 
what you've lyped 



2C 



I 



' 



I 



f 

I 

' ( 
I 



KEY 



+ 



EFFECT 



INST/DEL 



SHIFT 



iKST/DEL 



DELETE (ERASE 
TYPED 

CHARACTERS) 
INSERT (ADD 
SPACES) 



SHIFT 




CLEAR HOME 



This key serves two primary functions: HOME and CLEAR. When you 
press this key alone, the cursor immediately moves to the top left 
coiner of the screen (which Is known as the HOME position). The resf 
of your screen stays Ihe same. If you hold down the SHOT key and 
press clem/home , not only does Ihe cursor move lo HOME, but 
everything on Ihe screen is erased (or cleared). All that remains on the 
screen is Ihe blinking cursor at the top left corner of the screen. 



KEY 



EFFECT 



CLEAR /ROME 

CLEAR-HOME 



cnit (Control) 



SHIFT 



HOME POSITION 
CLEAR SCREEN 

SHIFT 



i -CLEAR 
HOME 



\ 



The cm key is like the SHOT *oy in that it always works wiih another 
key. You must hold it down while you press other keys. CTBL is used 
in three instances. 

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. 

2) You can pause a program thai is PRINTing or LISTing on Ihe screen 
by pressing CTBl and Ihe S key 

(To re-slart the program, press any key except bun/stop ) 

3) CTBL is also used with reverse on/off and flash on/off 
Tnese are explained later In this section 

In addition, some software programs that you buy make use of the 
CTBL key for their own special functions. 



21 



(COMMODORE KEY) 



The Commodore Key Is very similar lo 
perform lour functions; 



, and can be used fo 



1) When used wllh the shut hey. Ihe O key lets you got into typing 
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 
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. 

4) When you want to slow down a scrolling d-splay (a program thai 
appears line-by-ilne on the screen but might be going by too fast to 
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) 



hvs on fivs OIT (Reverse On/OH) 

Your Commodore 1 6 lets you print the reverse image of letters and 
numbers. In other words, if your cursor is black and the screen 
background is yellow, what you tyoe appears in yellow letters on a 
black background. 

Here's all you do lo get reversed images. Press the ctbl key and the 
ivsoh key E ^erythlng you type ;>; now. displayed In revQRMh unM 
you press the cm and bts oft the hetuhn key. or the Etc key 

and O This returns you to typing normal (non-reversed) characters 



I I I I 
I 
I 
f 

1 ( 



I 



KEY 



EFFECT 



RVSOK 



REVERSE PRINTING 
ON 



CTRL 



- Est \ 



CTRL 



HVS QFF 



- NORMAL PRINTING 



CTRL 



w 

- E-OFF \ 



22 



i 
I 






( 



FLASH ON FLASH OFF 

You can make the characters on your screen flash on and off 
continuously, like the cursor Hashes. Press ctbl and the flash oh 
key to make whatever you type flash. Typing ctbl and flash off 
of RETUmi >i esc ,nd O makes your typing normal (non-flashing) 
again. 



KEY 



- EFFECT 



CTBL + FLASH ON 



CHARACTERS 
FLASH 



CTRL 




CTRL + rUUBOFF 

(Escape) 



NORMAL DISPLAY 






CTRL— f 1 - OFF 



The ESC key lets you perform many special screen editing functions, 
including functions to set up and manipulate screen windows. 
Windowing Is a special properly of your Commodore 1 6. which lots you 
set apart an area of Ihe screen that may be used as work space wttnoul 
affecting the rest of Ihe screen. The ESC key can perlorm several 
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. 



Colour Keys 





The colour keys bear a striking resemblance lo Ihe number keys from 1 
to 8. When pressed 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 



23 



Hashing black. When you lype anything. Ihe characters appear in 
black. To change Ihe cursor {and what you type) to a different colour, 
use Ihe colour keys On the Ironl ol the keys numbered from i to 8. 
there are two colours written Press cm along with a number key to 
get the colour fisted on top. at the O key with a number to get the 
colour on the bottom You can change only the colour of the 
characters using the colour keys. To change the screen background or 
border colour, you must use a BASIC command (More on that later.) 



NOTE: When changing colours be careful that you do not press the 
number (colour) key even a split second belore pressing cm or 
O II you do, all you'll do is print a number on the screen rather 
than change the colour 



KEY + 



■ EFFECT KEY + 






CTHl + 1 * BLACK + 1 = ORANGE 
crtC + 2 = WHITE Cf + 2 - BROWN 



CTRL f 3 = RED 



CTHL + 1 - CYAN 



+ 5 = PURPLE 



3 = YEUOW GREEN 



+ 4 = PINK 



+ 5 = BLUE GREEN 



+ 6 = GREEN C« + 6 - LIGHT BLUE 
CTRL + 7 = BLUE O + 7 = DARK BLUE 

+ 8 - YELLOW © + 8 - LIGHT GREEN 



24 



> ! 



( ! 



[ 



I 



f 



( 



I 



I 



1 


1 


1 


1 


1 


f 


I 


1 


1 1 


r 


1 1 


i 


1 1 


l 



Graphic Keys 

Each letler key (and a tew other symbol keys) on your Commodore 1 6 
has two boxes on the front of the key. each wrth a different tine, 
squiggle, Of symbol These are the graphic keys. When first turned on, 
your Commodore 1 6 prints capital letters. When you type one of these 
-• .'v ■! i .i 'j -villi the SHIFT or © key. you type the graphic symbols 
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 



KEY 



EFFECT 



+ A - ♦ (GRAPHIC ON RIGHT 

SIDE OF KEY) 
+ A = r (GRAPHIC ON LEFT SIDE 

OF KEY) 




SHIFT 



You can create pictures, charts, and designs by printing graphics side 
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 
how they work. Cnapler 6 explains more about graphics. 

When you're in typing mode, you can only use the graphic symbols on 
the left front ol Ihe keys (by pressing & and the appropnate key) The 
left side graphics are ideal for creating charts, graphs, and business 
forms, 



25 



Function Keys 



£ 

f 1 


\ 


f 4 


f 2 


\ 


f 5 


I f 3 


f] 


f 16 


I HELP 


-1 


V ,7 



Tne lour keys on the righi side ol 
your keyboard {apart Itom the 
resl ol Ihe keys) are special 
function keys ifiat let you save 
time by performing repelitlve 
(asks with the stroke of jus! one 
key. The top of each key reads 
fl , 12. t3. and HELP You can 
gel these functions by just 
pressing the key by itself. The 
fronts ol Ihe keys read 14. 15. te 
and f? Press shift and f; , f2. 
f3 and HELP, respectively, to gel 
Ihese (unctions 



Here's what each key does 



KEY1 



KEY 2 



KEY 3 
KEY 4 
KEY 5 

KEY 6 
KEY 7 
KEYS 



enters one of the GRAPHICS modes when you supply Ihe 
number ol the grapnlcs area ana press itntmN The 
GRAPHICS command is necessary for giving graphics 
commands such as CIRCLE or PAINT More on GRAPHICS in 
Chapter 6 

prints DLOAD" on me screen All you do Is enter the program 

name to load a program from disk and hfl BETUM instead of 

lyptng oul DLOAD" yourself. 

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

clears the screen using Ihe SCNCLR command. 

prints DSAVE" on Ihe screen All you do Is enter the program 

name to save Ihe current program on disk and press httuum 

RUNs the current program 

displays a LISTing of the current program. 

(Ihe HELP key) highlights errors In program statements In 

Hashing prml 



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 I f 

I | I 

I 

I i ( 

i 
i 
I 

I 

( 
i 

i i 

i 
i i 

I ! ( 
I 

: i 



the keys (rom BASIC programs, or change them al aiy time in direct 
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 
when you turn off your computer You can redefine as many keys as 
you want and as many times as you want 



The Help Key 






HELP 



ji 



17 \ 



When you make an error in a program, your computer displays an error 
message to tell you whal you did wrong These error messages are 
further explained in the Appendices In Ihe back of this manual 

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



?SYNTAX ERROR M UNE 10 

HELP 

10 PRONT "COMMODORE 

COMPUTERS" 



Your compuler displays this 
You press HELP 

The mistake ts displayed (lashing 
on and oil 



27 









I 

I 



I 

( 
I 
f 
( 

I 

! 

I 

I I 
I ( 

I 



I 






r 
i 
i 



i 
I 



2B 



I I 

I ( 

I I 

I I 

I I 

I ( 

I I 

( I 



CHAPTER 3 



SOFTWARE 



Introduction 



• Cartridges 



Cassettes 



Diskettes 






29 



INTRODUCTION 

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 
and the fun and diversion it affords you. Software is ail the programs 
that can be entered and run on a computer. The hardware (In this case, 
your Commodore 1 6) can use software m many forms: plug-in 
cartridges, pre-recorded tapes and diskettes. The family of software 
available tor your Commodore 16 is growing quickly Your cealer can 
keep you up-lo-date on new products and inform you aboul tne features 
of software that's currently available. 

Your Commodore 16 can use software on CARTRIDGE, CASSETTE 
TAPE, and DISKETTE form, available Irom your Commodore dealer. All 
you do is load them Into your Commodore 16. You can also create and 
store your own programs on cassette tapes or floppy disks. 

CARTRIDGES 

Commodore produces a full assortment of cartridge soltware for your 
Commodore 1 6. There is a variety of personal, education, and 
business programs, as well as exciting games available lor your 
Commodore 1 6. You don't need any additional equipment to use 
cartridge software; all you do is plug tne cartridge Into tne back of your 
computer and power on Here are the steps to follow to use cartridges 



Loading Cartridges 

STEP 1 Turn OFF your Commodore 1 6. 



IMPORTANT: YOU MUST TURN OFF YOUR COMPUTER BEFORE 
YOU INSERT OR REMOVE CARTRIDGES. IF YOU DON'T, YOU 
MAY DAMAGE THE CARTRIDGE 



AND THE COMPUTER 



STEP 2 Hold the cartridge with the label facing UP. and insert the 
cartridge firmly in the cartridge slol (labelled 'memory 
expansion') in tne back of your computer. 

STEP 3 Turn ON your Commodore 1 6 

STEP A Begin tne game or program according to the instructions thai 
come with the software. 



i 

i 

f 

i i 

I ! ( 
I 

I I 

I I 

I I 

I I 

I ' 

I ' 



I I 

I I 

I I 

I f 

I I 

I I 

I I 

I ( 
t 

I 




CARTRIDGE SLOT 



CASSETTES 




• • 



A variety of software lor the Commodore 1 6 is available on cassette 
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 
fashion as cartridge software, but you have lo have an additional piece 
of equipment (called a peripheral) to load cassette software into your 
computer To use cassettes, you need a Datassette tape recorder, 
available Irom your Commodore dealer. 

You can also use cassette tapes and the Datassette lo slore programs 
you write yourself The next section explains how to save programs on 
tape 



31 






The steps for loading a program on cassene tape are the same, 
whether you're using pre-recorded software or programs you saved 
yourself. 

Loading Cassette Tapes 

STEP 1 Insert the cassette into your Dalassette and close the door 

STEP 2 Rewind the tape to the beginning by pressing the REWIND 
button on the Datassette 

STEP 3 Press STOP when the tape is rewound to the beginning, type 
LOAD and press the MlUM key. The computer responds 
with the following message; 

PRESS PLAY ON TAPE 

STEP 4 Press the PLAY button on the Datassette The screen goes 
blank as me Datassette starts When a program is found, the 
screen displays this message: 



SEARCHING 

FOUND program name 

STEP 5 Press the Commodore key C to load the program that was 
FOUND. If there is more than one program on the tape, and the 
program your Commodore 16 found isn't the one you want, do 
nothing Your computer will continue searching alter a brlel 
interval. 

When the program Is loaded, the word READY appears if you want to 
stop the loading before it's complete, press hun'STC* on the 
keyboard and then the STOP button on the Datassette. After the 
software is 'Oaoed. type RUN to start the program. You can also LIST 
the program or change it. if it is a BASIC program. 

Loading A Specific Program 

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



32 



5 



f } 



I 



:;, 



I 



f 



I I 



I 



I 
f 

! 
1 
I 



I 
! 
I 
f 

I 

f 
I ( 

I f 

r f 

t i 



STEP 1 If the program you want is called "BASES", you would type 

LOAD "BASES" 

and press return 

Your computer responds with: 

PRESS PLAY ON TAPE 



STEP 2 Press the PLAY button on your Datassette to get your 

computer to start looking After soarchmg on the tape for the 
program called BASES, the message should appear 

FOUND BASES 
LOADING 

The screen goes blank while your computer then "reads' 1 the program 
into its memory. If the entire tape goes by without the FOUND 
message, rewind the tape and try again. Once your computer has 
digested the entire program, your Commodore i 6 tells you; 

READY. 

■ 

STEP 3 At the cursor, you instruct it to 



RUN 



and press retton At this point, your Commodore 1 6 runs 
(executes) the program "BASES", 



Saving Programs on Cassette Tape 

When you write a program yourself and you want to keep it for later use 
or modification, you can SAVE that program When you SAVE a 
program, you are in effect recording it on a form of software (tape or 
disk) that allows you to recall the program so you can RUN It. make 
changes, etc When you want to save a program on cassette tape, 
follow these sleps 

STEP! Type 

SAVE "program name" 



33 



The program name you use can be anything you want, bul can 
be no more than 16 letters and/or numbers long 



STEP 2 Press the 



key The computet displays this message: 



PRESS PLAY & RECORD ON TAPE 



STEP 3 Press the RECORD and PLAY buttons on your Datassetto. The 
screen goes blank. When your program Is saved, the word 
READY appears on the screen. 

Examples ot SAVE Commands lor Cassette Tape: 



SAVE "THE DAY" 
SAVE "YOURSELF" 



This name is the specific name 
of the program being saved 



NOTE: When saving a program onto a cassette tape, always be 
aware of where the tape is positioned. 



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 



cassettes, you only have to put the disk Into the disk drive and type the 
commands to LOAD or SAVE programs; there are no buttons to push 
There are a couple ot small lights on me front o( the disk drive. The 
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 
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 
drive. 

Loading Programs From Diskette 

STEP 1 Make sure that your disk drive is pluggea >n and the serial 
cable Is connected Then turn the power ON. 

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 
the disk (It might be covered with a sticker). This notch should 
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. 




STEP 3 Close the protective "door" on the disk drive afler you insert 
the disk. 



STEP 4 Type: 



DLOAD "program 
name" 



Specific name ol the program 10 
be LOADed 



(To save lime, you could press FUNCTION KEY 2 and type in the 
program name ana the second quote marks.) 

STEP 5 Press the return key The disk spins and your screen says: 

SEARCHING FOR program name 
FOUND program name 
LOADING 



READY. 
■ - 



cursor 



STEP 6 Your software is now ready lo use. Type RUN and press the 
return Key io start ihe program. 

If the red light on the disk drive blinks afler the DLOAD is finished, 
something weni wrong. Type: 

?DSS (and nil BETURN ) 

to find oul what went wrong. 
Examples of DLOAD commands: 



DLOAD "•" 
DLOAD "FILES" 
DLOAD "SOF*" 



Headering A Diskette 



LOADs the 1st program on the disk 
LOADs a disk program called FILES. 
LOADs Ihe first program on Ihe disk that 
begins with the letters SOF. 



Headering prepares a new BLANK disk for use Any blank disk must 
be formafted before it may be used, by using ihe HEADER command. 



[1 1 


( 


1 1 1 


1 1 1 


1 ! 1 


( ) 1 


' ! 1 


' 


rji 


i i 


i i 


1 1 ! 


i 1 ( 


( 


f 


1 1 


( 


1 I 


' I 


■ 1 


1 1 


1 1 


1 1 



IMPORTANT: DO NOT HEADER A DISK THAT HAS ANYTHING ON 
IT UNLESS YOU WANT TO ERASE THE ENTIRE DISK. HEADERING 
ERASES EVERYTHING ALREADY ON A DISK, 



Tt\e lormat for the HEADER command Is 
HEADER 'disk name" l,Udevice#]|,Iid.#],Ddhve# 

• The name you use is the name of the entire disk. Give the disk any 
name up to 16 characters. 

• Udevice # specifies which peripheral device number (which disk 
drive unit), and defaults lo 8 (primary disk drive). 

• The id. is the letter I and any two letters and/ or numbers, like 12 1. 
IR5, etc Give the disk any id. you want, but you should give every 
disk a different I d to avoid contusion. (Note: the firsl characler 
must not be F). 

• II you have a dual drive fa disk drive with two slots tor disks), you 
should specify Ihe drive number with a or 1 . Drive number is 
ALWAYS included in the command, even wilh a single drive (DO). 

ARE YOU SURE? ^^^ 

As soon as you press return alter typing the HEADER command, 
your Commodore 1 6 asks ARE YOU SURE? This is to give you s last 
chance to change your mind. If you want to go ahead and header the 
disk, lype YES or Y and press RETUJUT If you decide not lo header the 
disk, lype NO or N and press RETURN 

Here are some examples of HEADER commands. 

HEADER "LETTERS",I07,D1 
HEADER "FINANCES", U8.IS3, DO 



NOTE: If you want to erase all files on a disk (as opposed to 
formatting a blank disk), use the HEADER command without an i.d 
number . This in effect scratches (erases) alt the files that were on 
Inai disk. 



Now that you know how to HEADER a disk, you're ready lo use disks lo 
write and save programs on your Commodore 1 6 (of any olher 



37 



Commodore computer). The BASIC Encyclopedia In the back of Ihls 
manual has more Information about the HEADER command. 

Saving Programs on Diskette 

When you want lo reuse a program you've written, be sure to SAVE it 
before you LOAD anolher program or turn otl the Commodore 16. K 
you don't, you'll lose the program 

When you change a SAVEd program, you have to SAVE it again it you 
want to keep the new version 

When you reSAVE a program, you are replacing the old version with 
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 
SAVE it. 

Follow these steps to save a program on disk: 

STEP 1 Type DSAVE "program name ' 

STEP 2 Press return Tne computer displays this message when 
the program is saved: 

SAVING 0: "program name" 
READY. 

I 



Example 



DSAVE "MYPROGS" 



The program name can be 
up lo 1 6 characters long 



It the red light on the disk drive blinks after the DSAVE is finished, 
something went wrong Type- 



?DSS (and "it BBTUHN 



to learn what went wrong. 

If you try lo SAVE a program on a write-protected disk (a disk thai does 
not accept your output} you must turn the drive OFF, then ON again 



i 


I 


1 


1 


1 




1 


1 


1 


1 


1 


( 


1 


1 



I 



I 

I 
I 



I 



I ( 



( 


( 


I 


1 


1 




( 


1 


1 


( 


1 


f 


1 


' 


1 


1 


1 


( 


1 


( 


( 


1 



The Directory Command 

When you SAVE programs on disk, the computer keeps a listing of all 
the flies saved on ihat disk. You can display the listing as a table of 
contents to see what's on a disk by using the directory command 

Type; 

DIRECTORY then press HETUHH 

(or ptess FUNCTION KEY 3) 

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

You can also display just part of the table of contents: 



DIRECTORY "MY"" 



DIRECTORY "'^PRG" 
DIRECTORY "«=SEQ" 



Lists every tile on Ihe 
disk that starts with the 
tetters MY. 

Lists every program file. 
Lists every sequential file. 



I 



98 












I ( 

I f 
I [ 



THE 



i i 

40 



CHAPTER 4 



FIRST 
STEPS 



Introduction 



i ( 
i i 
i r 

( i 

• The first step 



The screen display 



Reverse printing and changing colours 



i f • Correcting mistakes 



) • Screen windows 

i r 
f 



41 



INTRODUCTION 

The purpose ol this chapter is to begin to acquaint you wilh some of the 
characteristics and capabilities of your Commodore 16, and how to 
take the first steps toward programming with your computer 

The Screen Display 




/ 

I 



Your Commodore 1 6's comings and goings a'e seen on your TV or 
monitor display screen Whatever you type, whatever your computer 
has lo say about what you type, whatever programs you load . II all 
shows up on your monitor screen, whether you're hooked up to a 
colour or Wack and whtte TV, or a Commodore colour monitor Your 
Commodore 1 B screen, no matter what type ot monitor or TV you're 
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 
an entirely filled screen can contain spaces tor 1000 (25 X 40) 
characters. The Commodore 1 6's screen display is made up of Ihree 
elements: the characters (the letters, numbers and graphic symbols), 
Ihe background, and the border When you first turn your computer on. 

the characters are black, the background is white, and the boroer is 
light blue You've already seen how to change the colour of the 

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 



I 



f 
I 

r 
i 



i 






( 
f 
i 

r 
i 
i 
f 
f 

[ 

r 
r 

■ 
i 



Reverse Printing and Changing Colours 

Not only can you change Ihe colour of the cursor and characlers you 
type (and your computer displays) on your monitor screen, you can 
also reverse the character and background colours. That means that If 
you have Wack characters on a while background and you turn reverse 
printing on (by typing coo, and 91 everything that appears on the 
screen is reversed: Ihe characlers are in white, while the background 
behind those characters is black. You can experiment with changing 
the character colour and using reverse printing, by following these 
instructions' 



STEP1 Hold down the 



key and press Ihe bvs on >-. 




CTHL 



STEP 2 Release the keys and nold down ihe space bar 

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 
your sceen should get longer. K Ihe line gels to the end of the 
row, tt continues on the next row 

STEP 4 Release Ihe space bar (but don't press the return key). 

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 
do this, the cursor changes to the colour of Ihe key you 
pressed. 

STEP 6 Hold the space bar down again. Now your computer draws a 
line in ihe now colour Keep changing colours wilh the CTtt 
or keys and Ihe colour keys. Then ho'd down the space 
bar to make more different coloured lines, 

STEP 7 Turn off r everse prim by holding down cm and pressing the 
bvs off key Pressing ihe return key also turns oh reverse 
printing 



43 



BRIEF INTERLUDE: You can lype tellers, numbers and punctuation 
rn reversed print. Reverse letters make excellent headlines. You can 
also use ihem (o hignltght special words and numbers. You can type 
graphic symbols in reverse for the same effect To put a racing 
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 
reversed. On Ihe next line, type SHIFT and R (still in reversed print). 
Then turn off reverse, and fill (he last line with iuft and R (no 
longer reversed). Now your screen has a racing stripe In whatever 
colour you chose; perhaps it is a humble achervement, but it does 
give your screen a certain flair . . . 



THE FIRST STEP 

What is a program, anyway? An experienced programmer might tell 
you that a program is a series of ordered statements organised to direcl 
the computer to perform a sequence of steps toward some purposeful 
result What you may learn from this is not to ask an experienced 
programmer what a program is. 

The following, although it is only two lines long, qualifies as a program. 
Type it exactly as it appears here. Don't leave out the numbers at the 
beginning ot each line, since they are the line numbers; they tell your 
computer what order to read and perform the lines of the program. Be 
sure to press the return key at the end of each tine you type. 



10 PRINT'FIRST TRY" 

20 GOTO 10 

HUN 



This line tells your computer to print the 
words FIRST TRY on your screen 

This line tells your computer to go back to 
line 1 and print FIRST TRY again. 

When you type this and presb return 
your computer does what each line tells it to 
do. 



Press the run/stop Key to slop Ihe program. 

Why did your computer print FIRST TRY so many times? PRINT Is a 
command mat tells your computer to PRINT what appears between the 
quote marks on the screen. When your computer reads this line, it 



44 



1 


I 


r 


f 


I 


i 


! 


f 


i 


i 


r 


i 


! 




i 


( 



I I 
1 I 
I I 
I 

I ' 
i r 
i i 
i i 
( ( 
i ( 
i r 
i r 
i i 
f i 
i t 
[ i 



executes (carries out) that command. GOTO tells your computer to go 
back lo line 10 and execute the command (PRINT "FIRST TRY") Each 
time your computer got to line 20. It executed the GOTO command, 
returning to line 10 again and again This repetition is called a loop. 
The run/stop key breaks into whatever program the computer is 
running, and returns control of the keyboard back to you. 



TIP: Want lo slow down this program (or any olher) without slopping 
it? Just hold down the © key 



Now type Ihe following, pressing return after each eniry. 



NEW 



This tells the computer to forget 
the last program and get ready for 
a new one. 



The computer responds with the message 



READY 



You don't type this; this is your 
computer letting you know that 
It's READY tor new commands or 
programs. 



10 PRINT * 



o 



COMMODORE I 



16" Press CfBt and Bvson 



■Press 



and Rvs off 



Notice whal happens when you typo RTS ON and IVS OFF inside the 
quote marks. They appear on the screen as reversed characters. Now 
type RUN and pres; return lo see Ihe program. When the program 
is RUN, your Commodore 16 reads these reverse characters as what 
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 
representation for wnat you type) for doing other things in a PRINT 
statement, like moving the cursor and changing colours, when you RUN 
a program. 



45 



Now try tne same line, bul replace BfS ON and HVS oft with 
and FLASH oit (the < and > keys): 



10 PRINT" 



I COMMODORE 




I" Press CTRL and flash on 
Press; CTRL and FLASH OFF 






When you RUN this, it PRINTS oul COMMODORE 16 |ust once. But the 
word COMMODORE Hashes continuously, even though your program 
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 
would do other things (change colours, etc.) in the same manner 

Entering Commands 

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 
numbers followed by commands and statements within quote marks. 
That's because there are two 'modes' that you can use to communicate 
with your computet. Both are based on a language made up of terms 
that your computer understands. The most straight-forward (and the 
one built m to your Commodore 16) is called BASIC. Your Commodore 
1 6 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 
command immediately. You enter the command to bo carried out by 
your computer when you press the RETURN key This Is also known as 
DIRECT MODE. The alternate mode is known as PROGRAMMING, or 
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 
lines according to line number (lowest lines first). Obviously, 
programming mode is what you use to write computer programs. 



CORRECTING MISTAKES 

Mistakes are a way ot life with compulers. Mistakes in programming 
must be searched for and remedied for a program to run correctly. 
That's whai the HELP key is for. A more practical kind ol mistake— the 
typing error— can mess up programs just as Dadly. Not only will 
oompuling Improve your typing skills, you'll make great strides in 
spotting and correcting typing errors as well There axe several ways lo 
fix up typing errors Remember that to enter any changes (or anything, 






■ 



i : 



I 



f 



46 



I 



for that matter) either for your compulef to execute or into your 
computer's memory, you must press Ihe heturh key 



1. YOU CAN EDIT A LINE by overtyping. 

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 linistv 



EXAMPLE; 

10 PRINT "IT IS ONE O'CLOCK" 

If you want to change Ihe time lo TWO. move the cursor lo the O In 
ONE. 

10 PRINT "IT IS0NE O'CLOCK" 

And now lust type TWO over ONE and press BETUHN 

10 PRINT "IT IS TWO O'CLOCK" 



NOTE: When working with numbered program lines you don'l have 
lo be at the end ot the line lo press return Your Commodore 16 
remembers the whole line even if you press Rrrutw in the middle 
of the line. 



2. YOU CAN OPEN UP SPACES IN A WORD OR LINE with the 
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.) 
Then just type what you want lo insert 

10 PRINT "CORE" 



To change this to COMMODORE, move tne cursor lo Ihe 'O' and press 
the shift and msT keys until enough space opens up. Don't bother 
lo count out the spaces. You can |usi guess and then open up more If 
there aren't enough 



10 PRINT "C 



ORE' 



cursor 



47 



Now add the other letters'. 
10 PRINT "COMMODORE" 

3. YOU CAN ERASE CHARACTERS AND CLOSE UP SPACE with Ihe 
DEL Key (gel delete by pressing the INST/DEL key by itself). This 
key erases characters or spaces immediately to the LEFT ol the 
cursor. 



10 PRINT "AFTERNOON SCHEDULE" 

You can change this lo WEEKLY SCHEDULE by moving the cursor to 
Ihe E in AFTERNOON, pressing Ihe msT/DFZ key three times, and 
typing WHDO.Y 



10 PRINT "AFTERNOON SCHEDULE" 

and press inst/del three times 

10 PRINT "QRNOON SCHEDULE" Type in WEEKLY to replace 

ERNOON ann ( i return 



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 
tine still appears on the screen, but your computer ignores it. When 
you have two statements with the same line number, your Commo- 
dore 1B only uses the last one entered. For example, in a brief pro- 
gram using the COLOR command to change the colour ol the screen 
background, a mistake might occur: 



10 COKOR 0,3 mistake 

20 PRINT "COMMODORE 16" 






Press the ■etuiui key to gel to a fresh line, and just retype line 10 
correctly 

10 COLOR 0,3 

Now Ihe first line 1 is replaced by the second line 1 0. You can check 



48 



I 



I 






this by typing UST. which displays a ilne-by-line LISTing of your 
program as it is stored in the computer's memory. When you LIST a 
program, all lines appear In correct order and the replaced lines don't 
appear 



The screen reads: 



LIST RETURN 

10 COLOR 0,3 

20 PRINT "COMMODORE 16" 



You can see what the COLOR command does In this example. For a 
more complete explanation, see Chapter 6, or look up COLOR in Ihe 
BASIC Encyclopedia. 

Replacing lines In a program is also a good way to experiment with 
your computer When you replace a line, the new one doesn't have to 
be anything like Ihe old line. For example, instead ot correcting Ihe 
spelling of COLOR, you can enter this line: 

10 PRINT'COMMODORE 4 TIMES COMMODORE 4 «^' 



\ 



space 



Now RUN the program anc see what happens. 



5. YOU CAN ERASE AN UNWANTED LINE just by typing the number 
of the line and pressing HETuWi The computer ignores the line 
even Ihough it still appears on the screen Type UST to get tne pro- 
gram LISTing to make sure the line is gone from Ihe program. 

10 PRINT "COMMODORE 4 TIMES COMMODORE 4 - " 
20 PRINT "COMMODORE 16" 



Now type 
10 

UST 



RETURN 



The result, according to your computer 
20 PRINT "COMMODORE 16" 



49 



CLEARING THE SCREEN 

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 
once 't leaves the monitor screen. There are a few ways to accomplish 
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 (tor a couple minutes or so) It 
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 
screen and repositions the cursor at the lop left-hand corner, (the 
'home position') 

3. Type 

SCNCLR and press return 

This Is a BASIC language commanc that your computer Interprets as 
instruction lo clear the screen. 

4. Press the RESET BUTTON. This resets the machine, bringing Pack 
the starling screen and clearing all programs out ot your computer's 
memory. 

if you want lo dear the computer's memory but. not the screen, lype: 
NEW and press returh 

This is a BASIC language command that tells the computer to empty Us 
memory. The 1 6 in the Commodore 1 6 refers to the amount of space 
(I6K) that your computer has to store programs, Known as the memory. 
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 
memory stays there This means you have less space for new 
programs The last two methods erase what Is held In your computer's 
memory, so that you again have the lull amount of space available lor 
new programs. 



50 



I 



I 









SCREEN WINDOWS 




Windows let you aefine a specific area of the screen as your 
workspace. Everything you type (lines you type. USTmgs of programs, 
etc.) after setting a window appears within the window's boundaries, 
not attecting Ihe screen outside the window area. You can set up a 
window anywhere on the screen. 

To set a wmoow, follow these steps 

STEP 1 Move Vie cursor to ihe screen position you want as the top 
left comer ot the window 



STEP 2 Press the ESC key and release tt. and then press T. 

STEP 3 Move the cursor to the position you want to be the bottom 
right comer ot the window 

STEP 4 Press EK and release, then 'B' Your window Is now set. 



All screen output is confined lo Ihe 'box' you have defined To cancel 
the window, press the CLEAR/HOME key twice. The window is then 
erased, and the cursor is positioned in the top let! corner of Ihe screen. 



You can manipulate Ihe window and the text inside using the BC key. 
Screen editing functions, such as Inserting ana deleting text, scrolling, 
and changing the size of the window, can be performed by pressing 
esc followed by another key. To use a specific function, press the 
appropriate key after pressing 



51 



KEY 


FUNCTION 


A 


Automatic insert 


B 


Set the bottom right comer of the screen window 




(at the current cursor location) 
Cancel automatic insert 


C 


D 


Delete current line 
Insert a line 

Move to the beginning of the current line 


1 


J 


K 


Move to the end ot the current line 


L 


Turn on scrolling 


M 


Turn of) scrolling 


N 


Return lo normal screen display size 





Cancel insert, quote, reverse, and flash modes 


P 


Erase everything from the beginning ot the line to the cursor 





Erase everything Irom the cursor to the end of the line 


R 


Reduce screen display 


T 


Set the top left corner of the screen window 


V 


Scroll screen up 


W 


Scroll screen down 


X 


Cancels the previous Escape function 






52 



CHAPTER 5 



NUMBERS 

AND 

CALCULATIONS 



Introduction 



Numbers and operations 



• Calculations 



More about screen PRINTing 



Variables 



Numeric functions 



User defined functions 



53 



INTRODUCTION 

You don't have lo be a mathematics genius to understano and make 
use ol the mathematics capabilities ol your Commodore 1 6. In addition 
lo the straight-forward operations like addition, subtraction, 
multiplication and division, you can use your computer to figure out 
advanced functions like square roots and sines. You'll leaxn about the 
different types of variables, and how to use them. Your computer can 
handle single digit whole numbers or complex numbers of up to 38 
places expressed m exponential notation with equal efficiency You can 
do your calculations directly or as part of programs finally, this chapter 
gives you a brief explanation of now lo set up your own functions lor 
your computer lo evaluate. 

NUMBERS AND OPERATIONS 

You can use your computer like a simple calculator. Besides tne 
standard + and — operalion signs, your Commodore 1 6 uses the • 
sign for mulllplication and the / sign lor division and fractions. 
(Computers use the * sign instead ol an X for multiplication because a 
computer can't tell the difference between trie letter X and the 
mathematical symbol X.) You can use these operators and numbers In 
Immediate mode (no line numbers) or In program lines. Type In 
numbers and operators in PRINT statements WITHOUT QUOTES if you 
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 
exactly that on the screen, instead of performing tne addition. You can 
get your computer to put two and two togelher by typing PRINT 2 + 2. 



I 



BASIC MATHEMATICAL 
OPERATORS 



BASIC RELATIONAL OPERATORS 



Addition + 
Subtraclion - 
Division and fractions / 
Multiplication * 
Exponentiation r 
(press SHIFT and 0) 


Greater ihan 

Less than 

Equals 

Greater man or equal 

Less than or equal 

Not equal to 


> 

< 

■> 

■ > or >" 

<- or ■< 

< > or > < 



NOTE: Your computer doesn't accept commas as 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 
(separated by Ihe comma), and would read it as 30 and 359 instead 
of 30359. 



54 



I 

: 

I 
J 



Fractions and Decimals 

You can write a fraction like this 5 

or like this: 1/2 Your computer Is actually 
performing the division 

If you pul a fraction in a PRINT statement, your answer is always 
returned as a decimal or whole number For example. 



RETURN 



PRINT 139/493 + 5 
5.28194726 



THE PI KEY 



Hore's an example that uses pi (3 1 41 59265 J, which represents 
the ratio ol the circumference ol a circle to its diameter. Use ihis value 
by Just pressing Ihe 7T key ( Q and =}: 

PRINT TT /37* RETURN 

8.39998C36E-03 

Scientific Notation 

What did your computer mean by the E-03 part of Ihe above answer? 
Your computer displays decimal numbers in Ihe range -999,999.999 to 
999,999.999 In standard numerals. Numbers beyond this range (with 
more than nine digits) are automatically displayed in scientific notation. 
You can enter numbers in yourself in this form and your computer will 
read them with no trouble (certainly less trouble than you had 
converting mem!) Scientific notation is often uselul, since this special 
notation lets your computer display targe numbers In lewer digits. 

Here is how the number 198.505.478 would be written in scientific 

notation 



Omy ONE digil is shown to the 
left of the decimal point 



1 .98505478E + B — 



This number is ihe number of 
digit places the decimal poini is 
moved 



55 



Fof a number less than one with several decimal places, Ihe second 
number would be a - instead ol a +, indicating ihat Ihe decimal point 
Is moved lo the right. 

For example 



0003359 - 3.359E - 4 

Other examples 

20 = 2E + 1 

105000= 1 05E + 5 

.0666 - 6.66E - 2 



the decimal point is moved 1 digit left 
the decimal point is moved 5 digits left 
the decimal point is moved 2 digits right 



PERFORMING CALCULATIONS 

To per'orm a calculation, type PRINT and men the math problem 
without quotes, as in the following: 

10 PRINT 1+2, 2-1 
20 PRINT 2«2, 4/2 
RUN 



3 



1 



For the first time, PRINT didn't print exactly what you typed In the 
statement. Instead, your computer solved the calculations and PRINTed 
only tho answers. All you have to do to use PRINT to calcuiato is omit 
the quotation marks, Now try this: 

NEW 

10 PRINT "2001/2010" 

20 PRINT 2001 - 17 

RUN 

2001/2010 

11984 



one space is left here lor Ihe 
answer's sign 



Since line 10 Is in quoles, your computer |ust PRINTs the problem as if 
it were 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 
the printout for line 20. Now move the cursor back lo line 1 and 
change the line lo this: 



56 



I 



10 PRINT "2001/2010=" 

2001/2010 
RUN 

2001/2010= .995522388 
1984 



I 




don't forget the semicolon 

this space >s left tor the answer's 

sign 

Ihe answer for line 20 stays the 

same 



If you want to both PRINT the problem AND solve il you have to type it 
twice once in quoles and once out ot quotes, as line 1 shows. 

Order of Calculation 

You can perform more than one calculation in one line. Try typing this. 

PRINT 200-50+3 

Is the answer whal you expected? Try this: 

PRINT SO+5'200 

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. 

FIRST: Your computer checks for negative numbers (not subtrac- 
tion, just negative numbers). 

SECOND; Your computer soVes any exponents. 

THIRD: Your computer solves all multiplication and division, from left 
to right. 

FOURTH. Your computer solves addition and subtraction, from left to 
right 



NOTE: Your Commodore 1 6 always solves any pari of the problem 
that's surrounded by parentheses first. You can even put 
parentheses within parentheses: 36 • (1 2 + (A / 3)). The contents of 
the Innermost parentheses are solved first. 



Sometimes it's a good idea to oul negative numbers in parentheses lor 
clarity. For example, if you want to multiply 45 by -5, type II like this: 
4S*<— 5) Your computer can understand it with or without parentheses. 



57 



MORE ABOUT PRINTING ON THE SCREEN 

You've probably noticed thai certain programs had you lype commas In 
certain places, white in others there were semicolons. Your computer 
inlerprets commas and semicolons as instructions lor the spacing of the 
printout 

The eflect of punctuation on the spacing of PRINT statements works the 
same with spacing ol both text in quotes (called "text strings") and 
numbers being calculated Try typing this brief program 

NEW 

10 PRINT "0"."K" 
20 PRINT "O'V'K" 

Notice that the punctuation appears OUTSIDE ol the quote marks. 
When you RUN the program the screen looks like this: 



O 

OK 



K 



One 10PRINTed this 
Hoe 20 PRtNTed th<s 



If line 10 and line 20 are nearly Identical, why ts there such a difference 
in what they PRINT on the screen? The only difference is due to the 
punctuation between the items this program PRINTS. 

When you use a comma to separate items in a PRINT statement, the 
items are PRINTed several spaces apart When you use a semicolon, 
the items are PRINTed right next to each other, 

As you recall, your computer's screen has 40 columns across. These 
columns are divided into four 1 space areas, called PRINT ZONES 
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. 



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™ 

O K 



If you try to PRINT more than four items separated by commas, your 
computer automatically goes to the next line to PRINT For example: 



I 



I I 



58 



I 



I 



f 



print' a" rwro'rD" ;•&","?' 

spaces the letters like this on your screen: 





1 


11 


21 


3' 


40 


COLUMN 


ROW 1 


A 


B 


C 


D 






2 


E 


F 











When you use semicolons to separate items In a PRINT statement, your 
Commodore 16 ignores the print zones and PRiNTs all the items one 
after another; 

PRINT "A";"B";"C";"D";"E";"F" 

PRINTS ims 
ABCDEF 

II the first PRINT item is 1 2 letters long and the second itBm is 
separated by a comma, here's what happens: 

PRINT "ABCDEFGHIIKL'V'M" 

PRINTS this; 

ZONE 1 ZONE 2 ZONE 3 

ABCDEFGHJJKL M 



NOTE: Sometimes youli type a particularly long line on your 
computer, such as this: 

10 PRINT "I LIKE YOUR TOUCH ON MY KEYBOARD. DO YOU 
COME HERE OFTEN?" 



You'll notice lhat as you type this, you run out ol room on one row. But 
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 
as many as BO characters on one program line (up to two full 40-column 
rows}. 

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



59 



tows. If your lino is longer than one row. your Commodore 1 6 lets It 
spill over to the next row Your computer considers the line ended 
when you press Ihe HETUWf key, nol when you lype lo the end of the 
row You'll get used to tins as you use your Commodore 1 6 

USING VARIABLES 

■ 

The example 36*(1 2+(A/3)) shows one of the most powerful fealures 
of a computer. When you have a letter instead of a number in a 
mathematical problem, you're using a VARIABLE. A variable 
represents a value: 

10A-3 

20PRINT"TOTAL:";A'4 

If you RUN this program, the screen result is. 

TOTAL: 12 

There are three types of variables you can use 

SAMPLE 
TYPE SYMBOL DESCRIPTION EXAMPLES VALUES 






Floating 




real (decimal) X, AB, T4 


23.5. 12. 


point 




or whole 








numbers 


1.3E+2 


Integer 


% 


Whole numbers X%, A1% 


15.102.3 


Text siring 


S 


letters, 








numbers. XS. MSS 


"TOTAL:", 






and all other 


"DAY 1"."CBM" 






characters in 
quotes 





Every time you wanl a variable to be read as a whole number, the 
symbol tor that variable would Include the % sign A variable that 
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 
variable wilhout either of the symbols f % or %) is read as a floating point 
number (a "regular" number). Integer variables (whole numbers) are a 
subset of floating point variables: they are numbers with no decimal 
places 



60 



I 



' ( 



f 



Make sure that you always use the nght variable type. If you try to do 
something like assign a word to an integer variable, your program won't 
work. This program shows you what variable can or can't be used in a 
given situation, and you can find oui what happens when you try out 
different types ol data: 



10 PRINT "ENTER A NUMBER* 
20 INPUT X% 



this asks you to enter 
a number for the 
variable 



30 PRINT "I READ YOUR NUMBER AS"; X% 
40 PRINT "NICE GOING. ACE!" 
50 END 

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

ONE FIFTH 

.043 

10 






NUMERIC FUNCTIONS 

Included in your computers BASIC language are numeric functions, 
which are like the advanced calculations found on most scientific 
calculators (such as sine, cosine, tangent, etc ) 

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 

FUNCTION(X) 

For example, to find oul the sine of a variable, you would type 

PRINT SIN(X) 

with X as any number you wanl to Input. 



61 



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

10 FOB X= 1TOS 

20 PRINT "THE SQUARE ROOT OF"; X;"IS"; SQR(X) 

30 NEXT X 

You'll find a complete listing of the numeric functions In the BASIC 
Encyclopedia In the back of this manual. 



NOTE: Most commands have an abbreviation mat you can type 
instead o( typing out the entire BASIC name. Your Commodore 16 
interprets the abbreviation exactly as It would read the full name. An 
example of an abbreviation is as follows 



Lthen 



O prints L 



on your screen 



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



User Defined Functions 

An effective way lo use your computer's math capability Is to create 
user defined functions. User defined functions are extremely useful In 
calculations, and easy to implement using your Commodore 16. User 
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 
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 
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 



! 



I 



I 



i I 



CHAPTER 6 



GRAPHICS 

AND 
COLOUR 



• Graphics characters 



Character animation 



Controlling colours 



High resolution graphics 



Points, lines, and labels 



• Squares, circles, polygons, and painting 



! 



[ 



I 



[ 



Multi-colour graphics 



63 



GRAPHICS CHARACTERS 

You should remember from Chapter 2 that each letter key contains 2 
different graphic characters, as do the @. -, ", and £ keys for a total 
of 62 different graphic characters To print these graphic characters, you 
must hold down the shift or O keys while you press the key tor the 
graphics symbol you want. 



Whet your Commodore 1 6 is not in typing mode, hold down 
and press a tetter key lo print the graphics character on the right side of 
that letter key These characters include the playing card suits, a solid 
and a hollow ball, and a set of lines and connecting characters that you 
can use to draw many different pictures on your screen. 

The O key pressed with a tetter key always produces the graphic 
character pictured on the left fronl ol Ihe key The left side graphics are 
an assortment of bars, souares, lines and blocks, uselul In drawing 
charts and graphs. 



Pick a Card, Any Card 

Here is an example to help give you a better idea ol how to use the 
graphic characters to create representations. Follow these instructions 
to create a playing card, in this case the six of hearts. 



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



Key along 



u 
V 



i 
/ 



Now it's time lo draw Ihe top edge of the card: Press the mutt loci 
key so that it stays down Press "U". followed by the ' C" key 5 times, 
and then the T. 



B 



I ' ! 
I f 



64 



1 


1 


1 


1 


1 


r 


1 


i 


1 


i 


1 


r 


1 


i 


1 


i 


1 


i 


1 


i 


1 


i 


1 


i 


1 1 


1 


i 


1 


i 


1 


i 


1 


i 


1 


i 


1 


i 


1 


i 



To draw the left side: Keeping the shift loot down, go to the space 
directly beneath the curved edge (where you pressed the "U" in the last 
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 
pressed the "B" key a total ol 7 limes. (Using the cursor keys win be 
tough at first; you'll gel belter with practice.) 



/ 



c 



\ 



To draw the bottom edge. Similar to Ihe lop edge, you press "J" once 
and then press the "C" key 5 times, finishing off with the "K" key. 




To draw Ihe right edge: Draw Ihis in the same fashion as the left edge, 
pressing Ihe 'B' key a total of 7 times (while cursoring lo the appropriate 

place). 



65 




Release the wan loot by pressing it once In the upper left corner 
(one space down end one space over from the rounded edge) pfess the 
'6*. Go to the bottom right corner, position the cursor one space up and 
space lo the lelt and type another 'ff . 



SHIFT S 

\ 


6 


W 9 


L J. 



Now to ge t dow n to the heart of the matter— 6 of them to be exact. 
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 
SPACE BAR , and press the 'S' again Cursor down two rows and repeat 
the 'S- SPACE -S' sequence. Add the last two hearts two more rows 
down You now have an official six ol hearts playing card This won'l 
do you too mucn good In a game of blackjack, however. If you want to 
improve your hand, creale a couple ol cards of your own 



66 



1 


1 


1 1 


1 1 I 


1 I 


1 1 


1 1 1 


1 1 


1 J 


1 1 


1 I 


1 1 


1 I 


1 


I 


1 : 


r 


1 : 1 


1 1 


1 1 


1 ! f 


1 1 


1 1 


l : 1 


l 1 


i 1 


i I 



NOTE: When the shift lock is down, you can press return and 
not get a SYNTAX ERROR from your computer as a response. Even 
though you had characters on the line that weren't commands thai 
the computer can understand, your computer interprets the return 
key as just an Instruction to return to the beginning of the next line 
when the OVT key is held down. Your computer does nol try lo 
read or interpret what has been typed as BASIC language 
commands when shift oi shift loci is down. 



You can use the graphic keys to enhance your printout For example, 
here's how to underline a word or column- 



First, move the cursor to the line below what you want to underline. 
Then hold down the -fr key and the "T" key, which prints an underline 
space. Hold these two keys down until the entire portion of text is 
underlined. 



The purpose ot this section is to show you how the graphic symbols of 
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 
idea ot what is involved in using the graphic symbols to build different 
forms, you should experiment with them yourself, and see what you 
come up with. 



CHARACTER ANIMATION 

Movies are really a sequence of still piclures Each picture is a tittle 
differeni from the one that came before. The protector shows each 
ptclure tor a very short time, then goes on to the next one. The scene 
becomes animated. 

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 
and practical programs. A movie is animated at a rate of 30 pictures per 
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 



67 



this Illusion on your computer is lo use a program lo draw a picture, 
wait for a split second, (ben change to a new picture. 



To get the program to create pictures you would use the PRINT 
statement with the graphic characters. The simplest type of animation 
involves alternating two characters to gel the effect of movement, 



This progr am sim ulates animation by alternating ihe circle ( shift & O) 
and heart (JHfBt & S) symbols. It you use your imagination, you could 
consider this a heartbeat ol sorts 



IMPORTANT TO NOTE: Each time SOFT or O is referred to, il 
should be typed at the SAME TIME as the key following it when 
entering the program, since nolhtng happens when either Is typed by 
Itself 



Remember lo type NEW and press mft before entering each new 
program, and press KTUBK to enter each line In all these programs 



10 PRINT "HOME SHOT 

20FOHL=1TO 100 

30 NEXT L 

40 PRINT " HOME SHIFT 

50 FOR M=l TO 200 

60 NEXT M 

70 GOTO 10 




type these keya 
simultaneously 



You'll see Ihe obvious limitation of animation alternating two characters 
when you RUN this program To stop it press Ihe boh/stop key 



To gel a more interesting effect you can build a small picture from 
several graphic characters, then change a few ol the characters while 
leaving others in the same pace This gives the elfecl of part of a larger 
object moving, as In the following program; 



! I 
I I 

I I 

i 

II 

I 

! I 

I i 

( 

i l 
( 

I I 
! I 

i I 

I 

( 

I 

I I ' 
I I 

I I 



10 PRINT " HOME SHUT M SHIFT W SHIFT N " 

20 PRINT" SPACE O + SPACE 

30 PRINT " SHIFT N SPACE SHIFT M " 

40 FOR L= 1 TO 300: NEXT L 

SO PRINT " HOME SPACE SHIFT W 

60 PRINT " O T C> + <►■ T " 

70 PRINT " SPACE © G fr. G" 

80 FOR L= 1 TO 300: NEXT L 

90 GOTO 10 



Type RUN and press Betuhn 




In bolh examples of animation so far. the figure has been stationary In 
one area on Ihe screen. The next step is lo move the animated figure 
around. The TAB function helps when you want to move objects from 
the led edge, (The TAB function is explained in detail In ihe BASIC 
Encyclopedia) The following program portrays a snake crawling on Ihe 
screen. 



Remember lhal 



ana the tollowing key are slil lyped together. 



5FORA=0TO30 

10 PRINT " SHIFT CUl " 

20 PRINT TAB (A) " SHIFT U SHUT I SHIFT U SHIFT I " 

30 PRINT TAB (A) " SHIFT K SHIFT I SHIFT K SHIFT I SHIFT Q" 

40 FOR L=l TO 100: NEXT L 

50 PRINT " SHIFT CLE " 

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 
90 NEXT A 



Lines 20 and 30 should look like this when typed tn: 



Lines 60 and 70 will look like this; 



f\J\ 

vxr 



69 



Using characters like the ball (SHIFT O), you can play video games on 
the screen. To move a bail, just erase ihe ball ana replace it at a new 
position, as In th<s program 



10 PRINT " SHIFT a* " 

20 PRINT " space shift O 

30 FOR L=l TO 50: NEXT L 
40 GOTO 20 




Left cursor arrow 



When you RUN the program, remember to press the MB/stc* Key 
when you want to stop moving the ball. 

CONTROLLING COLOURS 

Separate colours can be put Inlo each pan at the screen The border 
can be one colour, the background a different one, and each character 
can have Its own colour You already know how to set the character 
colours using the keyboard. Vou can change the colours ol Ihe other 
scroen areas using the BASIC language command COLOR 

For example, you can turn Ihe border of your screen 'ea by typing the 
command COLOR 4,3 and pressing the MlUM key. The number 4 in 
the command stands lor the border area, and colour number 3 is red 
(the same number as on the key marked 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 
blue {also the same as the keyboard) 

The first number after the word COLOR specifies Ihe area on the 
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 
multi-colour graphics later m this chapter 

Screen Area Numbers 



AREA* 



AREA NAME 





1 
2 
3 
4 



Background 
Character 
Multi-colour 1 
Multi-colour 2 
Border 
CHARACTERS 

BACKGROUND 

BORDER 




70 



f 

I 

I 
I 

I 

M 

i i 

i 
i 
f 
■ f 
( 

! 
( 

! 

I 
I 

I 
I 

1 
I 



The second number after COLOR setecls the colour you want to put on 
the area of the screen you've specified. The colour numbers 
conespond 1o the colour keys on Ihe keyboard. 



Colour Numbers 



COLOUR * 

1 

2 

3 
4 
5 
6 
7 
8 



COLOUR 



COLOUR 



BLACK 9 ORANGE 

WHITE 1 BROWN 

RED 11 YELLOW GREEN 

CYAN 12 PINK 

PURPLE 13 BLUE GREEN 

GREEN 14 LIGHT BLUE 

BLUE 15 DARK BLUE 

YELLOW 16 LIGHT GREEN 



Each colour also has an adjustable brightness level, called the 
luminance You can add a number from (darkest) through 7 (brighies!) 
after the colour number to vary the colour Type COLOR 4 ,3, and 
press KTOlK The border becomes a dark red. Type COLOR 4, 3, 7 
and the border changes 10 a bright red 

In short, the COLOR command looks like this 

COLOR area, colour, luminance 

Here is a quick program to show you all your Commodore 1 6's colours. 

First type NEW and press hetubm 

10 COLOR 0, 7, 7 

20FORM-0TO7 

30FORN-1TO2 

40 FOR L=l TO 16 

50 PRINT " cm. wn oh " ; 

60 READ A 

70 COLOR I. A. M 

80 PRINT ' ' SPACE SPACE ' • ; 

90 NEXT L 

100 PRINT 

110 RESTORE 

120 NEXT N.M 

130COLOR1,2, 4 

200 DATA 7,14,4,13,6,16,11,8,10.9.3,12,5,15,2,1 



type these keys together 



71 



When you RUN this program. (he screen background changes to a lighl 
blue, and ihe spectrum ol Commodore 1 6 colours is shown al each 
luminance level. You'fl notice Ihat black is Ihe same al all luminance 
levels. 

NOTE: Like most ol the BASIC graphic lerms reviewed in this 
chapter. COLOR may be referred to as a statement or command 
interchangeably. 



THE GRAPHIC COMMAND 



The graphics you've seen so tar use only the keyboard without really 
taking advantage of your computer's capabilities. The BASIC language 
of your Commodore 1 6 contains commands to draw shapes and forms 
through programs. To use the graphics-related commands of you' 
computer, you must enter a new mode, the GRAPHIC mode. Graphic 
mode can be considered the drawing mode, since all the drawing 
commands are "activated". You can't use these commands until you 
specify exactly what graphics mode you want to use; you specify 
which type ot graphics mode you want by using the GRAPHIC 
command. There are three different modes: normal text, high- 
resolution graphic and multi-colour graphic modes. Wllh the 
GRAPHIC command, you can even have part-text, part-graphic screens 
that 'ol you can write on one pari ol Ihe screen and draw on the rest. 
The command to enter this new mode is GRAPHIC 



In general the GRAPHIC command looks like this 
GRAPHIC mode, clear -* — this part is optional 

Mode number Effect 





1 
2 



Texl 

High-resolution graphics 
High-resolution graphics + text 
Multi-colour graphics 
Multi-colour graphics +■ text 



Clwr number Effect 





1 



Don't clear screen 
Clear screen 



72 



I I 


I I 


I 1 


1 1 


1 1 


( ( 


1 I 


( I 


1 1 


1 


1 


1 1 


I 


1 


f ' 


( 


1 ( 


( ! 1 


1 I 


1 ' 


' 


! 


1 


' 


f 


1 1 


1 ( 


1 1 


I f 


i 


1 



To switch from the normal graphics (of text mode) to high-resolution, 
just type the command GRAPHIC 2,1 and press HETORH The screen 
goes blank and Ihe cursor reappears near the bottom of the screen 
Your Commodore 1 6 screen is divided into 2 separale sections: Ihe top 
for graphics and Ihe bottom live lines lor text. It you don't wanl the 
bottom five lines for text, you can use the command GRAPHIC 1,1, 
but you won't be able to see any commands you type. You can switch 
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 
Adding ,1 after the command erases the screen 

There is another way to clear the high-resotulton screen. The 
command SCNCLR erases the screen without changing the graphic 
mode Once you use high-resolution graphics, Ihe computer sots aside 
1 0K of memory for your high-res screen. This memory is taken trom 
the BASIC program area. When you are through using graphics, you 
can reclaim this memory by using ihe command GRAPHIC CLR. 



HIGH RESOLUTION GRAPHICS 

Your Commodore 1 6 screen contains 25 rows of 40 characters each. 
or 1 000 total character positions on the screen. Each character is 
formed out ol single dots, with 8 rows of 8 dots each making an entire 
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 

Using normal graphics, you have limited control over me Individual 
dots Drawing a racing stripe or a playing card is a nice little exercise, 
bul your creation is limited to using the characters (letters, graphic 
symbols, etc.) on your computer keyboard. You can slill create all 
kinds of shapes and figures but just a fraction of what you could do if 
you could control each dot by itself The high resolution graphics 
capability of your Commodore 16 lets you do |ust that Resolution 



73 



refers lo the precision and control you have in drawing; with nigh 
resolution graphics, you can use commands thai let you draw and 
erase dots, lines, circles, and other shapes. 



There is one limit to high-resolution (hi-res tor short) graphtcs. Your 
computer can only use two colours in each 8*8 character position, 
That Is. each 8x8 space on the screen (where a* single character 
would fit) is limited to two colours {foreground and Background colour 
tor that square) You can use different colours for each different 
character position, but only two colours within mat position. Anolhei 
graphic mode that will be covered later in this section, multi-colour 
mode, allows up to four differenl colours per character position at the 
cost of the resolution available in the high-resolution mode 



Here is a program that utilizes some of the high resolution graphics 
capability of your computet and the GRAPHIC command in particular. 
Clear the computer's memory with the NEW command so you're sure 
that there are no "left-over" program tines, and then type. 



10 COLOR 0,1 

20 GRAPHIC 1,1 

30 FOR L=2 TO 16 

40 COLOR 1.L.2 

50 DRAW 1,0,L*12 TO 319.LM2 

60 DRAW l.L'18,0 TO L-18, 199 

70 NEXT L 

80FORL-lTOS000:NEXT 

90 COLOR 1,2 J 

100 GRAPHIC 









Notice mat the colours change near the intersections. This is due lo the 
limitations of hi-res graphics, with too many colours too close together. 



Points, Lines and Labels 

Type the commands GRAPHIC 2,1 DRAW 1,0,0 and press betdrn 
Look closely at the upper left corner of the screen. Your Commodore 
1 6 drew a white dot there The DRAW command can be used to draw 
a single dot anywhere on tho screen, a line, or a shape. 



74 



I 

! I 
I 

I 

I 

i 

I. ! 
( 
I 
( 
I 
I 
I 
! 
I 
■ ( 

I I 
( I 



Some forms of the DRAW command are 



COMMAND 



RESULT 



DRAW colou' source, column, row 

DRAW colour source, column, row TO column, 

row 

DRAW colour source TOcolumn, row 



POINT 

LINE 

LINE DRAWN FROM 

LAST POINT 



Colour source Is for the background. I for the foreground. Anything 
drawn in the background colour (0) Is the same as erasing the 
foreground colour at that spot. 



In the DRAW command, the first number is either I {draw a dot) or 
{erase a dot). The next two numbers are for the column and row 
positions for the dot. So if you wanted to draw a dot at column 1 7. row 
20, you would type DRAW 1,17,20. To erase the same dot, you'd Type 
DRAW 0,17,20 



The DRAW command can also draw a line between any two points. 
Just add the word TO and the coordinates of the other end, like this. 
DRAW 1 ,1 ,1 TO 1 00,1 00. This draws a line Irom the dot at 1 .1 lo 
100.100. You can erase this line by typing the same command, just 
substituting a for the 1 immediately after DRAW 



If you are used lo drawing graphs in malh, you might get a little 
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 
the 0.0 point would either be at Ihe cenire or Ihe lower left comer of the 
screen, but on your computer n Is the upper left corner. You'll get used 
to this system as you practice. 



Once you have put a point or line on the screen, you can draw a line 
from it to any other point like this: DRAW 1 TO 150,50. This draws a 
line from Ihe last poinl drawn lo column 50 row 150. If your program 
uses a loi ol DRAW TO commands, you could place Ihe first dot at a 
position on Ihe screen by using the LOCATE command, as in 
LOCATE 100,100, to Immediately return lo Ihe first position 



75 



This program draws a curve based on Ihe sine lunclioo 



NEW 

10 COLOR 0,1 

20 COLOR 1.2 

30 GRAPHIC 1.1 

40 LOCATE 0,100 

50FORX = 1 TO 319 

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

70 DRAW 1 TO X.Y 

80 NEXT X 

90 FOR L=l TO 5000 

100 NEXT L 

110 GRAPHIC 




Don'! lype NEW after RUNnlng Ihe lasl program To plot the program 
dlff erently. change line 70 lo: 



70 DRAW l.X.Y 



This program plots the same curve using points Instead ol lines. 



The Char Command 

Graphs are more easily understood and uselul it you label them. You 
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 
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) 
o* (lor erase). The next two numbers are the column and row where 
Ihe texl appears. 

Leave the last Iwo programs In ihe computer, don't type NEW Add 
these lines: 



76 



I 
f 
I 
I 
I 
I 



( 
( 

f 

r 

i 

i 

i 

i 
i 
f 
r 
i 
i 

r 

( 



i 

! 

I < 

I I 

[ I 

f ( 

f I 

f l 



81 CHAR 1,0,0,"GRAPH OF':CHAR l.O.l/'FORMULA" 
82CHAR1,0,2,"Y»SW(X)" 

83 DRAW 1,0,100 TO 319,100,189,0 TO 189. 199 

84 CHAR 1,0,12,"X-AXIS": CHAR 1,22,0, "Y" 

85 CHAR 1,22,2,"A": CHAR 1,22,3,"X" 

86 CHAR 1.22,4/T*: CHAR 1.22.VS" 




SQUARES, CIRCLES, POLYGONS AND PAINTING 

Using the DRAW command, you can draw pictures by plotting many 
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 
(our lines (plotting each endpoint ol the square) or you can just use the 
BOX command. 

Drawing Rectangles 

One ot the graphic commands ot your Commodore 1 6 makes i( easier 
to draw squares and other rectangular shapes. The BOX command 
lets you pick the points ot 2 opposite comers ol the square To 
duplicate the same box as in the above example, just use BOX 
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 
opposite corners, (0.0) al the upper-left corner and (100.100) near Ihe 
middle ol Ihe screen 

The BOX commana can lorni any rectangle |ust by changing Ihe 
corners. You can even rotate the box by specifying an angle (m 
degrees) after the lasl coordlnale, like this: BOX 1,50,50,100,100,45. 
The box is rotates -55 degrees clockwise so lhat II resembles a diamond 
shape. 

II you would like lo draw a solid box instead of just Ihe outline, you just 
add a comma 1 alter the angle. A solid box at the centre of the screen 
is shown as BOX 1,100,50,220,150., 1. Notice thai you need a comma 



77 



lo lake the p'ace Ql the angie, even though you don't want the box 
rotated This ts so your computer reads the comma as the DEFAULT 
value, which means that It interprets your lack ot response as an 
instruction II you don't Include the comma, the 1 at the end ol the line 
Is read as the angle lor the box to be rotated. 



Some typical forms of the BOX command are: 
Command 



Effect 



BOX on. column 1 , row 1 , column 2, row 2 
BOX on, col 1 . row 1 , col 2, row 2, angle 
BOX on. col 1 , row l , col 2, row 2, . fill 
BOX off, col t , row i , col 2, row 2. angle. Ill 



Outline 
Rotated 
Solid box 
Erase area 
of screen 



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 
and column 2 is the bottom right corner 

Here Is a program that illustrates the BOX command (line 60) 



10 COLOH 0,1 

20 COLOR 1,2 

30 GRAPHIC 2,1 

40 A = RND(1)'20+ 10 

50 FOR L=0 TO 359 STEP A 

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

70 NEXT L 

80 FOR L« 1 TO 2000: NEXT L 

90 GRAPHIC 0,1 



Drawing Circles 

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 
an ellipse), and you can rotate the oval. You can also just draw a 
section ol me shape (called an arc). 



78 



1 1 i 


i ' r 


i i 


! 1 1 


1 I 1 


1 1 


1 1 I 


I I 


1 I 


1 ' 


1 1 


l 1 


! 1 1 


1 i ( 


1 1 


1 ! 1 


( 


1 1 



I 
I 

( 
I 



The usual forms of the CIRCLE command are: 



Commam! 



Effect 



CIRCLE on. centre column, centre row, radius 
CIRCLE on, c-col, c-row, width, height 
CIRCLE on, c-col, c-row, wid, hi, start, finish 
CIRCLE on, c-col, c-row, wtdth, height., .angle 
CIRCLE on. c-col. c-row. wid, ht.... point angle 



circle 
wa 
arc 

rotated oval 
polygon 



This commano draws a circle in the centre of the screen: CIRCLE 
1, 160, 100,50. This tells your computer lo draw a circle with its centre at 
column 160 and row 100. with a radius of 50. This may actually 
produce an oval, since the dots on some TV's and monitors ( American 
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 
different from the width, Uke this: CIRCLE 1,160,100,50,42. 



Drawing Polygons 

Your Commodore 16 can also draw a square, u-angle or other polygon 
using the CIRCLE command. Just tell the computer how many 
degrees to go between points on the circle, like Ihis. CIRCLE 
1,160, 100,50,42,,,. 120. This command draws a triangle, since each 
side is 1 20 degrees (Remember that omitting number values while 
including commas in a graphic command causes your computer to read 
standard default values lor the missing number.) A simple (ormula to 
get the angle lor a polygon with N sides is 360/N 



Here's a quick program lor drawing polygons: 

10 GRAPHIC 2,1 

20 INPUT-HOW MANY SIDES";A 

30 IF A < 2 OR A > 100 THEN PRINT "DONT BE RIDICULOUS": 

GOTO 20 
40 CIRCLE l.I60.80,40,33„ M 360/A 
50 GOTO 20 

You can choose to draw only an arc Instead o> a whole circle. The 
CIRCLE command accepts the starting and ending angles In degrees, 



79 



right afler the height number The command CIRCLE 
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 
if you entered the last program 






10 COLOR 0, 1 

20 COLOR 1,2 

30 GRAPHIC 1,1 

40 A = RND(l)" 20+ 10 

SO FOR L=0 TO 359 STEP A 

60 CIRCLE 1, 160. 100, 80, 40...L 

70 NEXT L 

80 FOR L= 1 TO 2000: NEXT L 

90 GRAPHIC 0,1 




I 



This program will be slightly different each time you RUN 



The Paint Command 

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 
up to the boundaries formed by lines drawn on the screen. If there are 
no lines rjrawn, the screen is filled right to the edge. The BOX 
command has a fill option that colours In boxes and rectangles. The 
PAINT command can colour in irregular shapes and other non-uniform 
areas on the screen that can't be filled with other commands. 

To see what the PAINT command does, add this line to the last 
program: 



BO 



f 

I 

I 
f 
I 
I 
( 

: 
I 
f 
( 
I 
I 
f 
f 
( 
f 
f 






75 PAINT 1, 160, 1O0 




MULTI-COLOUR GRAPHICS 

The Commodore 1 6 high resolution graphics give you control over 
every single dot or "pixel" on the screen, but you have seen that the 
ability to put colours close together is limited. Most hkes programs 
can use only one or two colours For Including more different colours, 
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 
for the use of multiple colours, which is slightly lower resolution. 

To begin using multi-colour graphics, review the GRAPHIC command 
earlier in this chapter. You'll see that the multi-colour screen without 
text is GRAPHIC 3 and the multi-colour screen with 5 lines of text Is 

GRAPHIC 4. 



Now look at the table listing the COLOR command. There are two 
areas that we haven't used yet, areas 2 and 3. These areas hold two 
extra colours. You can use any of the three colours (1 . the text colour; 
2. an extra colour; and 3, another extra colour) These colours do not 
Interfere with each other on the screen the way the hi-res colours do in 
some previous programs In this chapter. 



This program makes use of multi-colour graphics, showing a "neon 
sign" effect. 



,i 



NEW 

10 COLOR 0,1 

20 GRAPHIC 3,1 

30 COLOR 3,1 

40 TRAP 200 

50 DRAW 3,10,10 TO 10,100: DRAW 3,10,5S TO 30,55 

60 DRAW 3,30,10 TO 30,100: DRAW 3,50,10 TO 80,10 

70 DRAW 3,65,10 TO 65,100: DRAW 3,50,100 TO 80,100 

80FORL=0TO7 

90 COLOR 3,2,L 

100 FOR M= 1 TO 100: NEXT M 

110 NEXT L 

120 COLOR 3,1 

130 FOR M-l TO 100: NEXT M 

140 GOTO 80 

200 GRAPHIC 0: COLOR 1,2,7 



Colour area 3, the second of the multicolour areas, has a special ability 
that none ol the others has Once you have drawn on the screen using 
area 3, you can change that colour everywhere it appears on the 
screen by using the COLOR command, If you set the colour with 
COLOR 3,5 and draw using that colour, your graphics appear in 
purple. II you then change the colour with COLOR 3,6, all the purple 
areas would change to green. This doesn't work with any other area. 
The Series 264 Programmer's Reference Guide contains more 
information about graphics 



82 



[ 



"I 

; t 

! 

f 
( 
i 
f 
[ 
f 

r 

t 
i 

f 



r 

( 

f 
f 
( 

[ 



CHAPTER 7 



SOUND 

AND 

MUSIC 



Introduction 



Volume command 



Sound command 






• Creating sound effects 



Making some music 



The Mustc Machine 



83 






INTRODUCTION M ■ BM 

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 
your scree" Type any number trom lo 1 01 5 as your response and 
press return To stop the program, enter a zero as your value. 



10 VOL 8 

20 DO 

30 INPUT X 

35 IF X > 1013 OR X<0 THEN PRINT "0 TO 1015, PLEASE": GOTO 30 

40 SOUND 1,X, 10 

50 LOOP UNTIL X-0 



Pressing the huh /stop key also stops the program 
Here's how to play a single note on your Commodore 1 6 
First Type VOL 8 and press 






Second Type SOUND 1,266,60 and press return 



You should hear a note play tor about a second and Ihen stop. You 
might consider this an unfinished symphony in the most extreme sense 
ot the word (one note down. 3.500 lo go). II you don't hear anything, 
turn up the volume of your television or monitor and try it again 



Tnese two steps are the only commands thai you need to know to play 
music on your Commodore 1 6. Both commands are easy to 
understand and easier to use 



The Volume Command 

The VOL command controls the VOlume ol the notes that your 
Commodore 1 6 plays. The number thai comes after VOL is the selting 
tor the volume This command works pretty much like the volume knob 
on your TV When it is set at zero (VOL 0). the volume is ott and you 
won'l hear anything When you set it at 8 (VOL 8), the volume is 
turned up all the way. and your computer plays as loud as it can. 



i 



i 
i 
i 
( 

i 
i 
i 



i 



i 

f 
i 

i 
i 
i 
1 

r 
I 
i 
i 
i 



i i 
i i 

! I 
I I 

I I 



84 



I 
f 

I 



Try the first example again and use a different number after the VOL 
command. The larger the number, the louder the note is played. 



The Sound Command 

The SOUND command tells your computer everything it needs to know 
aboul Ihe sound you want to otay The SOUND command is followed 
by three numbers thai describe the note 

SOUND voce, nolo value, duration 



The first number In the sound command refers lo voice. The number 
for vo'ce can be a 1 .2 or 3 The Commodore 1 6 sound is produced by 
two different "voices", 1 for Ihe first voice and 2 for the second vo»ce. 
The third voice option applies lu voice 2's capacity to produce either a 
lone or noise. 



Voice 1 - This voice plays only tones Select INs voce wllh a 1 after 
the SOUND command 



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, 
or a 3 to use this voice for noise, to make sound effects like thunder 
and rain 



The second number after the word SOUND is Ihe note value 
(frequency). This can bo any number from O lo 101 5. It tells your 
Commodore 1 6 how low- or high-pitched a note to play As the 
numbers get larger, the noles get higher The highest values (in Ihe 
1 01 5 neighborhood) are not audible lo Ihe human ear 



Note: Wnn voice 3, noise is "white" only in the range ol 600-940 
You can use register values outside this range to create interesting 
sound effects. 



This displays a! of the notes in one scale, along with Ihe note value to 
use There is a complete chart ot notes tor the Commodore 1 6 n Ihe 
appendix. 



85 



Ill II III 41 III II I 




NOTE A B C D E F G 

VALUE 770 798 810 834 854 864 881 

ACTUAL FREQUENCY 440.4 494.8 522.7 588.7 658 699 782.2 
(HZ) 

Try the Wowing program: 



sets VOLume 



NEW 

10 VOL 8 -<— 

20 X -0 

30 DO 

40 SOUND l.X.5 ■« plays nole 

50 X = X + S 

60 LOOP UNTIL X - 1015 

70 VOL -* turns off VOLume 

80 END 



This program shows of some ol your Commodore '6's musical range. 

The third number after the word SOUND controls the Duration (length) 
ol the note This tells your computer how long to play the note. This 
number can be anything Irom to 65535. This number sets a timer, 



86 



I 



! 



f 



! 
( 

( 
( 
f 
I 
( 

( 

f 

I 



which counts time in sixtieths of a second A duration of 60 keeps the 
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 
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 
a lower one by 25 at a time 



10 VOL 8 



sets VOLume at 8 



20 FOR S= 1000 TO 700 STEP -25 
30 SOUND 1, S, 1 
40 NEXT S 



creates loop, with 
downward STEPs 



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 
scale. STEPping down 25 numbers at a time Finally, line 30 instructs 
your Commodore 16 to play each note lor (us: an instanl by selttng the 
DURATION to 1 , which is 1 /60 ol a second. Experimenting with 
different number and duration values can give you some very 
interesting effects. 



Creating a Noise Sound Effect 

Using a value ol 3 when selecting a voice in the SOUND command 
spc-cilies noise. This is used lo create sound effects with noise rather 
than tone. The following program uses voice 3 lo create the sounds ol 
a windstorm. 

10 VOL 2 -« sets VOLume level 

20 R-INTIRND{0)-10) + 1 < selects RaNDom number Irom 1 

30FORX = 1TOR to 10 



40 SOUND 3, 600+ 30*X, 10 



{continued on next page) 



87 



r 






50 NEXT X 

60FORX = RTO 1 STEP -1 

70 SOUND 3, 600+30-X, 10 

80 NEXT X 

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

100 SOUND 3 r 600, T 

110 GOTO 20 



Lines 30 and 60 sel up FOR . . NEXT loops lor the nole value 
(frequency) ol Ihe sound, one increasing and one decreasing, based on 
the random number from line 20. 11 Is Important to have variation in 
pilch, since windstorms have different forces of gusts of wind. Lines 40 
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 
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 
the gusts of wind. This may seem pretty complicated, like you need to 
be an experienced programmer to be able 10 do li. But it's really 
nothing more than experimenting, trying different things, and seeing 
what noise comes out. Creating sound effects using noise is 
challenging, trying to capture Ihe right elements of the sound you want 
exactly To be good al it. you have lo be willing lo experiment 



Making Some Music 

You may nol understand everything that's going on in these programs, 
but type Ihem In anyway and see what happens 

This program simulates a piano using the Keys Irom 1 through 8. 

5 SCNCLR 

10FORX-1TOB: READN(X): NEXT X 

20 VOL 8 

30 DO 

40 GET AS: IF A$="" THEN 40 

30 A=ASC(A$): IF A<49 OR A >56 THEN 90 

60N-A-48 

70 SOUND 1, NfN), 5 

80 COLOR 4, N, 3 

90 LOOP UNTIL A = 32 

100 VOL 0: COLOR 4, 2, 7 

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



I 

I 
( 

I I 

f I 

I ( 
f 



I 



Bfl 



1 


' 


1 


1 


1 




1 


1 


( ! 


1 



Press numbers 1 Ihrough 8 to play notes. The screen border even 
changes colours with the different noles When you finish playing, 
press Ihe space bar to slop me program. 



Now thai your Commodore 1 6 can be used like a piano, you mighl feel 
(he urge to play a popular song. Here are Ihe numbers lo press lo play 
a well-known song that surely must be considered a classic. 



115 5 6 6 5 

4 4 3 3 2 2 

5 5 4 4 3 3 2 
5 5 4 4 3 3 2 
115 5 6 6 5 
4 4 3 3 2 2 1 



i mmm 



This next program plays a song by reading a list ol DATA statements 
Your compute' READs the numbers contained in the DATA statement 
as values for variables (in this case X and Y), changing the values with 
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 
duration for the SOUND command 

Row Boat 



10 VOL 8 

20 DO 

30 READ X, Y 

40 SOUND 1, X, Y 

45 FOR D=l TO Y'16+30:NEXT 

50 LOOP UNTIL X=0 <— 

60 END 

100 DATA 169, 45, 169. 45, 169, 30 

110 DATA 262, 15, 345, 45, 343, 30 

120 DATA 262, IS, 345, 30, 383, 15 

130 DATA 453, 60, 596, 45, 453, 45 

140 DATA 345, 45, 169, 45, 453, 30 

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

160 DATA 169, 60 

200 DATA 0, 



This loop creates a brief delay 
between notes 



\ 



THE GREAT COMMODORE 16 
MUSIC MACHINE 

The (asl program is a little longer. Tnis is the "GREAT COMMODORE 
16 MUSIC MACHINE". When you press a key from 1 through 9, the 
note is played, and a note appears on the start on the correct line. 









5 GOSUB 1000 

6F0RX = 1T0 9: READ N(X}: NEXT X 

8 CHAR 1. 8, 1,"*THE GREAT MUSIC MACHINE*" 

10 VOL 7 

20 DO ( 1 

30 GET A$: IF AS= ,[ " THEN 30 'no space 

35 A = ASC(A$) : IF A < 49 OR A > 57 THEN 50 

36 N= A - 48 
40SOUNDi,N(N), 4 

45 GSHAPE N$, 150, 8 ■ <6+(9-N)), 4 

46 FOR Z=l TO 50: NEXT Z 

47 GSHAPE N$, ISO, 8 ' (6+(9-N)). 4 
50 LOOP UNTIL A = 32 

55 VOL 0: GRAPHIC 0: SCNCLR 

60 END 

100 DATA 345, 383. 4S3, 516, 571, 596, 643. 68S, 704 

1000 GRAPHIC 1,1 

1010 FOR Y=60 TO 124 STEP 16 

1020 DRAW 1, 100, Y TO 200, Y 

1030 NEXT Y 

1040 AS="FEDCBAGFE" 

1050 FOR X = l TO 9: C- 13 

1060 IF INTCX/2) - X/2 THEN C = 14 

1070 CHAR 1, C, X + 6, MIDS <A$, X, 1), 

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

1080 NEXT X 

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 

1110SSHAPENS, 1,1,8, 16 

1120 GSHAPE N$, 1 ( 1,4 

1130 RETURN 



90 







1 


r 


1 


i 


1 


r 


1 




1 


r 


1 




1 


( 


1 


1 


1 


( 


( 


i 


1 


f 


1 


( 


1 




1 


( 


1 


i 


1 


( 


1 


[ 


1 


( 


i 


( 


1 


( 


r 









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 
give you a taste of the music capabilities of your Commodore 1 6 Don't 
be afraid to try new sounds and noises and create your own 
masterpiece. 

By now, you've begun to get a handle on some ot the things you can 
do with your Commodore 1 6. The aim of this manual has been to give 
you a taste ot computing, to have you try new things and see wnat 
happens, to learn about your computer and lo have fun In the process 
But there's still so much more , , programming, for example. This 
manual has touched on how lo begin lo use BASIC, but is nol a tutorial 
or BASIC lexlbook by any means. The BASIC Encyclopedia 
(Immediately lollowlng this chapter) gives a complete listing of ALL the 
BASIC commands on your Commodore 1 6. with explanations and 
examples. In many of the programs in the last couple of chapters, you 
may not have understood exactly what steps were doing what. To 
learn more aooul programming with the BASIC language, you should 
read books lhal were written to leach BASIC A list of these books 
appears in the appendix. It you are really interested in programming, 
you might want to gel the Series 264 Programmers Reference Guide, 
whicn focuses on the hows and whys of programming, revealing the 
secret and not-so-secret tricks of the programming trade Now thai 
you've finished reading this manual, you mighl think that you're on your 
own, bul not entirely. You can read any o' the many computer 
magazines, some of which are entirely devoted to Commodore 
computers, peripherals and software You can also become part of a 
group of people near you who share your interest in Commodore 
computers; a Commodore User's Group. For moie Information on these 
groups, contact the CBM Information Centre. 



F 



I 



< 

f 
( 
f 
( 
( 
I 
I 
I 

( 
I 
I 

I 

< 
i 

I 
I 
I 



I f 

I i 



92 



[ 



BASIC 3.5 



ENCYCLOPEDIA 



Introduction 



Commands 



Statements 



Functions 



Variables and operators 



Abbreviation and reference chart 






ftt 



INTRODUCTION 

You've seen in Ihis manual an assortment ot exercises using Ihe BASIC 
language, to give you a (eel tot computer programming and some ot 
ihe vocabulary Involved. This encyclopedia gives a complete list ol the 
rules and lerms (SYNTAX) of the BASIC 3.5 language, along with a 
concise description ot each Experiment with these commands, and 
remember that you can't damage your Commodore 1 6 by typing in 
programs, and that Ihe best way to learn computing Is by doing 

The encyclopedia provides formats and briet explanations and 
examples ol Ihe BASIC 3 5 commands and statements. It Is not 
intended to teach BASIC. It you are Interested in learning BASIC, 
Appendix G lists tutorial books that witl help. 

Commands and statements are listed In separate sections. Within Ihe 
sections, Ihe commands and statements are listed in alphabetical order. 
Commands are used mainly In direct mode, white statements are most 
ollen used In programs. In most cases, commands can be used as 
statemenls In a program it you prefix them wild a line numoer. You can 
use many statements as commands by using them in direct mode (i.e., 
without line numbers) II you are unsure where a term is located, they 
are all 'Isled in tne reierence chad. 

The BASIC Encyclopedia is organized along the lines ot the tallowing 

• COMMANDS: the commands used lo work with programs, edit, 
store, and erase them. 

• STATEMENTS: the BASIC p*ogram statements used In numbered 
lines ot programs. 

• FUNCTIONS: the string numeric, and prim functions 

• VARIABLES AND OPERATORS: the dllterent types of variables, 
legal variable names, and arithmetic and logical operators. 

A luiler explanation of BASIC 3.5 commands is provided in Ihe Series 
264 Programmer's Reierence Guide, available from your Commodore 
dealer or your local bookstore. 

COMMAND AND STATEMENT FORMAT 

The commands and statements presented in Ihis section of the 
encyclopedia follow consistent format conventions to make them as 
clear as possible. In most cases, there are several examples to 
Illustrate whal the aclual command looks tike The following example 
shows some of the format conventions that are used In Ihe BASIC 
commands and statements; 



94 






I 



EXAMPLE LOAD'program name",D0. U8 

\ ar 



keywords 



irgument 



.additional arguments 
(possibly optional) 



Ihe parts of the command or statement that you must type In exactly as 
they appear are highlighted in a darker lype in Ihe format listing, while 
the name of the command is in capital letters. The words that you don't 
type in exactly, such as the name of a program, are printed in lighter 
italic type. When quote marks (" "> appear (usually around a program 
or file name), you should include them in the command or statement, 
like In Ihe format example 

• KEYWORDS appear in uppercase tetters and boldface type. YOU 
MUST ENTER THESE KEYWORDS EXACTLY AS THEY APPEAR 
However, many keywords have abbrevialions that you can also use 
(see the reference chart). 

Keywords are words lhat are part ot Ihe BASIC language that your 
computer knows Keywords are the central part of a command or 
statement They tell the computer what kind of action you wanl it to 
lake. These words cannot be used as variable names. 



• ARGUMENTS (also called parameters) appear In lowercase letters 
Arguments are the parts of a command or statement that you select; 
they complemenl keywords by providing specific information aboul the 
command or statement. For example, a keyword tells Ihe computer lo 
load a program, while an argument tells Ihe computer which specific 
program lo load and e second argument specifies which drive the disk 
containing the program is in Arguments Include filenames, variables, 
line numbers, etc. 



• SQUARE BRACKETS [| show OPTIONAL arguments You select 
any or none ot the arguments iisted. depending on your requirements 



• ANGLE BRACKETS < > indicate that you MUST choose one of the 
arguments listed. 



• VERTICAL BAR i separates items in a list ot arguments when your 
choices are limited lo those arguments listed, and you can't use any 
other arguments. When the vertical bar appears in a list enclosed in 
SQUARE BRACKETS, your choices are limited to the items in the list, 
but you still have the option not lo use any arguments 



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

• QUOTATION MARKS " ' enclose character strings, filenames, and 
other expressions When arguments are enclosed in quotation marks in 
a formal, you musl include the quotation marks in your command 0( 
statement. Quotation marks are required parts of a command or 
statement 

• PARENTHESES When arguments are enclosed in parentheses In a 
format, you must include the parentheses in your command or 
statement. Parentheses are also required when they appear »n a 
command or statement description. 

• VARIABLE refers to any valid BASIC variable name, such as X. A$. 
orT% 

• EXPRESSION means any valid BASIC expression, such as A+B+2 
or 5*(X+3) 



BASIC COMMANDS 

AUTO 

AUTO [line* J 

Turns on the automatic line numbering feature which eases the job of 
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 
the screen, with the cursor In position to begin typing thai line. The 
[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 
AUTO 10 
AUTO 50 
AUTO 



automatically numbers line in increments o( ten 
automatically numbers line In increments of fifty 
turns OFF automatic line numbering 



96 



I 



f 



f 



BACKUP 



BACKUP Ddnve* TO Ddrive* |, ON Uunrt#| 

This command copies all the Dies on a diskette to another diskette on a 
dual drive system. You can copy onto a new diskette without first using 
the HEADER command to format the new diskette because the 
BACKUP command copies al> the information on the diskette, Including 
the format. You should always BACKUP important diskettes In case 
the original is lost or damaged 

Because the BACKUP command also HEADERS diskettes, II destroys 
any information on the diskette onto which you're copying information 
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 
command 



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



EXAMPLES: 
BACKUP DO TO Dl 

BACKUP DO TO Dl , ON U9 



Copies all files from the disk in drive 

to tne disk in drive 1 

Copies all files from drive C to drive 

1 In disk drive unit 9 



COLLECT 



COLLECT [Ddrive#] |,ON Uuml#l 

Use this command to free up space allocated to improperly closed files 
and deieles references to these files from the directory 



97 



[ I 



EXAMPLE 
COLLECT DO 



CONT 

CONT (Continue) 

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 
END statement within the program. The program win resume execution 
where it 'eft off. CONT will not work if you have changed or added 
lines of the program (or even (ust moved the cursor to a program line 
and hit return without changing anything), if the program slopped due 
to an error, or if you caused an error before trying to re-start the 
program The error message in this case is CAN'T CONTINUE ERROR. 



COPY 

COPY [Ddrive#,J "source file" TO [Ddrivejf ,) "other file" [,ON Uuntt#] 

COPYs a file on the disk in one drive (the source file) to the disk in the 
other on a dual disk drive only, or creaies a copy of a file on the same 
drive (with a different file name). 



EXAMPLES- 
COPY DO/'NOON" TO Dl, "NIGHT" 

COPY DO, "STUFF" TO Dl, "STUFF" 
COPY DO TO Dl 



Copies NOON from 
drive lo drive 1 , 
renaming it NIGHT 

Copies STUFF from 
drive to drive 1 

Copies all tiles from 
drive Q to drive 1. 



■"'.'/ 



COPY "CATS" TO "DOGS" 






f 



I 

[ 
I 

f 
( 

I 



Copies CATS as a 
program called DOGS 
on ihe same drive. 



DELETE 

DELETE [first Hne#J |- iasl llne*| 

Deletes lines ot BASIC text. This command can be executed only in 
direct mode. 



EXAMPLES: 
DELETE 75 
DELETE 10 - SO 
DELETE -30 

DELETE 75- 



Deietes line 75. 

Deetes lines 10 through 50 inclusive. 

Deletes all tines from the beginning ol the 
program up to and Including line 50. 

Deletes ail lines from 75 on to Ihe end of the 
program 



DIRECTORY 



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

Displays a disk directory on the Commodore ^6 screen Use CTRL -S 
lo pause Ihe display (any other key restarts the display after a pause) 
Use me fr key (Ihe Commodore key) to slow II down. The 
DIRECTORY command cannot be used to print a hard copy Y ou must 
load the disk directory (deslroying the program currently in memory) to 
do that. 



f 



BB 



EXAMPLES 

DIRECTORY 

DIRECTORY Dl ( U9, "WORK" 

DIRECTORY "AB*" 
DIRECTORY DO, "FILE ?.BAK" 



List all files on the disk 

Lists the file on disk drive unit 9 (8 
is the delaull). drive 1 , named 
WORK 

Lists all files starting with the letters 
"AB", like ABOVE. ABOARD, etc. 

The ? Is a wild-card that matches 
any single character in thai 
position: FILE 1 .BAK, FILE 2.BAK. 
FILE 3.BAK all match the siring. 



NOTE: To print out the OIRECTORY ot drive 0, unit 8, use the 
following. 

LOAD"$0",8 
OPEN4,4:CMD4:UST 

PRINT#4;CLOSE4 



DLOAD 



DLOAD "filename" [,Ddrive#| [,Uun«*| 

This command loads a program from disk into current memory. (Use 
LOAD to load programs on lape.) You must supply a program name. 



EXAMPLES 
DLOAD "DTRUCK" 

DLOAD (A$) 



Searches the disk tor the program 
DTRUCK" and LOADS it. 

LOADs a program trom disk whose 
name is in the variable AS. You will get 
an error it A$ is empty. 



100 



1 



r 



The DLOAO command can be used within a BASIC program lo find and 
RUN another program on disk. This is called chaining. 



DSAVE 



DSAVE filename" |,Ddrrve#] [,Uunrt#] 

This command stores a program on disk (Use SAVE to store 
programs on tape.) You must supply a program name. 



EXAMPLES 
DSAVE "DDAY" 
DSAVE (AJ) 

DSAVE "PROG 3", D0.U9 



SAVES the program "DDAY" to disk 

SAVEs to disk program whose name 
is In the variable AS. 

SAVES Ihe program "PROG 3" lo the 
disk drive with a unit number of 9. 



HEADER 



HEADER "dtskname" ,Ddrlve# [,Iid #| |,ON Uunit#] 

Before you can use a new diskette for the firsl time you must format it 
with Ihe HEADER command. If you want to erase an entire diskette for 
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 
name up to 1 6 characters long The i d. number is any 2 characters. 
Give each disk a unique id number Be careful when you HEADER a 
disk because Ihe HEADER command erases all sioreo data Giving no 
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 
previously formatted, since the quick header only clears out the 
dkecto'y rather than formatting ihe disk. 



101 



EXAMPLES: 



HEADER "MYDISK", 123, DO 
HEADER "THEBALL", US, Dl, US 



HELP 



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 
me portion containing the error displayed in Mashing characters. 



KEY 









KEY |key#. string) 



There are eight (8) function Keys availaDle to Ihe user on your 
Commodore 16 compuler tour unshitted and lour shifted Your 
Commodore 16 allows you to define what each key does when 
pressed. KEY without any parameter specified gives a listing displaying 
all the current KEY assignments: The data you assign to a key is typed 
out when that lunction key is pressed. The maximum length tor all the 
definitions together is 1 28 characters. Entire commands or a series of 
commands) can be assigned to a key. For example: 



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

causes the compuler lo select lexl mode and list your program 
whenever Ihe 'F7' key is depressed (in direct mode). The CHR5(1 3) is 
the ASCII character for ktuwi Use CHR$<34) to incorporate a 
double quote into a KEY string. 



! 'I 

I 

I I 

I ( 

I ( 

) I 
I 

I I 




102 



I I ( 

I ' I 
I 

I I 

I I 



I I 

I 
I 

I . 1 
I . I 
I [ 



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



10KEY2,"TESTING" + CHR$(34):KEY3, "NO" 



10 FOR I - 1T0 8: KEY I, 
CHR$(I+132):NEXT 



defines the function keys as 
they are defined on the 
Commodore 64 and VIC 20 



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, 



LIST 



LIST [first line) I -[last tine]] 

The LIST command lets you look al lines of a BASIC program that have 
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 
holding down ihe & key, paused by CTKL -S (unpaused by pressing 
any other key), or STOPped by pressing the mm/no* key. II you 
follow Ihe word LIST with a line number, your Commodore 1 6 only 
shows that line number If you type LIST wilh iwo numbers separated 
by a dash, the Commodore 1 8 shows all lines from the first to the 
second line number. If you type LIST followed by a number and just a 
dash, il shows all the lines from that number lo the end of the program 
And if you type LIST, a dash, and then a number, you get all the lines 
from the beginning ol the program to that line number Using these 
variations, you can examine any portion of a program, or easily bring 
lines lo the screen for modification. 



EXAMPLES. 



LIST 



LIST I0Q- 



Shows entire program 

Shows from line 100 until the end of me program. 



103 



LIST 10 Shows onfy line 10. 

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

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



LOAD 

LOAD ["filename" (.device*] [.relocate flag) ] 

This Is the command to use when you want to use a program stored on 
cassette tape or on disk. It you type just LOAD and hit the hetorn 
key, the Commodore 16 scieen goes blank. Press play, and the 
Commodore 1 6 starls looking for a program on the tape When It llnds 
one. the Commodore 1 6 prints FOUND "lliename" You can hit the 
C" key to LOAD; rf you don't press Ihe key, the compuier resumes 
searching on the tape after a brief interval. Once the program is 
LOADed, you can RUN. LIST, or change D 



You can also type the word LOAD followed by a program name, which 
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 
variable), which acts as a device number to determine where Ihe 
program is stored (disk or tape) tt there is no number given, your 
computer assumes device number 1 , which is the cassette tape 
recorder. 



The other device commonly used w<m the LOAD command Is usually 
the disk drive, which Is device number 8. 



EXAMPLES: 

LOAD 

LOAD "BASES' 

LOAD A$ 

1CM 



Reads in the next program on tape 

Searches tape for a program called 
BASES, and LOADS it if h is found 

Looks for a program whose name is m 
the variable called AS. 



i 
i 
i 
i 
i 
i 
i 
i 
i 
i 
i 
i 

[ 



I 
( 
I 
f 
f 

r 

f 
i 



LOAD "BRIDGES" f 8 



Looks tor the program called BRIDGES 
on the disk drive, and LOADS it if found. 



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

The RELOCATE FLAG determines where in memory a program is 
loaded. A relocate (lag of tells the Commodore 1 6 to load the 
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 
relocate Hag is 0. This is generally used only when loading machine 
language programs. 



NEW 



NEW 

This command erases the entire program in memory and clears out any 
variables that may have been used Unless the program was stored 
somewhere. It 'S lost uniil you type il in again. Be careful when you use 
tnis command 

The NEW command can also be used as a statement m a BASIC 
program. When your Commodore 16 gels to this line, the program Is 
erased and everything stops. This is not especially useful under normal 
circumstances . 



RENAME 

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

Used to rename a file on a diskette. 
EXAMPLE 



RENAME D0."ASSET" TO 
"LIABILITY" 



Changes Ihe name of the file from 
ASSET to LIABILITY 



105 



RENUMBER 

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

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



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



The o'd starling line number is ihe line number in (he program where 
renumbering is lo begin This allows you to renumber a portion of your 
program. It defaults lo Ihe first line of your program. 

This command can only be executed from direct mode 
EXAMPLES 



RENUMBER 20, 20, 1 



RENUMBER, , 65 



Starting al line 1 , renumbers Ihe program 
Line 1 becomes line 20. and omer unes 
are numbered in increments of 20. 

Starting at line 65. renumbers m 
Increments of 1 0. Line 65 becomes line 
1 (unless there are already lines 
numbered 10-64, In which case fhe 
command Is nol carried out). 



RUN 

RUN |Une f\ 

Once a program has been typed Into memory or LOADed, the RUN 
command makes it start working RUN clears all variables in the 
program belore starling program execution If Ihere is no number 
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 
program. 



■Oh 



( 

I 

I 
I 

I 
[ 
I 
I 
I 

I 

I ( 

! 

I 

I I 

I 

I 

: I 
I 
I 

' I 

f 



EXAMPLES: 
RUN 
RUN 100 



Slarts program working from lowest line number. 
Starts program at line 1 00 



SAVE 

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

This command stores a program current ly in memory onto a cassette 
tape or disk. If you just type the word SAVE and press BETUWi your 
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 
location, so be careful with your tapes If you type the SAVE command 
followed by a name in quoles or a siring variable name, the 
Commodore 16 gives the program lhal name, so It may be more easily 
located and retrieved In Ihe future. If you want to specify a device 
number for the SAVE, follow the name by a comma (after the quotes) 
and a number oi numeric variable Device number t is the tape drive, 
and number 8 is the disk. Alter the number on a tape command, there 
can be a comma and a second number, which is between and 3 
second number is 2, the Commodore 1 6 puts an END-OF-TAPE marker 
(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 
you are trying to LOAD, you get a FILE NOT FOUND ERROR 



EXAMPLES 



SAVE 



SAVE "MONEY" 



SAVE AS 



SAVE "YOURSELF"^ 



Stores program to tape withoul a name. 
Stores on tape with the name MONEY 
Stores on tape with name m variable AS 
Stores on disk with name YOURSELF 



107 



SAVE "GAME". 1, 2 



Stores on tape with name GAME and 
places an END-OF-TAPE marker after me 
program. 



SCRATCH 

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

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



EXAMPLE: 



SCRATCH "MY BACK", Dl 



Erases the file MY BACK from the 
disk m drive 1 



VERIFY 



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

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 
you |ust SAVEd Is really saved, to make sure that nothing went wrong 
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 
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 
don't match (which you already knew) Now the tape is where you 
want it, and you can store the next program without fear of erasing an 
old one. 



1 08 



[ 

f 

I 

f 

I 
I 



! 



I 
I 
( 
I 

I 
I 
' 
( 
( 
I 
I . ( 

I I 
I ( 
I ( 



VERIFY without anything after the command causes the Commodore 
1 6 to check the next program on tape, regardloss of its name, against 
the program now in memory VERIFY followed by a program name (in 
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 
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. 



EXAMPLE: 
VERIFY 

VERIFY "REALITY" 
VERIFY "ME",8,1 



Checks the next program on the 
tape. 

Searches for REALITY on tape, 
checks against memory, 

Searches for ME on disk, then 
checks. 



BASIC STATEMENTS 
BOX 



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



colour source 
ai.bl . 
a2, b2 . 

angle 

paint 



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

. Corner coordinate (scaled) 

. .Corner opposite at . bt (scaled); default ts the PC 
. . . Rotation in clockwise degrees: default Is degrees 
, , . Paint shape with colour (0:off, 1 on); default Is 



This command allows you to draw a rectangle of any stee anywhere on 
the screen To get the default value, include a comma without entering 
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. 



EXAMPLES 

BOX 1, 10, 10, 60, 60 



Draws Ihe outline of a rectangle 



109 



BOX , 10, JO, 60, 60, 45, 1 



BOX , 30, 90, . 45, 1 



Draws a filled, 
diamond) 



rolaled box (a 



Draws a tilled, rotated polygon 



CHAR 



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



colour source 

A ■ i * • ■ * i ► * ■ 

y 

"slnng" 

reverse. 



Colour source (0 - 3) 

Character column {0 - 39) 

Character row (0 - 24) 

, , i , Text to be printed 
Reverse fiold flag (0 = off, 1 » on) 

Text (alphanumeric strings) can be displayed on any screen at a given 
location by the CHAR command. Character data is read from the 
Commodore 1 6 character ROM area. You supply the x and y 
coordinates of the starting position and the text string you want to 
display. Colour source and reverse imaging are optional 

The string is continued on the next line If it attempts to print past the 
right edge of me screen. When used In TEXT mode, the string printed 
by the CHAR command works just like a PRINT string, including 
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 
in GRAPHIC mode. 



CIRCLE 

CIRCLE |cs] ,[a.b). xr [, [yr] [, [sal. |. [ea) [, | angle) [,inc] j J ] 

CS . Colour source (0 - 3) 

a.b Centre coordinate (scaled) 

(defaults to the Pixel Cursor |PC]) 

xr X radius (scaled) 

y Y radius (detault is xr) 



110 



I 



! 
f 
[ 
I 
I 
( 
I 

i 

i 
i 

i 

i 
i 



T . 



angle 

•nc 



Starting arc angle (default 0) 
Ending arc angle (detault 360) 
.Rotation in clockwise degrees 
(default is degrees) 
Degrees between segments 
(default is 2 degrees) 





With the CIRCLE command you can draw a circle, ellipse, arc, triangle 
or an octagon The final coordinate Is on the circumference ot the 
circle at the ending arc angle. Any rotation is about the centre. Arcs 
are drawn Irom the starling angle clockwise lo the ending angle The 
segmeni Increment controls the coarseness of the shape, with lower 
values for inc creating rounder shapes. 



EXAMPLES 



CIRCLE, 160,100.65,10 
CIRCLE, 160.1Q0,6S,50 
CIRCLE ,60,40,20,18,, ,.45 
CIRCLE, 260,40,20,,, „90 
CIRCLE , 60,140,20,18,,,, 120 



Draws an ellipse. 
Draws an oval. 
Draws an octagon 
Draws a diamond 
Draws a triangle. 



111 



I 



CLOSE 



CLOSE tile * 



This command completes ana closes any files used by OPEN 
statements. The number following Ihe word CLOSE Is the (He number 
(o be closed. 



EXAMPLE 
CLOSE 2 






Logical Hie 2 is closed. 



CLR 



CI.R 



This command erases any variables In memory, but leaves Ihe program 
ilseif intact. This command ib automatically executed when a RUN or 
NEW command is given, or when any editing Is performed 



CMD 

CMDIile# [.write HstJ 

CMD sends the output which normally would go to the screen (I.e. 
PRINT statement, LISTS, but not POKEs into the screen) (o another 
device Instead. This could be a printer, or a data file on tape or disk. 
This device or Hie must be OPENed first. The CMD command must be 
toilowed by a number or numeric variable referring to the (lie. 



EXAMPLES: 
OPEN 1,4 
CMD1 
UST 

112 



OPENS device 0A, which is the printer. 

AH normal output now goes to the printer 

The USTing goes to the pnnter, not the screen 
even the word READY. 



I 



I 

i ' 
i i 



i ' 
i ' 
i : I 
i i 
i i 
i I 
I I 
i ' 
i ' 

I ' 
I I 

i ' 

I ' 
( ' 
i I 

i i 

i ' 

i I 
i ' 



PRINT* 1 



CLOSE 1 



Set output back lo me screen. 



Close the die. 



COLOR 

COLOR source *. colour # [.luminance #| 

Assigns a colour to one of the 5 colour sources: 

N umber Sourca 

background 

1 foreground 

2 multicolour 1 

3 multicolour 2 

4 border 



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



DATA 

DATA list of constants separated by commas 

This statement is followed by a list of items to be used by READ 
statements. The items may be numbers or words, and are separated by 
commas Words need not be inside of quote marks, unless they 
contain any of the following characters: SPACE, colon, or comma. If 
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 
part of a program, otherwise it will not be recognized. Also see the 
RESTORE statment. which allows your Commodore 16 lo reread data 



113 



EXAMPLE: 



DATA 100, 200, FRED, "WILMA", , 3. 14. ABC123 



DEF FN 



DEF FN name (variable) - expression 

This command allows you lo define a complex calculation as a lunclion 
In the case of a long formula thai is used several times within a 
program, this can save a lot ol space. 



The name you give the numeric function begins with the letters FN, 
followed by any lega' numeric variable name. First you must define the 
function by using the statement DEF followed by the name you've given 
the function Following trie name Is a set ol parentheses (J with a 
numeric variable (in this case. X) enclosed. Then you have an equal 
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 
20 of the example below: 



EXAMPLE 



10DEFFNA(X)=12'(34.75-XA3)+X 



20 PRINT FNA(7) 



The number 7 is inserted each 
piace X is located In the formula 
given m the DEF statement. 



NOTE: DEF FN can only be used wnh standard numeric functions, 
not integer or string functions. 



i 



( 

( 

i 
( 
i 
i 

! 
I 



114 



I I 

I I 

I ! 

I I 

I I 

( 1 

I ( 

I I 

I I 

I . I 

I ! 

( I 

I I 

I I 

( I 



DIM 



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 
is followed 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 
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 it Is easy lo run out of memory if you gel 
carried away. To figure the number of variables created with each DIM. 
multiply Ihe total number of e'ements In each dimension of the array 
(Each array starts with element 0.) 



NOTE: Integer (single-digit) arrays take up 2/5ths of Ihe space of 
floating point arrays 



EXAMPLE 

10 DIM AS(40).B705).CC%<4.4,4) 




41 Elements 16 Elements 125 Elements 



You can dimension more than one array In a DIM statement by 
separating the arrays by commas. It the program executes a DIM 
statement for any array more lhan once, you'll get a re'DIMed array 
error message II is good programming practice to place DIM 
stalemenls near ihe beginning of the program 



DO (LOOP) WHILE (UNTIL EXIT) 



DO|UNTIL boolean argument | WHILE boolean arguement) 
stalemenls [EXIT] 



115 



I '( 



LOOP[UNTIL booiean argumeni WHILE boolean argument] 

(An example of a boolean argumeni Is A=l or H>-57 ) 

Performs the siatemenis between ihe DO statement and the LOOP 
statement. If no UNTIL or WHILE modifies either the DO or the LOOP 
statement, execution of the intervening statements continues 
Indefinitely. If an EXIT statement is encountered io the body of a DO 
loop, execution is transferred to the first statement lollowing the LOOP 
statement DO loops may be nested, lollowing the rules defined for 
FOR-NEXT loops. 



It the UNTIL parameter is used. Ihe program continues looping until the 
boolean argument is satisfied (becomes TRUE). The WHILE parameter 
Is basically the opposite of the UNTIL parameter; the program continues 
looping as long as the boolean argument is TRUE. 

EXAMPLE: 

DOUNTTLX-0ORX-1 

LOOP 
DO WHILE A$="":GET A$:LOOP 



I 



DRAW 

DRAW (colour source *\ [, al. b1][,TOa2, b2.][ .] 

With this command you can draw Individual dots, lines, and shapes. 
You supply colour source (0-3). starting (al , b1 ) and ending poinls (a2. 
b2). 

EXAMPLES: 

a dot DRAW 1. 100, 50 — no endpolnt specified, defaults to 

a1 ,b1 value tor a2.b2 to create a dot 
lines: DRAW . 10.10, TO 100,60 

DRAW TO 25,30 
a shape: DRAW , 10,10 TO 10.60 TO 100,60 TO 10,10 



( 

f 
( 
I 
f 



116 



I ( 
( ( 



I I 

I I 

I < 

I ( 

I ( 

I ( 

I f 

( I 

I ( 

( ( 

I ( 
I . f 

( ( 
I . f 

( f 



END 



END 



When the program executes an END statement, the program stops 
RUNnlng Immediately. You may use the CONT command to re-start 
the program at Ihe statement following the END statemenL 



FOR . . . TO . . . STEP 

FOR variable = start value TO end value (STEP increment] 

This statemenl works with the NEXT statement to set up a section of 
the program that repeals for a set number of times. You may Just want 
your computer to count up to a large number so the program pauses for 
a few seconds, in case you need something counted, or something 
must be done a certain number o' times (such as printing). 



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 
beginning and ending counts tor the loop variable. 



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 
command NEXT, it adds tne STEP increment (default ■ 1 ) to the value 
of the loop variable and checks to see If It Is higher than the end of loop 
value. If It is not higher, the next line executed is the statement 
immediately following the FOR statement. If the loop variable is larger 
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. 



EXAMPLE' 

10 FOR L - 1 TO 20 

20 PRINT L 

30 NEXT L 

40 PRINT "BLACKJACK! L - "I 



■ 



117 



This program prints Ihe numbers from one lo twenty on Ihe screen, 
lollowed by Ihe message BLACKJACK! L ■ 21 . 



The end of loop value may be lollowed by (he word STEP and another 
number or variable In this case, Ihe value following ihe STEP is added 
each lime instead ol one. This allows you lo count backwards, by 
fractions, or any way necessary. 



You can set up loops inside one another. This Is known as nesting 
loops. You must be careful to nest loops so that the last loop to start is 
the first one to end. 



EXAMPLE OF NESTED LOOPS 



[ 



10 FOR L = 1 TO 100 

20 FOR A = S TO 11 STEP 2 

30 NEXT A 

40 NEXT L 



TiisHDR. NEXT 
loop ts "nested 1 ' inside 
Ihe larger one. 



GET 



GET variable list 

The GET statement is a way to get data from the Keyboard one 
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) 
character is returned, and the program continues without waning for a 
key There is no need to press tne return key. and m fact the 
hetuum key can be received with a GET 



118 



f 'I 
I ( 

: I 

i r 
i i 
i i 
i i 
i 1 
i i 
i 

i i 
i 1 
i i 

i i 
1 < 
' ( 
i i 
i i 
i < 
i i 
i i 
i t 

I . ! 

I ( 



The word GET Is followed by a variable name, usually a string variable, 
tf a numeric were used and any key other than a number was hit, the 
program would stop with an error message. The GET statement may 
also be put into a loop, checking for an empty result, which waits for a 
key lo be struck to continue. The GETKEY statement could also be 
used in this case. This command can only be executed within a 
program. 



EXAMPLE. 

10 GET A$:IF A$ "A" THEN 10 



This line warts for the 
'A' key to be pressed 
to continue, 



GETKEY 

GETKEY variable list 

The GETKEY statement Is very similar lo the GET staiement. Unlike 
the GET statement. GETKEY waits for Ihe user to type a character on 
the keyboard This lets it be used easily to wait tor a single character to 
be typed, 

This command can only be executed within a program. 
EXAMPLE: 



10 GETKEY AS 



This line waits tor a key to be 
struck. Typing any key will 
continue the program 



GET 



GET* file number, variable list 



111 



Used with a previously QPENed device or file to input one character at 
a lime. Otherwise, it works like the GET statement 

This command can only be executed within a program. 



EXAMPLE: 
GET*1,A$ 



GOSUB 



GOSUB line # 

This statement is like the GOTO statement, except that your 
Commodore 1 6 remembers where It came from When a line with a 
RETURN statement is encountered, the program Jumps back to the 
statement immediately following the GOSUB The target of a GOSUB 
statement is called a subroutine A subroutine is useful it there is a 
routine In your program that can be used by several different portions of 
the program Instead of duplicating the section of program over and 
over, you can set it up as a subroutine, and GOSUB to it from the 
different parts of the program See also the RETURN statement. 



EXAMPLE 

20 GOSUB 800 



means go to the subroutine 
beginning al line BOO and execute 



800 PRINT "HI THERE";RETURN 



GOTO or GO TO 



GOTO line # 



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 



120 



1 ( 

I 

( 

I 

I 
f 
1 

r 

. i 
i 

1 

( 
f 

i 
i 

f 

( 
i 

i 



in direct mode. GOTO line # allows you to start execution of the 
program at the given line number witnout clearing the variables 

EXAMPLE: 

10 PRINT "REPETITION IS THE MOTHER OF LEARNING" 
20 GOTO 10 

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



GRAPHIC 

GRAPHIC mode [.clear option] 

This statement puts your Commodore 16 in one of lis 5 graphic modes 

mode description 

normal text 

1 high-resolution graphics 

2 high-resolution graphics, spilt screen 

3 multicolour graphics 

4 multicolour graphics, split screen 



When executed. GRAPHIC 1 - 4 allocates a 10K bit-mapped area, and 
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). 
It 1 is given in the GRAPHIC statement as the second argument, the 
screen is also cleared 



EXAMPLES: 

GRAPHIC 1,1 

GRAPHIC 4,0 



Selects hhres graphic mode and clears the screen. 
Selects multi-colour graphics with an area lor text, 
without clearing the screen 



121 



GRAPHIC CLR 



GRAPHIC CLR 



This is actually a lorm of the GRAPHIC statement; instead of specifying 
a mode to use graphics, this statement clears the 10* of memory 
allocated to the graphic area, and that memory space becomes 
available for BASIC once again 



IF . . . THEN . . :ELSE 

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

IF THEN lets the computer analyze a BASIC expression preceded 
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 
be any BASIC statement. If the expression is false, the program goes 
directly to the next line, unless an ELSE clause is present. The 
expression being evaluated may be a variable or formula. In which case 
It is considered true if nonzero, and false if zero. In most cases, there Is 
an expression involving relational operators (• , <, >, <«, >-. <>, 
AND. OR. NOT). 



The ELSE clause. It present, must be In the same line as the IF-THEN 
pan When an ELSE clause is present. It is executed when the THEN 
clause isn't executed. In other words, the ELSE clause executes when 
the IF expression is FALSE 



1^1 



i 

i i 

[ ( 

[ ! 

( ( 

[ I 

I I 

[ ( 



I 



I 





No \ 


■ 1 
OK 


Cneck 
■ 0? 




E w 


End 





I 

I 

I 
I 
I 



I I 

! I 



I 

i I 
I 

: I 
I ( 



EXAMPLE 

50 IF X>0 THEN PRINT"OK": 

ELSE END 



Checks the value ol X. II X Is 
greater lhan 0, the THEN clause 
is executed, and the ELSE clause 
isn't. If X is not greater than 0. 
the ELSE clause is executed and 
the THEN clause Isn't. 



INPUT 



INPUT ["prompt string".] variable list 

The INPUT statement allows the compute' to ask for data from the 
person running the program and place II into a variable or variables. 
The program stops, prints a Question mark (?) on the screen, and wails 
for the person to type Hie answer and press the BETUHN key 



The word INPUT is followed by a variable name or list of variable 
names separated by commas. There may be a message Inside 
quotes before the list of variables lo be input. If this message (called a 
prompt) is present, there must be a semicolon (,) after the closing quote 
of the prompt. When more than one variable is to be INPUT. Ihey 
should be separated by commas when typed In If not. the computer 
asks for the remaining values by printing two question marks {??) II 
yoj press the BETurn key witnout INPUTting values, the INPUT 
variables retain the values previously held for those variables This 
statement can only be executed within a program. 

EXAMPLE: 

10 INPUT "WHAT'S YOUR NAME";At 

20 INPUT "AND YOUR FAVORITE COLOR"; B$ 

30 INPUT "WHAT'S THE AIR SPEED OF A SWALLOW";A 



122 



[ f 



123 



INPUT 



INPUT* life number, variable lis! 

This works tike INPUT, but lakes (he data from a previously OPENed 
file or device. No prompt string is allowed This command can only be 
used in program mode 



EXAMPLE: 



INPUTS, AS, C, D$ 



LET 



[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 
The variable name which is to get the result of a calculation is on the 
left side of the equal sign, and the number or formula is on the right 
side. 

EXAMPLE: 
10 LET A = 5 



20 B = 6 



30 C ■» A • B + 3 



40 DJ - "HELLO- 



LET is implied (but not necessary) 
in lines 20, 30 and 40. 



i ' 
i ' 

i r 

i ( 



t 



i 



! 



I 



( 
I 

I 

' 
I 
I 
I 

f 



f r 
( 
i 
I 
i 

! I 

I ' I 

I 



LOCATE 



LOCATE x-coordlnate, y-coordlnate 

The LOCATE command lets you put the pixel cursor (PC) anywhere on 
the screen. The PC is the current location of the starting point ot the 
next drawing. Unlike the regular cursor, you can't see the PC. but you 
can move II with the LOCATE command. For example. 

LOCATE 160. 100 

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 
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 
the dot at the PC can be found by PRINTing PDOT(2). (In all drawing 
commands where a colour option Is available, you may select a value 
from to 3. corresponding to Ihe background, foreground, multicolour 
1 , or multicolour 2 as the colour source.) 



MONITOR 

MONITOR 

This command takes you out of BASIC Into the built-in machine 
language monitor program The monitor is used to develop, debug, 
and execute machine language programs more easily than from BASIC. 
See the section on monitor commands for more Information (When In 
the monitor, typing an 'X' and pressing arrufiN gets you back to 
BASIC.) 



NEXT 



NEXT [variable. . . . ,vanable| 



124 



I f 



125 



The NEXT slalemeni Is used with ihe FOR statement. When the 
computer encouniers a NEXT statement, it goes back to the 
corresponding FOR statement and checks the loop variable (See FOR 
statement tor more detail.) It the loop is finished, execution proceeds 
with the statement after the NEXT statement. The word NEXT may be 
followed by a variable name, a list ot variable names separated by 
commas, or no variable names. It there are no names listed, the last 
loop started is me one being completed H the variables are given, they 
are completed In order trom left to right 



EXAMPLE: 

10 FOR L « 
20 FOH L < 
30 FOR L 



1 TO 10:NEXT 

1 TO 10:NEXT L 

1 TO 10:FOR M = 1 TO 10: NEXT M, L 



ON 



ON expression <GOTO/GOSUB> line #1 [. line #2, 



This command can make the GOTO and GOSUB statements mlo 
special versions ol the IF statement The word ON is followed by a 
formula, then either GOTO or GOSUB. and a list ol line numbers 
separatee by commas. If the result ol the calculation of the formula 
(expression) ts 1 . the first line in the list is executed. II Ihe result is 2. 
the second line number is executed, and so on. If the result is 0. or 
larger than the number of line numbers in the list, the next line executed 
is tne statement following the ON statements II Ihe number is negative, 
an ILLEGAL QUANTITY ERROR results 



l ; 

f . 



I 

f 

f ! 

I 
I 
I 
I 

I 

I 

I 

I 



( 
I 

r 

f 



^26 



i r 



EXAMPLE: 



10 INPUT X:IF X<0 THEN 10 

20 ON X GOTO 50, 30, 30, 70 

25 PRINT "FELL THROUGH":GOTO 10 

30 PRINT "TOO HIGH":GOTO 10 

50 PRINT'TOO LOW'rGOTO 10 

70 END 



When X = 1 . ON 
sends control to the 
lirsl line number in the 
lisl (50) When X - 2. 
ON sends control to 
the second line (30), 
etc. 



OPEN 

OPEN Me [.device # (.secondary address f. "filename, type, mode"]|l 

The OPEN statement allows your Commodore 16 lo access devices 
such as the Datassette recorder and disk for data, a primer or even the 
monitor screen The word OPEN is followed by a logical file number, 
which is the number to which all other BASIC statements will refer This 
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 
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 
your Commodore 1 6 is concerned). It Is often a good Idea lo use the 
same file number as the device number because it makes it easy to 
remember which Is which. Following the second number may be a 
third number called the secondary address. In the case ol tne cassette, 
this can be fo' read. 1 lor write, ana 2 lor write with end-of-lape 
marker at Ihe end. In the case of the disk, Ihe number refers to the 
channel number. In the printer, the secondary addresses are used to 
set Ihe mode of the printer See the Commodore 1 6 Programmer's 
Reference Manual or the manual lor each specific device for more 
information on secondary addresses There may also be a string 
following the third number, which could be a command to the disk 
drive or the name ol the file on tape or disk. The type and mode refer 



127 



to disk dies only. (File types are prg.seq, rel, and usr; modes are 
read and write.) 



EXAMPLES: 
10 OPEN 3,3 

10 OPEN 1,0 



20 OPEN 1,1,0,"UP" 

OPEN 4,4 
OPEN 15,8.15 



OPENS the SCREEN as 
device. 



OPENs the keyboard as 
device. 



OPENs the cassette tor 
reading, tile to be searched 
lor is named UP 



OPENs a channel to use the 
printer. 

OPENs trie command 
channel on the disk 



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

tor writing. 

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



PAINT 



PAINT [colour source] [,[a,bl (.model | 

Colour source (0-3); (default is l , foreground colour) 

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



i 
r 



I 



f 
f 
l 

f 
I 

i 
i 
i 
I 

i 
i 

! 
I 
I 
! 
( 
I 

r 



12B 



f ' f 



mode. 



.0 = paint an area detmed by the colour source 

selected 

1 - paint an area defined by any non-background 

source 



The PAINT command lets you fill an area with colour It tills m the area 
around the specified point until a boundary ot the same colour (or any 
non-background colour, depending on which mode you have chosen) Is 
encountered The final position of the PC will be at the starting point 
<a ( b). 



NOTE: If the starting point is already the colour ot colour source you 
name (or any non-background when mode t is used), there is no 
change 



EXAMPLE: 

10 CIRCLE, 160.100.6S.50 
20 PAINT , 160,100 



draws outline of circle 
in the circle with colour 



POKE 



POKE address, value 

The POKE command allows you to change any value In the 
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 
computer's memory. This could have any value Irom to 65535 The 
second number is a value from to 255, which is placed tn the locat<on, 
replacing any value that was there previously This command can be 
used to control anything on the screen, from placing a character at that 
location to changing the colour there. 

EXAMPLE: 



10 POKE 16000,8 



Sets location 16000 to 8 



129 



20 POKE 16*1000,27 Jelt. ocation I6000to27 

Nole; PEEK, a function related lo POKE, ts listed under FUNCTIONS. 



PRINT 



PRINT printilst 



The PRINT statement is the major output statement In BASIC. While 
the PRINT statement is the lirst BASIC statement most people learn to 
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 



Characters inside of quotes 
Variable names 
Functions 
Punctuation marks 



{"text lines") 
(A. B. A$, X$> 
<SIN<23), ABS(33)) 



Tne characters inside ol quotes are often called literals because they 
are printed exactly as they appear. Variable names have the value they 
contain (either a number or a string) pnnted Functions also nave their 
number values primed. Punctuation marks are used lo help format the 
data neatly on the screen The comma divides the screen into 4 
columns for data, while the semicolon doesn't add any spaces. Either 
mark can be used as the last symbol in the statement. This results in 
the next PRINT statement acting as if it is continuing the last PRINT 
statement. 



EXAMPLE: 



RESULT 



10 PRINT "HELLO" 

20 A$-"THERE":PR1NT "HELLO/AS 

30A=4:B = 2:PRtNTA+B 

50 J = 41:PRINT I;:PRINT 1-1 

60 C«A+B;D=A-B:PRINT A;B;C,D 

See also: POS( ), SPC( j andTAB( (FUNCTIONS 



HELLO 
HELLO.TMERE 

6 

41 40 

4 2 6 2 



130 



r 



f 



i 



PRINT 

PRINT* file*, print list 

There are a few differences between this statement and the PRINT. 
First of all. Ihe word PRINT# is followed by a number, which rotors to 
the device or data file previously OPENed. The number is followed by 
a comma, and a list of things to be PRINTed. The semicolon acts In the 
same manner for spacing as it does in the PRINT staiemenl The 
comma will send 1 spaces to most printers and can be used as a 
separator for disk files (see the Programmer's Reference Guide and ihe 
Disk Drive Manuai). Some devices may not work with TAB and SPC. 

EXAMPLE 

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



PRINT USING 



PRINT i^filenumber.] USING formal list, prml list 

These statements let you define the format of string and numeric Items 
you want to print to the screen, pnnter, or another device. Put the 
format you want in quotes This is the format list. Then add a 
semicolon ana a list of what you want printed in the format lor the print 
list The list can be variables or the actual values you want printed. For 
example: 



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

10 PRINT USING "S##.##";13.2S,X,Y 

20 PRINT USING "##i*>#";"CBM",A$ 



When you RUN this, line 10 prints out: 
$13 25532.00 $••••• 



prints •••♦♦ instead of Y 
value because Y has 5 
digits, which does not 
conform to tormat list (as 
explained below) 



131 



Line 20 prints this: 



CBM CAT 



CHARACTER 



leaves three spaces before printing "CBM" as 
defined in format list 



Hasn Sign (#) 
Plus(+) 
Minus {-) 
Decimal Point f.) 
Comma (.) 
Dollar Sign ($) 
Four Carets (TTTt) 
Equal Sign (*=) 
Greater Than Sign <>) 



NUMERIC STRING 

X X 

X 

X 

X 

X 

X 

X 

X 
X 



The hash sign (0) reserves room lor a single cha.'acter In the output 
field. If the data item contains more characters lhan you have in your 
format field, the following occurs: 



For a numeric Hem. the entire field is filled with asterisks <■). No 
numbers are printed. 



For example: 

10 PRINT USING "0000")% 

For these values for X, this format displays: 
A -12.34 12 

A = 567.89 568 

A -123456 ••** 

For a STRING item, the string data Is truncated at the bounds ol the 
field. Only as many characters are printed as there are hash signs (#) in 
the format item. Truncation occurs on the right 

The plus f +) and minus (-) signs can be used in either the first or last 
position of a format field but nol boih. The plus sign is printed if the 
number is positive. The minus sign is printed If the number is negative. 



132 



[ 

I 
I 
I 

f 
[ 

I 
f 

I 

f 

f 

r 
[ 



I 



i 
i 
f 
f 



i 
f 

i 



if you use a minus sign and the number is positive, a blank is printed in 
the character position indicated by the minus sign 

If you don't use either a plus or minus sign In your formal field for a 
numeric data Item, a minus sign is printed before the first digit or dollar 
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 
number is positive. II (here are too many digits to fit into the field 
specified by the # and + / - signs, then an overflow occurs and the field 
is filled with asterisks (•). 

A decimal point f ) symbol designates the position of the decimal point 
in the number You can only have one decimal point in any format 
field. If you don't specify a decimal point In your format field, the value 
is rounded to the nearest integer and primed without any decimal 
places. 

When you specify a decimal point, the number of digits preceding Ihe 
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 
many digits an overflow occurs and the field is filled with asterisks {*). 

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 
printed number Only commas within a number are printed. Unused 
commas !o the left of the first digit appear as the filter character. At 
least one must precede the first comma in a field. 

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 
is specified as a comma. 



EXAMPLES: 

FIELD EXPRESSION 



RESULT COMMENT 



##.# + 
00.0 ■ 
0000 

0000 



-.01 

1 
-100.5 

-1000 



0.01- 
1.0 
-101 



Leading zero added. 

Trailing zero added. 

Rounded to no decimal 

places. 

Overflow because four digits 

and minus sign cannol fil in 

field. 



133 



##*. 

#%#* 



10 

1 



1 Decimal point added. 

SI Leadings sign 



A dollar sign (S) symbol shows that a dollar sign will be printed m Ihe 
number If you wani the dollar sign to float (always be placed before trie 
number), you mus! specify at least one # before Ihe dollar sign If you 
specify a dollar sign without a leading 0, the dollar sign is printed in the 
position shown in the format fietd. 

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 



The lour up arrows or carels (tnt) symbol Is used to specify mat the 
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 

You must specify four carels (tTTT) when you want to print a number in 
E -fo'mat (scientific notation) If you specify more than one but fewer 
lhan four carets, you get a syntax error. If you specify more than four 
carels only the first four are used The llfth caret (and subsequent 
carets) are interpreted literally as no text symbols 

An equal sign (») is used 1o centre a string in the field. You specify the 
field width 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. 

A greater than sign ( > ) is used to right justify a string in a field. You 
specify the field width by the number of characters (# and =) In the 
format field. If the string contains fewer characters than the field width, 
the string is right justified in the field. If the string contains more 
characters than can be lit into the field, the right-most characters are 
truncated and the string tills the entire field 



PUDEF 

PUDEF "1 through 4 characters" 



I .VI 






! 



PUDEF lets you redefine up to 4 symbols in the PRINT USING 
statement. You can change blanks, commas, decimals points, and 
dollar signs into some other character by placing Ihe new character In 
the correct position in the PUDEF control string. 

Position 1 is the filler character. The default is a blank Place a new 
character here when you want another character lo appear in place of 
blanks. 

Position 2 is Ihe comma character. Default is a comma 
Position 3 is the decimal point 
Position A is the dollar sign. 



EXAMPLES 

10 PUDEF " p- 
20 PUDEF "'&" 
30 PUDEF" ," 



40 PUDEF "T.E* 




ispace PRlNTs " in the place of blanks. 
PRINTS & in place of commas. 

space PRINTS decimal points in place ol 
commas, and commas in place of 
decimal points 
PRlNTs English pound sign in place of $, 
decimal points in place of commas, and 
commas in place of decimal points. 



READ 

READ variable list 

This statement is used to get information from DATA statements into 
variables, where the data can be used. The READ statement vaiiabte 
list may contain both strings and numbers. Care must be taken to avoid 
reading strings where the READ statement expects a number, which 
produces an ERROR message 

EXAMPLE: 
READ AS, GS, Y 



135 



REM 



REM message 

The REMark is jus! a nolo (o whoever Is reading a LIST ol Ihe program 
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. 



EXAMPLE 



10 NEXT X: REM THIS LINE IS UNNECESSARY 



RESTORE 



RESTORE [line #] 

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 
This gives you the ability to re-READ the information II a pine #] 
follows the RESTORE statement, the pointer is sat to that line 
Otherwise the pointer Is reset lo the first DATA statement In Ihe 
program. 



EXAMPLE: 
RESTORE 200 



RESUME 

RESUME [line* | NEXT) 



136 



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 
following the slatement containing the error; RESUME line will GOTO 
the specific Ime and begin execution the/e. 



RETURN 



RETURN 

This statement is always used with the GOSUB statement Whan Ihe 
program encounters a RETURN statement, II goes to trie statement 
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 



SCALE 

SCALE <l/0> 

The scaling of Ihe bit maps in multicolour and high resolution modes 
can be changed with Ihe SCALE command. Entering: 

SCALE 1 



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 9 to 1 99 

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



137 



SCNCLR 

SCNCLH 

Clears the current screen, whether graphics, text, or both (split screen). 



SOUND 

SOUND voice #, frequency control, duration 

This statement produces a SOUND using one at three voices with a 
frequency control in the range 0-1023 lor a duration ot - 65535 60ths 
oi a second 



Voice 



1 
2 
3 



Voice 1 (tone) 
Voice 2 (tone) 
Voice 2 (white noise) 



It a SOUND (or voice N is requested, and the previous SOUND tor the 
same N is still playing. BASIC watts for the previous SOUND lo 
oomplete. SOUND with a duration of is a special case. It causes 
BASIC to turn oft the current SOUND for that voice immediately, 
regardless of the time remaining on the previous SOUND See the 
MUSIC NOTE TABLE In the appendix for the frequency control values 
that correspond to real notes 



EXAMPLE: 

SOUND 2, 800, 3600 



Plays a note using voice 2 with 
frequency set at 800 for one 
minute 



138 



I 



SSHAPE/GSHAPE 



SSHAPE and GSHAPE are used to save and restore rectangular areas 
of multicolour or high resolution screens using BASIC string variables. 
The command lo save an area Is; 



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



stnng variable 
a1.bl ... 
a2,b2 .... 



.Siring name to save data In 
. .Corner coordinate (scaled) 
. .Corner coordinate opposite (at ,bl ) (default «s the 

PC) 



Because BASIC limits siring lengths to 255 characters, the size of the 
area you may save is limited. The string size required can be 
calculatea using one of (he following (unsealed) formulas: 

L<mcm) - INT( (ABS(a1-a2) + 1) I 4 + 99) • <ABS(b1-b2> + 1) + 4 
Uh-0 - INT((ABS<ai-a2) + 1J/8+ .99) • (ABS(b1-b2> + 1) + 4 
(mem) refers lo multi-colour mode; (h-r) Is high tesolulion 

The shape is saved row by row. The last four bytes ol the string 
contain the column and row lengths less one (I.e.: A8S (a1-a2) ) in low/ 
high byte format (if scaled divide the lengths by 3.2 (X) and 5.1 2 (Y) ). 

The command lo display a saved shape on any area of the screen 

GSHAPE string variable name [. la.b] [.mode] J 

string . . Contains shape to be drawn 

a.b . .Top let! coordinate telling where to draw the shape 

(scaled - the default is the PC) 
mode Replacement mode: 

0. place shape as is (default) 

1 : place field Inverted shape 

2; OR shape with area 

3; AND shape with area 

4: XOH shape with area 



( 



139 



EXAMPLES: 



SSHAPE "VARIABLES", 0, 









GSHAPE "VARIABLES".,,! 



Saves screen area from me upper 
left corner lo where me cursor is 
positioned under me name 
VARIABLES. 



Displays VARIABLES shape with 
background and foreground colours 
reversed, with me loo left ol me 
snope positioned at the cursor 



STOP 



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 It you use the CONT 
command. The STOP statement is usually used while debugging a 
pfogram. 



SYS 



SYS address 

The word SYS is followed by a decimal number or numeric variable m 
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 
Programmer's Reference Guide tor information about machine 
language programs. 



140 









TRAP 



TRAP (lineal 

When turned on TRAP intercepts all error conditions (including Ihe 
ntm/STOP key) except "UNDEF'D STATEMENT ERROR" Intneeveni 
of any execution error, tne error flag is set, and execution is transferred 
lo the line number named in the TRAP statement. The line number in 
which Ihe error occurred can be tound by using me system variable EL. 
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 
statement can be used lo resume execution. TRAP with no line* 
argument turns oft error TRAPping. 



TRON 



TRON 



TRON is used in program debugging This statement begins trace 
mode When you are in trace mode, as each statement executes, the 
line number of Ihat stalement is printed 



TRQFF 



TROFF 



This statement turns trace mode off. 



141 



VOL 



VOL volume level 

Seis Ibe current VOLume level (or SOUND commands. VOLume may 
be set from to 8, where 8 is maximum volume, and is off. VOL 
aff eels both voices 



WAIT 

WAIT address, value 1 (. value 2] 

The WAIT statement is used to halt the program until the contents ol a 
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. 

The content of the memory location is first exclusive-ORed with value 2 
(if present), and Ihen logically ANDed with value 1 It the result is zero, 
the program checks the memory location again When the result is not 
zero, the program continues with the next statement. 



Additional Graphic Statement Information 

There are a few concepts that apply to ail ol the bit map graphics 
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 
commands use Ihe PC In addition, the locate command allows you to 
reposition Ihe PC without drawing anything 



Wherever you would use X, V coordinates in a drawing command, you 
can use RELATIVE coordinates instead. Relative coordinates are based 
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 
moves the PC to Ihe right A minus sign before the X value moves the 
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: 



142 



I 






I 
f 
( 

( 
I 
( 
f 

I 

! 
f 



LOCATE +100,-23 



moves the PC right 1 00 pixels and up 
25 



DRA Wl , + 10, + 10TO100, 100 draws a line 1 pixels right and 1 

pixels below Ihe current value of Ihe 
PC to the absolute point 100.100 

You can also specify a distance and and angle relative to the current 
PC by separating the two parameters by a semicolon 



For example: 
LOCATE 50;45 



moves the PC from its current location 
by a distance of 50 dots at an angle of 
45 degrees. 



FUNCTIONS 

Numeric Functions 

Numeric functions are classified as such because Ihey return numbers. 
The functions they perform range from calculating matnematical 
functions lo specifying a screen location Numeric functions follow the 
form. 

FUNCTION (argument) 

where the argument can be a numerical value, variable, or string 



ABS(X) (absolute value) 

The absolute value function returns the magnitude of the argument X. 

ASC(X$> 

This function returns the ASCII code (number) of the first character of 
X$. 



I 



143 



ATN(X) (arclangeni) 



Returns the angle whose tangent is X. measured in radians. 



COS(X) (cosine) 

Returns the value of the cosine ol X, where X is an angle measured In 
radians. 



DEC (he*adecima>-string) 

Returns decimal value of hexadecimal-string (0< nexadeclmal- 
slrlng<FFFF) 

EXAMPLE: 
N=DEC("F4") 



EXP(X) 

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



FNxx(x) 

Returns Ihe value ol Ihe user-delined lunction xx created In a DEF FNxx 
statement 



144 



I 
I 



I 



I 
I 

I 
f 



( 






INSTB (string 1 . string 2 [.starting-position]) 

Returns position of string 2 in string 1 ai or after Ihe (starting-position] 
The starting-position defaults lo the beginning of string 2 If no match is 
found, a value of is returned 



EXAMPLE: 



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



Ihe result is 5, because CAT starts at the fifth cnaracter in string 



INT(X) (integer) 

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



If the INT function Is to be used lor rounding off, Ihe form is INT(X + .5) 
or INT(X - .5). 

EXAMPLE; 



X = INT(X-100 + .5J/10O 



Rounds to the next highest penny 



JOY <n) 



When n - 1 Position of joystick #1 

2.. - - Position ofioystick #2 



n 



Any value of 1 28 or more means Ihe fire button is also depressed. The 
direction is indicated as loPows - . 



I «S 



fire= 128 + 
LEFT 7 



UP 
I 



8 
6 



3 RIGHT 



5 
DOWN 



EXAMPLE: 



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



LOG(X) (logarithm) 

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 1 0, divide by LOGO 0). 



PEEK(X) 

This (unction gives tne contents ol memory location X, where X is 
located in the range ol to 65535, returning a result from to 255. This 
is often used in conjunction with the POKE statement. 



RCLR(N) 

Returns current colour assigned to source N (0 = < N = < 4) 

(0-background, 1 -foreground. 2=multicolour 1, 3=multicolout 2. 
4= border) 



RDOT(N) 

Returns Information about the current position of the pixel cursor (PC) at 
XPOS/YPOS. 



i 46 



[ 
I 

I 



r 



( 
I 
I 
I 
I 
I 
I 



1 ,11 

I I 

I I 



N-OtorXPOS 

1 for YPOS 

2 colour source 



RGB(X) 

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



RLUM(N) 

Returns current luminance level assigned to colour source N 



I 


i 


[ 


( 


I I 


I 1 


1 1 


1 t 


1 1 


i r 


i 


i 



RND(X) (random number) 

Thi6 function returns a random number between and 1 . This is useful 
in games, to simulate dice roils and other elements of chance, and is 
also used ir some statistical applications. The first random number 
should be generated by the formula RND(-TI), to stan things off 
differently every time. After this, the number In X should be a 1 . or any 
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 
every time RND is used. A negative value lor X seeds the random 
number generator using X and gives a random number sequence. The 
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 
based on the previous seed. 



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 
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 
the decimal places, leaving the result as a oigit from 1 to 6 

To simulate 2 dice, add two of the numbers oblained by the above 
lormula together 



1 47 



EXAMPLE. 

100X=lNT(RND(l)-6)+INT(RND(l)*6)+2 
100 X = rNT(RND(l)'1000)+l 
100X+INT(RND<1)*150) + 100 



Simuiales 2 dice. 
Number from 1 -1 000. 
Number from 100-249. 



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 



SW<X) {sine) 

This Is the trigonometric sine tunction. The result is the sine of X. 
where X is an angle In radians, 



SQR(X) (square root) 

This function returns the square root of X, where X is a positive 
number or It X is negalive. an ILLEGAL QUANTITY ERROR results. 



TAN(X) (tangent) 



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



US 






f 
' 
I 
I 
I 

! 
I 
I 
I 
I 
f 



f 



USR(X) 

When this function is used, the program lumps to a machine language 
program whose starting point is contained in memory locations 1281 
and 1 282 The parameter X Is passed to the machine language 
program in ihe floating point accumulator. Another numoer is passed 
back to the BASIC program through the calling variable. In other 
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 



VAL<XS) 

This function converts Ihe string X$ Into a number, and Is essentially 
the inverse operation trom STRS The string is examined from Ihe left- 
most character lo Ihe right, tor as many characters as are In recognizable 
number format. If the Commodore 16 lirvds illegal characters, only the 
portion ol the siring up to that point Is converted 



EXAMPLE: 



10X«VAL("123.4S6") 



10X=VAL("3E03") 



10X*VAL{"12A13B") 



10X = VALTRIUO17-") 



10X-VALT-1.23.23.23") 



X-123.456 
X=3000 
X-12 
X=0 
X— 1 .23 



149 



String Functions 

String luncnons differ from numeric functions in thai Ihey return 
characters, graphics or numbers from a stnng (defined by quotation 
marks) instead of a number. 



CHR$(X) 



This function returns a string character whose ASCII code is X. 



ERR$(N) 



Returns string describing error condifion N (see TRAP) 



HEXJ(N) 

Returns a 4 character string containing the hexadecimal representation 
of value N (0 < N < 65535) 



LEFT$(X$,X) 



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



LEN(X$) 



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



1 50 



I 



I 
I 
I 
I 
I 
[ 
f 
I 
I 
f 






MIDS(X$,N,X) 

This returns a string containing X characters, starting from the Nth 
character in XS. MIDS can also be used on the left side of assignment 
statement as a pseudo-variable as well as a function. MIDS {string 
variable, starting position, length) = source siring. 



This function reassigns values of positions (starting position) through 
(starling position + length) of source string to the characters of string 
variable in corresponding locations. Length defaults to the length of 
string variables, and an error results If (starting position + length) is 
greater than the length of the source string. 



EXAMPLE 



10 A$-"THE LAST GOODBYE": 

20 PRINT AS 

30 MIDS(AJ,6,3>="ONG" 

40 PRINT AS 



RIGHTS(XS,X) 



This returns the right-most X characlers In XS 



STR${X) 

This returns a string which is identical to the PRINTed version of XS. 
EXAMPLE 



AS=STR$(X) 



15i 



Other Functions 



FRF. (X) 



This function returns the number ot unused bytes available in memory, 
X is a Gummy argument. 



POS (X) 

This function returns the number of the column (0-39) where the next 
PRINT staiement begins on the screen X Is a dummy argument. 



SPC(X) 

This is used in the PRINT staiement to skip over X spaces. X can have 
a value trom 0-255 



TAB (X) 



This is used in the PRINT statement. The next item to be printed is in 
column number X. X can have a value from to 255. 



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



VARIABLES & OPERATORS 



Variables 



Your Commodore 16 uses three lypes ol variables in BASIC. These 
are: normal numeric, Integer numeric, and string (alphanumeric) 
variables. 



i 



i 
i 
l 



l 
■ 
( 
( 

I 
i 
I 
I 
I 
( 

[ 

! 
[ 



Normal NUMERIC VARIABLES, also called floating point variables. 

can have any value Irom 30 to * M , with up to nine digits of accuracy. 
When a number becomes larger than nine digits can show, as In 
10' ,0 or 10 *'° , your computer displays It In scientific notation form, 
wilh the number normalized to 1 digit and eighl decimal places, 
followed by the letter E and the power ot ten by which the number is 
multiplied. For example, the number 1 2345678901 is displayed as 
1.234356789E + 10. 



INTEGER VARIABLES can be used when the number Is trom +32767 
to -32768, and with no fractional portion An integer variable is a 
number like 5, 10, or -100. Integers take up less space than floating 
po«nt variables when used in an array. 



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

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 
traders, but only the first Iwo are significant 



An integer variable is specified by using the percent f %) sign after the 
variable name. String vanaoles have the dollar sign (S) after their 
names 



EXAMPLES: 

Numeric Variable Names: A. A5, BZ 
Integer Variable Names: A%. A5%. BZ% 
String Variable Names: AS A5S. BZ$ 



ARRAYS are lists ot variables with the same name, using an extra 
number (or numrjets) to specify an element ot tne array. Arrays are 
defined using the DIM statement, and may be floating point, integer, or 
string variables arrays. The array variable name <s followed by a set of 
parentheses ( } enclosing the number of the variable in the list 



I I 



153 



EXAMPLES: A(7).BZ%<1 1),AS(87) 

Arrays may have mote lhan one dimension. A two dimensional array 
may be viewed as having rows and columns, with the first number 
Identltylng the column and the second number in the parentheses 
Identifying the row {as it specifying a certain grid on a map) 

EXAMPLES: A(7.2) BZ%(2.3,4)7S<3.2) 



RESERVED VARIABLE NAMES 

There are seven variable names which are reserved for use by the 
Commodore '6. and may not be used for another purpose. These are 
the variables DS, DSS. ER, EL. ST.TI, and TIS. You also can'i use 
KEYWORDS such as TO and IF, or any names that contain 
KEYWORDS, such as SRUN. RNEW, or XLOAD as variable names. 



ST is a status variable lor Input and output (except normal screen/ 
keyboard operations). The value of ST depends on the results of the 
last input/output operation. A more detailed explanation of ST is In the 
Series 264 Programmer's Reference Guide, bul in general, if the value 
of ST is the operation was sucessful 



Tl and Tis are variables that relate to the real-time clock built Into your 
Commodore 1 6 The system clock <s updated every I /60th of a 
secooa It starts at when your Commodore 1 6 Is turned on and is 
reset only by changing (he value of Tl$. The variable Tl gives you the 
current value of the clock in 1 /6Qlhs of a second. 



TIS is a string that reads the value of the real-time clock as a 24 hour 
clock The first two characters of TIS contain the hour, the 3rd and 4th 
characters are the minutes, and the 5th and 6th characters are the 
seconds. This variable can be set to any value (so long as all characters 
are numbers), and will be automatically updated as a 24 hour clock 



EXAMPLE: TIS = "101530" sets the dock to 10 1 5 and 30 seconds 
(AM) 

The value of the clock is lost wnen your Commodore 16 is turned off It 
slarts at zero when your computer is turned on, and is reset to zero 
when the value of the clock exceeds 235959 (23 hours. 59 minutes and 
59 seconds). 






1 


1 


1 


1 


1 




1 


1 


1 


1 


1 1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


! 



( I 



f 


1 


1 


( 


I 


I 


1 


!< 


1 


1 


I 


' 


1 


1 


I 


1 


1 


f 



The variable DS reads the disk drive command channel, and returns the 
current status of the drive. To gel this Information In words. PRINT 
DSS. These status variables are used after a disk operation, like a 
DLOAD or DSAVE. to find out why the red error light on the disk drive 
is blinking. 

ER, EL. and ERRS are variables used in error trapping routines. They 
are usually only useful within a program ER returns the last error 
encountered since the program was RUN. EL is the line where the error 
occured. ERRS is a function which allows your program to prinl one of 
the BASIC error messages. PRINT ERRS(ER) prints out the proper error 
message. 

BASIC OPERATORS 

Tne ARITHMETIC operators include the following signs 



+ addition 

- subtraction 

* mu Implication 

/ division 

T raising to a power (exponentiation) 

On a line containing more lhan one operator, there is a set order in 
which operations always occur. If several operators are used together, 
the computer assigns priorities as follows; First, exponentiation. Ihen 
multiplication and division, and last, addition and subtraction If two 
operations have the same priority, then calculations are performed in 
order from left to right. If you want Ihese operations to occur In a 
different order, Commodore 16 BASIC allows you to give a calculation 
a higher priority by placing parentheses around it. Operations enclosed 
in parentheses will be calculated before any other operation. You have 
to make sure that your equations have the same number of left 
parentheses as right parentheses, or you will gel a SYNTAX ERROR 
message when your program is njn. 

There are also operators for equalities and inequalities, called 
RELATIONAL operators Arithmetic operators always take priority over 
relational operators. 



■ 


is equal to 


< 


is less than 


> 


is greater than 


<= or < 


= < Is less than or equal to 



155 



> = o, = > | S greater lhan or equal to 
<> or >< is noi equal lo 

Finally, there are three LOGICAL operators, with lower priority than 
both arithmetic and relational operators; 

AND 

OR 

NOT 



These are used most often lo Join multiple tormulas in IF . . . THEN 
statements. When they are used with arithmetic operators, they are 
evaluated last {i.e , after + and -) 



EXAMPLES; 
IFA=BANDC=DTHEN100 

IF A = B OR C=D THEN 100 

A-S:B-4:PRrNTA=B 
A-9:B«4:PRINTA>B 
PRINT 123 AND 15:PRINT 5 OR 7 



requires both A-B & C-D to be 
true 

allows either A = B or C-D to be 
true 

displays a value ot 

displays a value ot -1 

displays 11 and? 



i 



l 



BASIC Abbreviation and Reference Chart 



I 



i SB 



: ' 



KEYWORD 


'.V-i.f ./|.^ ON 


TYPE 




ABS 


a 


SHIFT 


6 


tunction— numeric 




ASC 


a 


SHIFT 


s 


function— numeric 




ATN 


3 


SHIFT 


T 


luncllon— numeric 




AUTO 


a 


SHUT 


U 


command 




BACKUP 


b 


SHUT 


A 


command 




BOX 


b 


SHIFT 





statement 




CHAR 


ch 


SHIFT 


A 


statement 




CHR$ 


c 


SHIFT 


H 


lunctton— string 




CIRCLE 


c 


SHIFT 


1 


statement 




CLOSE 


cl 


SHIFT 





statement 




CLR 


c 


SHIFT 


L 


statement 




CMD 


c 


SHIFT 


M 


statement 




COLLECT 


col 


SHIFT 


L 


command 




COLOR 


CO 


SHIFT 


L 


statement 




CONT 


c 


SHIFT 





command 




COPY 


CO 


SHIFT 


P 


command 




COS 




none 




(unction— numeric 




DATA 


d 


SHIFT 


A 


statement 




DEC 




f Or e 




function— numeric 




DEFFN 


d 


SOTT 


E 


statement 




DELETE 


de 


SHIFT 


L 


command 




DIM 


d 


SHIFT 


1 


statement 




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 

•. j«_ p. 


e 


SHIFT 


X 


(unction- numeric 




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 




157 



KEYWORD 



ABBREVIATION 



IYPC 



GSHAPE 


g 


wttn 


S 


statement 


HEADER 


he 


SHIFT 


A 


command 


HEXS 


h 


SHOT 


E 


function— string 


IF.. GOTO 




none 




statement 


IF ..THEN ELSE 


none 




statement 


INPUT 




none 




statement 


INPUT* 


( 


wmrr 


N 


state mem 


INSTR 


in 


SHIFT 


S 


function— numeric 


INT 




none 




function— numeric 


JOY 


1 


SHIFT 





function— numeric 


KEY 


k 


SUFT 


E 


command 


LEFTS 


le 


SHOT 


F 


function— stnng 


LEN 




none 




funct'on--numeric 


LET 


1 


SHIFT 


E 


statement 


LIST 


1 


SHIFT 


1 


command 


LOAD 


I 


SHIFT 





command 


LOCATE 


to 


SHIFT 


c 


statement 


LOG 




none 




function— numeric 


LOOP 


lo 


SHIFT 





statement 


MID$ 


m 


SHIFT 


1 


function— string 


MONITOR 


m 


wan 





statement 


NEW 




none 




command 


NEXT 


n 


SHOT 


E 


statement 


ON...GOSUB on., go 


SHIFT 


s 


statement 


ON... GOTO on. .g 


SHUT 





statement 


OPEN 





SHITT 


P 


statement 


PAINT 


P 


SHIFT 


A 


statement 


PEEK 


P 


SHIFT 


E 


function — numeric 


POKE 


P 


SWFT 





statement 


POS 




none 




function— numeric 


PRINT 


? 






statement 


PRINT* 


P 


SHIFT 


R 


slatemenl 


PRINT USING 


?us 


SHIFT 


1 


statement 


PUDEF 


P 


SHIFT 


U 


statement 


RCLR 


* 

r 


SUFT 


C 


(unction— numeric 


RDOT 


r 


SHIFT 


D 


function —numeric 


READ 


r 


SHIFT 


E 


statement 


REM 




none 




statement 



I 



I 

I 



I I 

i : i 

i i 

i ,.|< 

i i 

i i 



1 58 



1 


1 


1 


1 


1 


1 


1 


1 


1 


1 


( 


1 


f 


I 


I 


1 


I 


1 


1 


1 


1 


1 


1 




( 


( 


1 


( 


1 


f 





KEVWOHU 


A.BBfiEViA 
re SHIFT 


uon 


TYPE 


RENAME 


N 


command 


RENUMBER 


ren 


■■FT 


U 


command 


RESTORE 


re 


SfflFT 


S 


statement 


RESUME 


res 


JHHFT 


U 


statement 


RETURN 


re 


SHUT 


T 


statemenl 


RGR 




SHIFT 


G 


function— numeric 


RIGHTS 




SHIFT 


1 


(unction— string 


RLUM 




SHIFT 


L 


(unction— numeric 


RND 




SHOT 


N 


function— numeric 


RUN 




SHFT 


U 


command 


SAVE 


s 


SUFT 


A 


command 


SCALE 


sc 


SHIFT 


A 


statemenl 


SCNCLR 


s 


SHIFT 


C 


statemem 


SCRATCH 


sc 


SHIFT 


R 


command 


SGN 


s 


SHWT 


G 


function— numeric 


SIN 


s 


SHIFT 


1 


function— numeric 


SOUND 


s 


SUFT 





statement 


SPC( 


s 


SJHFT 


P 


(unction— special 


SQR 


s 


SHIFT 





function— numeric 


SSHAPE 


s 


SHIFT 


s 


statement 


STatus 




none 




reserved— numeric variable 


STOP 


s 


SHIFT 


T 


statement 


STRS 


St 


SUFT 


R 


function— string 


SYS 


s 


SUFT 


Y 


statement 


TAB( 


1 


SHUT 


A 


(unction— special 


TAN 




none 




function— numeric 


Ti 




none 




reserved — numeric variable 


ris 




none 




reserved— string variable 


TRAP 


t 


SHIFT 


R 


statement 


TROFF 


(ro 


SHIFT 


F 


statemenl 


TRON 


tr 


SUFT 





statemenl 


UNTIL 


u 


SHIFT 


N 


statement 


USR 


u 


SHIFT 


S 


function —special 


VAL 




none 




function— numeric 


VERIFY 


V 


SHIFT 


E 


command 


VOL 


V 


SUFT 





statement 


WAIT 


w 


SHIFT 


A 


statement 


WHILE 


w 


SHIFT 


H 


statement 



1 S9 



I 



1 


r 


[ 




1 


( 


[ 


i 


1 


i 


1 


l 


1 


[ 


1 


i 


1 


i 


1 


( 


1 


( 


1 


( 


1 


i 


1 


r 


1 


( 


1 


( 


1 


( 


1 


f 


1 


( 


1 


l 


1 


( 


1 


i 



APPENDICES 



Error messages 



Disk error messages 



Deriving mathematical (unctions 



Musical note lable 



• Screen display and ASCII codes 



Book list 






160 



f ' 



161 



APPENDIX A 

Error Messages 

These error messages are printed by BASIC You can also PRINT 
Ihe messages through the use of the ERRS() lunclion. Ttie error 
number refers only to the number assigned to the error for use with 
mis function 



ERROR # ERROR NAME 



1 
2 

3 

4 
5 
6 



8 



10 



11 



162 



TOO MANY FILES 



FILE OPEN 



FILE NOT OPEN 



FILE NOT FOUND 



DEVICE NOT PRESENT 



NOT INPUT FILE 



NOT OUTPUT FILE 



MISSING FILE NAME 



ILLEGAL DEVICE 
NUMBER 

NEXT WITHOUT FOR 



SYNTAX 



There is a limit of 10 files 
OPEN at one lime 

An allempt was made to open 
a file using Ihe number ol an 
already open Tile. 

The file number specified In 
an I/O statement must be 
opened belo'e use 

No file wilh that name exisfs 
(disk) 

The required I'O device not 
available 

An attempt made to GET or 
INPUT data from a file thai 
was specified as output only 

An attempt made to send 
data to a file that was speci- 
fied as input only 

An OPEN, LOAD, or SAVE to 
Ihe dis* drive generally re 
os a filename. 

An attempt made to use a 
device improperly (SAVE to 
the screen, etc.) 

Either loops are nesled in- 
correctly, or there is a variable 
name in a NEXT slatement 
that doesn t correspond wilh 
one in a FOR 

A slatement is unrecogniza- 
ble by BASIC Thts could be 



F |t 








1 1 








1 

1 








because of missing or extra 
parenthesis, misspelled 
keyword, etc 


1 

1 i 


12 


RETURN WITHOUT 
GOSUB 


A RETURN slatement en- 
countered when no GOSUB 
statement was active 


1 
1 

1 


i 
i 


13 


OUT OF DATA 


A READ statement en- 
countered, without data 
left unREAD 


14 


ILLEGAL QUANTITY 


A number used as ihe 
argument of a lunction or 
statement is outside the 
allowable range 


1 1 

( [ 

1 ( 

1 ( 

1 I 


15 


OVERFLOW 


The result of a compu- 
lation is larger than the 
largest number allowed 
(1 70141 1833E+38) 


16 


OUT OF MEMORY 


Either there is no more room 
for program and program 
variables, or there are loo 
many DO, FOR, or GOSUB 
statements in effect 


1 [ 


17 


UNDEF'D STATEMENT 


A line number referenced 
doesn't exist in the program 


( f 
1 ( 


16 


BAD SUBSCRIPT 


The program tried to refer- 
ence an element of an array 
out ol the range specified by 
ihe DIM statement 


1 f 

f 1 
1 1 


19 


REDIM'D ARRAY 


An array can only be DIMen- 
stoned once. If an array is 
referenced before that array 
is DIMd. an automatic DIM (to 
10) is performed 


20 


DIVISION BY ZERO 


Division by zero is not allowed 


( f 
( f 


21 


ILLEGAL DIRECT 


INPUT or GET statements are 
only allowed within a program. 


I I 








I r 








f 


f 






163 



i K 



22 

23 

24 
25 

26 



32 

33 
34 

35 



TYPE MISMATCH 



STRING TOO LONG 



FILE DATA 

FORMULA TOO 
COMPLEX 



CANT CONTINUE 



27 


UNDEF'DFUNC 


28 


VERIFY 


29 


LOAD 


30 


BREAK 


31 


CAN'T RESUME 



LOOP NOT FOUND 



LOOP WITHOUT DO 



DIRECT MODE ONLY 



NO GRAPHICS AREA 



This occurs when a number 
is used in piace ot a siring or 
vice-versa 

A string can contain up to 255 
characters. 

Bad data read trom a tape liie. 

Simplify the expression 
(breaK inlo 2 pads or use 
(ewer parentheses) 

The CONT command does 
not work If the program was 
not RUN, there was an error, 
or a line has been edited. 

A user defined function refer- 
enced that was never defined. 

The program on tape or disk 
does not match the program 
in memory 

There was a problem loading . 
Try again 

The stop key was hit to half 
piogram execution 

A RESUME statement en- 
countered without TRAP 
statement in elfecl 

The program has encoun- 
tered a DO slatemenl and 
cannot find the correspond- 
ing LOOP 

I OOP encountered without a 
DO slatemenl active 

This command ts allowed 
only in direct mode, not from 
a program 

A command (DRAW, BOX. 
etc. ) to ceate graphics 
encountered befo'e the 



164 



! 




( 


1 


1 


1 


' 


1 


1 


1 


1 


1 


1 ' 


1 


1 


1 


1 


1 




1 


( 


1 


1 


1 


1 


I 


1 


1 


1 


1 


I 


( 


( 


' 


( 


1 


( 


1 


1 


1 


( 


l 


1 


( 


1 



36 



BAD DISK 



GRAPHIC command 
was executed 

An attempt failed to HEADER 
a diskette, because Ihe quick 
heaaer method {no ID) was 
attempted on an unformatted 
diskette. o r the diskette is bad. 






166 



APPENDIX B 

Disk Error Messages 

These error messages are relumed through the DS and DS$ 
reserved variables 



NOTE ; Error message numbers less lhan 20 should be ignored 
with the exception ol 01 , which gives inlormation about the num- 
ber of tiles scratched with the SCRATCH command 



20 



21 



22 



23 



24 



READ ERROR 

(block header not found) 



READ ERROR 

(no sync character) 



READ ERROR 

(data block not present) 



READ ERROR 

(checksum error 
.n data block) 



READ ERROR 

(byte decoding error) 



The disk controller is unable to lo- 
cate the header ol the requested 
data block Caused by an illegal 
sector number, or the header has 
been destroyed 

The disk controller is unable to 
detect a sync mark on the desired 
track Caused by misalignment of 
the read/writer head, no diskette 
is present, or unformatted or im- 
properly sealed diskette. Can 
also indicate a hardware failure 

The disk controller has been re- 
quested to read or verify a data 
block that was not property writ- 
ten This error message occurs 
In conjunction with the BLOCK 
commands and indicates an ille- 
gal track and/or sector request 

This error message indicates that 
Ihere is an error in one or more ol 
Ihe data byles The data has been 
read Into the DOS memory, but 
the checksum over the data is tn 
error This message may also in- 
dicate grounding problems. 

The data or header has been read 
into the DOS memory, but a hard 
ware error has been created due 
lo an invalid bit pattern in the data 



1 


! 


1 


r 


1 


r 


1 


i 


1 


i 


1 


i 


1 




1 ' 


)' 


1 


i 


1 


i 


1 


i 


1 


( 


! 


i 


( 


i 


1 


I 


1 


i 


1 


i 


1 


i 


1 




1 


r 


1 


i 


1 


I 


1 


f 


1 


i 



25 



26 



WRITE ERROR 

(write- verify error) 



WRITE PROTECT ON 



27 



READ ERROR 

(checksum error 
in header) 



28 



WRITE ERROR 

(long data block) 



29 



DISK ID MISMATCH 



30 



SYNTAX ERROR 

(general syntax) 



byte This message may also 
indicate grounding problems. 

This message is generated il the 
controller detects a mismatch 
between the written data and ihe 
data in the DOS memory 

This message is generated when 
Ihe controller has been requested 
to write a data block white the 
write protect switch is depressed 
Typically this is caused by using 
a diskette with a write protect 
lab over the notch 

The controller has delected an 
error in the header ol the re- 
quested daia block The block 
has not been read into the DOS 
memory This message may also 
indicate grounding problems 

The controller attempts to detect 
the sync mark ol the next header 
after wnting a datablock. If the 
sync mam does not appear within 
a pre -determined time. Ihe error 
message is generated The error 
is caused by a bad diskette formal 
(the data extends into the next 
block), or by hardware failure. 

This message is generated when 
Ihe controllei has been requested 
to access a diskette which has 
not been initialized. The message 
can also occur II a diskette has a 
bad header 

The DOS cannot interpret the 
command sent lo the command 
channel Typically, this is caused 



167 



31 

32 
33 

34 



.-" 



50 



51 



SYNTAX ERROR 

(invalid command) 

SYNTAX ERROR 

(Invalid command) 

SYNTAX ERROR 

(invalid die name) 

SYNTAX ERROR 

(no file given) 



SYNTAX ERROR 

(invalid command) 



by an illegal number ol 'tie names, 
oi patterns are illegally used For 
example, two file names may 
appear on the left side ol the 
COPY command 

The DOS does not recognize the 
command The command must 
start in Ihe first position. 

The command sent is longer than 
58 characters 

Pattern matching is invalidly used 
m the OPEN or SAVE command 

The file name was left oul of a 
command or Ihe DOS does not 
recognize il as such. Typically, 
a coion(;) has been left out of 
the command 

This error may result if the com- 
mand sent to command channel 
(secondary address 15) is unrec- 
ognized by the DOS 



RECORD NOT PRESENT Result of disk 'eading past the 

last record through INPUT*, or 
GET# commands This message 
will also occur after positioning to 
a record beyond end of file In a 
relative file II the intent is to ex- 
pand the file Dy adding Ihe new 
record (with a PRINT* com- 
mand), the error message may be 
ignored. INPUT or GET should not 
be attempted after this error is de- 
tected without first repositioning. 

OVERFLOW IN RECORD PRINT* statement exceeds 

record boundary. Informalion is 
truncated Since the carriage re- 



i 



: 



i| 



168 



I' 

f 

I 
( 

I 
( 
I 
f 
f 

I 



52 



60 



FILE TOO LARGE 



WRITE FILE OPEN 



61 



FILE NOT OPEN 



62 
63 



65 



FILE NOT FOUND 
FILE EXISTS 

FILE TYPE MISMATCH 
NO BLOCK 



turn which is senl as a record ter- 
minator is counted in the record 
size, this message will occur if the 
total characters m the record (in- 
cluding the final carriage return) 
exceeds ihe defined size. 

Record position within g relative 
file indicales that dish Overflow 
will result. 

This message is generaied 
when a write file lhat has not 
been closed is being opened 
for reading 

This message is generated wn en 
a file is being accesseq that has 
nol been opened in the DOS. 
Sometimes, in this casft. a mes- 
sage is not generated; the re- 
quest is simply ignored. 

The requested file does nol exist 
on the indicated drive. 

The file name of the file being 
created already exists on the 
diskette. 

The file lype does not match the 
file lype in the direciory en | fy for 
the requested file 

This message occurs in conjunc- 
tion wilh ihe B-A command It 
indicates that the block | be allo- 
cated has been previously allo- 
cated The paramelers indicate 
the track and sector available 
with the next highesl number If 
the parameters are zero (0). then 
all blocks higher in number are 
muse 



169 



66 



ILLEGAL TRACK 

AND SECTOR 



67 



70 



ILLEGAL SYSTEM 
TORS 



NO CHANNEL 

(available) 



71 



DIRECTORY ERROR 



72 



DISK FULL 



73 



DOS MISMATCH (73, 

CBM DOS V2.6 1541) 



The DOS has attempted to ac- 
cess a track or block which does 
not exist in the format being used 
This may indicate a problem read- 
ing the pointer to the next block 

This special error message 
indicates an illegal system 
track or sector 

The requesied channel is not 
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 

The BAM does not match the 
internal count Tiere is a problem 
in the BAM allocation or the BAM 
has been overwritten -n DOS 
memory To correct this problem 
reinitialize the diskette to restore 
the BAM in memory Some active 
files may be terminated by the 
corrective action NOTE BAM = 
Block Availability Map 

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 

DOS 1 and 2 a»e 'ead compatible 
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 



170 






I 



74 



DRIVE NOT READY 



attempt is made to write upon a 
disk which has been formatted in 
a non-compatible formal. (A utility 
routine is available to assist in 
converting Irom one format to 
another) This message may a(so 
appear after power up. 

An attempt has been made to 
access the Floppy Disk Drive 
without any diskette present 



171 



APPENDIX C 

Deriving Mathematical Functions 

Functions thai are nol intnnsic lo BASIC 3 5 may be calculated as 
follows; 



FUNCTION 


BASIC EQUIVALENT 


SEC AN t 


SEC<X)-i/COSW 


COSECANT 


CSC<X)-1/SIN(X) 


COTANGENT 


COT(X)-l/TAN(X) 


INVERSE SINE 


ARCSIN<X)=ATN(X,<SOfi(-X-Xtl)) 


INVERSE COSINE 


ARCCOSIX)- -ATNiX/SQR 




( X'X.i;j.a.'2 


INVERSE SECANT 


ARCSEC<X>=ATN<X/SGR{X*X-l)> 


INVERSE COSECANT 


arccsc(X)=atn:x<sor<x-« . i 




-|-)GN{X(-I'ai2) 


INVERSE COTANGENT 


ARCOT!X)-ATN(X).ir'2 


HYPERBOLIC SINE 


SINH(X) E (EXP(X)-EXP|-X)K2 


HYPERBOLIC COSINE 


COSH(X)=<EXP(X)- *EXP( X]V2 


HVPERBOUC TANGENT 


TANH(X)-EXP(- X)/(EXPI«) - EXP 




l-Wt+1 


HYPERBOLIC SECANT 


SECH(X)-a(EXP(X).EXP( X)) 


HYPERBOLIC COSECANT 


C5CHtX)=? J (EXP(X)-EXP(-X)) 


HYPERBOLIC COTANGENT 


COTH(X)-EXP( - XHEXP(X) 




-EXPt-X))*:-'- ■ 


INVERSE HYPERBOLIC SINE 


ARCS1NH(X) = L0G(X i SORfX'X • 1» 


INVERSE HYPERBOLIC COSINE 


ARCCOSH(X) - LOG(X. SORlX'X - 1)| 


INVERSE HYPERBOLIC TANGENT 


ARCTANH<X)=LOG(|l »X^i X))/2 


INVERSE HYPERBOLIC SECANT 


ARCSECH(X)-LOG(*SOP 




( - X'X 1 !)• ll'X) 


INVERSE HYPERBOLIC COSECAN' 


ARCCSCH(X)-LOGl(SGN(XrSOR 




■>'..H> ■ 


INVERSE HYPERBOLIC COTANGENT 


ARCCOTH(X)-LOGl(X.U'|. \\y3 



172 







1 


1 


1 






1 


1 


f 


[ 


I 


! ' 


1 


I 


I 


1 


1 


1 


r 


1 


i 


' 


i 


1 


i 


1 


i 


1 


I 




i 


i 


: 


' 


i 


1 


( 


[ 


i 


1 


f 


1 


1 



APPENDIX D 
Musical Note Table 



NOTE 


SOUND REGISTER VALUE 


ACTUAL FREQUENCY (HZ) 


A 


7 


110 


B 


118 


1235 


C 


169 


1308 


D 


262 


146.8 


E 


345 


164.7 


F 


383 


174.5 


G 


453 


195.9 


A 


516 


220.2 


B 


571 


246.9 


C 


596 


261.4 


D 


643 


293.6 


E 


685 


330 


F 


704 


3496 


G 


739 


392.5 


A 


770 


440.4 


B 


798 


4949 


C 


810 


522 7 


D 


834 


588.7 


E 


854 


658 


F 


864 


699 


G 


881 


782.2 


A 


897 


880 7 


B 


911 


989 9 


C 


917 


1045 


D 


929 


1177 


E 


939 


1316 


F 


944 


1398 


G 


953 


1575 



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



173 



register value 7) use The 7 as the second number afler the SOUND 
command— SOUND 1.7.30 

Use the following formula fo find the sound register values lor frequen- 
cies other than those in the table: 

SOUND REGISTER VALUE - 1024-(111860 781/FREQUENCY) 

Both the table of sound register values arid the above formula are lor 
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 
the television standard, you should use the following formula to calcu- 
late new sound register values for the entire table 

SOUND REGISTER VALUE = 1024— (11T840.45/FREQUENCY) 






174 



APPENDIX E 
Screen Display Codes 

The following chart lists all ol the characters built into the Commodore 
character sets It shows which numbers should be POKEd Into screen 
memory (locations 3072 to 4095) to gel a desired character (Remem- 
ber lo set color memory —2048 to 3071 ) Also shown is which char- 
acter corresponds to a number PEEKed Irom the screen 

Two character sets are available, but only one set at a time. This means 
that you cannot have characiers from one set on the screen at the 
same lime you have characters from the other set displayed. The 
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 



175 



SET I 


SETS 


POKE 


5ET1 


9ET? 


KKf 


SETI SET1 POKE 


(<> 







T 


1 


20 


( 


40 


A 


a 


1 


U 


U 


21 


> 


41 


B 


o 


2 


V 


V 


22 


* 


42 


c 


c 


3 


w 


w 


23' 


■f 


43 


D 


a 


A 


X 


X 


24 


. 


44 


E 


B 


5 


Y 


y 


25 


- 


45 


F 


( 


6 


z 


Z 


26 


, 


48 


G 


g 


7 


I 




27 


/ 


47 


H 


h 


8 


f 




28 





48 


1 


i 


9 


I 




29 


1 


49 


J 


i 


10 


I 




30 


2 


50 


K 


k 


11 


- 




31 


3 


51 


L 


1 


12 


SPACE 




32 


A 


52 


M 


m 


13 


I 




33 


5 


53 


N 


n 


M 


■> 




34 


6 


54 








15 


# 




35 


7 


55 


P 


P 


16 


1 




36 


8 


56 


Q 


Q 


1? 


% 




37 


9 


57 


R 


r 


18 


& 




38 




58 


S 


s 


19 


i 




39 


i 


59 



176 








SET! 


5£T2 


POKE 


sen 


SET 2 


POKE 


SET! WT* POKE 


< 




60 
61 


D 


T 


84 
85 




108 


- 


a 


U 


109 


> 




62 


& 


V 


86 


h! 


110 


7 




63 


o 


W 


87 


□ 


111 


B 




64 


i* 


X 


88 


H 


112 


a 


A 


65 


a 


V 


89 


^ 


113 


m 


B 


66 


si 


z 


90 


^r 


114 


B 


C 


67 


b 




91 


H 


115 


B 





68 


E 




92 


II 


116 


H 


E 


69 


;i 




93 


LI 


117 


□ 


F 


70 


s 


8 


94 


1 


118 


D 


G 


71 


H 


K 


95 


- 


119 


a 


H 


72 


SPACE 


i 


96 


H 


120 


B 


I 


73 


E 




97 


U 


121 


a 


J 


74 


B 




98 


j y 


□ 


K 


75 


□ 




99 


. 


123 




L 


76 


D 




100 


a 


124 


s 


M 


11 


□ 




101 


Fl 


125 





N 


78 


m 




102 


B 


126 


□ 





79 


a 




103 


B 


127 


□ 


P 


80 


a 




104 







R 


B1 
82 


□ 





105 
106 






§ 


S 


B3 


CB 




107 







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



177 



















If 


















































APPEND 
















PRINTS 


CHRI 


PRINTS 


CHR» 


PRINTS 


CHRS 


PRINTS 


CHHS 


r* ■ ■ ^» ■ ■ r 


id CHR- 
















D 


68 


m 


97 


E 


126 


ffl 


lfi5 


ASCII ai 


Codes 




i *»*v 




















E 


69 


i. 


98 


H 


127 


Ml 


156 


This appendix shows you what 


characters will appear ii 


[you PRINT 




F 


70 


B 

B 


99 




128 




157 


CHR$(X). 


(or all possible values of X li will also show the values 


ob- 










f « 








tained by typing PAINT ASC("> 


'■"). where X is any character you 


can 




G 


71 


100 


FLASR 

ON 


129 


m 


158 


type. This ts useful in evaluating the character received 


in a GET 


i 




H 


72 


a 


'01 


130 


CYN 


159 


statement 


. converting upper/ lower-case, and printing c 


haracler 






1 


73 


102 


FLASH 


131 


5 PACE 


160 


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




OFT 


■J ■ '» ^ - » 


be enclosed in quotes 














J 


74 


ii 


103 




132 


c 


161 
















i 




K 


75 


a 


104 


H 


133 


a 


162 




















L 

M 

N 


76 
77 
78 


□ 


105 
106 
107 


f5 


134 
135 
136 


□ 

□ 


163 


PWNT5 


CHRS 


PRINTS 


CHRJ 


PRINTS 


CMRS 


PRINTS 


CMRS 


164 







♦ 


17 


" 


34 


3 


51 


165 




i 


• 


18 


# 


35 


4 


52 I 







79 


□ 


108 


* 


137 


■ 


166 




2 


SL 


19 


S 


36 


5 


53 | 


, 


P 


BO 


s 


109 


'* 


138 


3 


167 




3 


K 


20 


% 


37 


6 


54 




Q 


81 





110 


« 


139 


B 


168 




4 
5 




21 


4 


38 


7 


55 ' 




R 


82 


□ 


111 


HELP 


140 


B 


169 


■Bt 


22 


39 


8 


56 i 


I 


s 


63 


L] 


112 «■" «T™» '41 


□ 


170 




6 




23 


( 


40 


9 


57 




T 


84 


♦ 


113 


SWITCH TO 
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 

'2 


— 


2B 
29 


- 


45 
46 


> 
? 


62 r 
63 




v 

z 


89 
90 


D 


118 
119 




147 


r 


176 




■» 


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 
95 


ffi 
E 


123 
124 


m 
i: 


152 
153 


a 


181 

j I > L 


















182 


















i 

r 


i 


96 


CD 


125 


ES 


154 


n 


183 


178 














a 


1 
















179 



APPENDIX G 

Books For Commodore Products 

The following lisis Include a sampling ol ihe computer and program- 
ming books available The title of ihe book is listed first, followed by the 
author and publisher. 

Commodore Books 

VIC 20 Programmer's Reference Guide 
Commodore 64 Programme' s Reference Guide 
Commodore Plus/4 Programmer's Reference Guide 
Mastering Your VIC 20 
Four VIC 20 Computer Books 

VIC Revealed, Nick Hampshire 

VIC Games. Nick Hampshire 

VIC Graphics, Nick Hampshire 

Stimulaling Simulations for the VIC. C.W Engel 
Introduclcn to BASIC, Part 1 and 2. Andrew Colin 
Commodore Software Encyclopedia. Third Edition 

BASIC Programming 

Armchair BASIC. An Absolute Beginner's Guide lo Programming 

in BASIC. Fox & Fox, Osbome/McGraw-Hii) 
BASIC Handbook. Second Edition. Lien, Compusofl 
Basic Commodore 64 BASIC, Coan Hayden 
Elementary BASIC, Leogard & Singer, SRA 
How to Build a Program, Emmerichs, Dililhium Presa 
Instant Freeze-Dried Computer Programming in BASIC, Brown 
My Computer Likes Me When I Speak in BASIC. Albrechi. 

DilifhKim Press 
Nailing Jelly lo a Tree, Willis & Danley, DiMhium Press 
The Programmer's Book of Rules, Ledin & Ledin, Lileti'iie 

Learning Publishers 
Technical BASIC Kassab, Prentice-Hall 

Machine Language Programming 

Machine Language 'or Beginners, Mansfield, COMPUTE 1 Books 

Programming the 6502, Zaks, Sybex 

6502 Assembly Language Programming. Leventhal, Osborne/ 

McGraw-Hill 
6502 Micro Chart, Micro Logic Corp. 
6502 Software Design. Scanlon. Sams 
The &S02 Software Gourmet Guide & Cookbook. Findlay. Hayden 



'80 



[ 



t 



I 



I 
I 
( 
I 



INDEX 



Abbreviations 62, 157-199 
Addition 54 

Animation 87-70 
Airays 153-154 
ASCII Codes APPENDIX F 
AU'Q Command 98 



B 

BACKUP Command 97 

BASIC Encyclopedia 93-1 56 

BASIC Ablxevialion and Reference Chart 

157-169 
BOX Siatement 77-76, 109-110 



Calculations 54. 56-57 
Order or Catainaiions 57 
paienrhMes 57 

Cartridges 30-31 
Loading Cartridges 30-31 
Memory E*pansion Port 6 
CwselWn 31-34 
Cassette Port 8, 9 
Loading Cassettes 32-33 
Saving an Cassette 33-35 
CHAR Siaiemenl 76-77, 110 
CHP4 Codes APPENDIX F 
CIRCLE Statement 78-80, 1 1 0l 11 
CLEAR/HOME Key 21. 50. 51 
Clearing the Screen 21 , 50, 73 
CLOSE Slatemenil 12 
CLR Siatement 1 1 2 
CMD Statement 1 1 2-1 1 J 
COLLECT Command 97-08 
Colour 
ChangmgColou'843-44, 70- '2 
COLOR Statement '0-71.113 
Colour Kays 23-25. fij-44 
L drrnnance 71 
Mulb-colou' Mode Si -32 
PAINT Siatement 80-81 , 1 28-1 29 
Reverse Printing 22 43-44 
COLOR Statement 70-71 113 
Connectflo the Computer 9-1 1 
CQPV Command 93-39 



Conociing M slakes 
Erasing Ihe Screen 50 
Une Earwig 46-49. 61-52 



DATA Statement 11 3-1 U 
Dotasette Tape Recorder, 13. 31-32 
DEF FN Statement 1 14 
DELETE Command 99 
Deleting Leller 8 2Q,?1. 47-48 
Denizing Mainemai«cai Functions 

APPENDIX C 
D<M Statement 1 1 6 
D -ucl Mode 46 

DtRECTOFlV Command 28. 39. 99- 100 
0r> Enor Messages appendix b 
Disheltes 34-38 

DIRECTORY Command 27. 39. 99-1 00 

Headenng 36-38, 101-102 

Loading 35-36, 104-105 

Saving 38. 107-108 
OlwWton 54 

OLOAD Command 26, 36-38. KXH01 
DO/LOOP; WHILE/UNTIL/EXIT 115-116 
DRAW Statement 74-75, 116 
Di awing 

Circles 78-80 

Lines 74-76 

Points 74-75 

Polygons 79-80 

Rectangles 77-78 
DSAVE Command 26. 38. 101 



: I ng {See Screen Editing) 
END Stalemer.l 1 1 T 

Entering Commands 46 

Erasing Cnatacwa (See Screen Editing) 

Erasing L'nes (See Screen Enilirig) 

Error Messages 38. 38. APPENDIX A 

ESC Key 23, 51 

Exponentiation 65 



Floating Poinl Variables GO-61 . 1 53 
FOR . TO . . . STEP Siaiemenl 
117-118 



181 



• 



Formatting a Diskette 36-38. 10 1 

Fractions 55 

Functions 

NL(nerc8l-62. 143-149 

Special 152 

Strrtg 150-151 

User Defined 82 
Function Keys 26-27 



GET Slalemenl 118-119 
GETKEY Slalemenl 119 
GET* 5la!emenl r 9-1 20 
GOSUB Statement 1 20 
GOTO Statement 44 120-121 
G'apnic Modes 

High Resolution 72-82 

Multi-coioui 81-82 
GRAPHIC Statement 72-73. 121 
GRAPHIC CLR Statement 122 

OnpNn 

Animation 67-70 
BOX Siatemeni 77-78 
CHAR Slalomont 76-77 
CIRCLE Stelement 78-80 
DRAW Statement 74-75 
H gn Resolution 73-82 
Muttl-Co>omB1-82 
PAINT Statement 80-81 
Po-nis. Lines and Labels 74-76 
Srjjates. Cuctesana Polygons 77-80 
Us*ig Graph»c Keys 25. 64-67 
QSHAPE Slalemenl 1 39 ■' 40 



H 

HEADER Command 38-38. I0>-102 

HELP Command 102 

HELP Kay 27 

High Resolution Graphics 73-82 



I 

I 



I 



ELSE Statement 



IF THEN 

122-123 
Immediate Mode 46 
lnc*iect Mode 46 
INPUT Statement 1 23 
INPUT* Statement l 24 
Inserting Letters 20-21. 47-48 
INST/OEL Key 20-21, 47-48 
mlsger Variables 60-81 , 152-153 



182 



Joysticks 7 



KEY Command 102-103 

O Key 22. 45 

CLEAR/HOME Key 21 . SO 51 

Colour Keys 23 

CTRL Key 21 

Cursor Keys 20 

ESC Key 23. 6t 

=LASH ON/OFF Keys 23, 46 

Function Keys 28-27 

Graphics Keys 25-26, 64-67 

HELP Key 27 

INST/OEL Key 20-21, 47-48 

RETURN Key 19. *7 

RUN/STOP Key 19 

RVS ON/OFF Keys 22. 43-48 

SHIFT Key 1 8-1 9 

SHIFT LOCK Key 19 

Typing Mode 1 8 



LET Statement 1 24 

LIST Commano 27. 103-104 

LOAD Command 32-33. 104-105 

Loading 

Cartridges 30 

Cassettes 31-33 

Diskettes 35-36 
LOCATE Statement 125. 142-143 
Luminance. 71 



M 

Mathematical Opetaiois 54. 155-156 
Memory Eipanslon Pod 8. 30 
MONITOR Statement - 25 

Monitors 10. 14 

Mult<-<:olour Graphics 91-82 

Multiplication 54 

Muse 87, 86-91 (See also Sound) 

M'-scal Note Table APPENDIX D 



N 

NEW Command 50, 105 
NEXT SUIement 1 25-1 26 



( 



I 
I 
I 

I 



I 
I 
l 



I 



I 



Numbera 
Decimals 55 

Denying Mathematical Functions 
APPENDIX C 
Fractions 55 

Numenc Functions 6 1-62 143-149 
Operators 54, 155-156 
Older of Precedence 57 
Parentheses 57 
Performing Caoulatlons 54. 56-57 

Scientific Notation 55-56 
J^« -Defined Functions 62 
VanaOlas 60-61, 152-155 



ON Statement I 26-127 

OrvOH Switch 7 

OPEN Statement 127-128 

Operatois 
Logical 155-156 
Mathematical 54. 155-156 
Relational 54. 155-' 58 



PAINT Statement B0-8V 128-129 

Penaherats 12-10 

Pi 19,55 

P<*eiCurso* {PC) 142-^43 

POKE Statemem 1 29-1 30 

Power Supply 7-10 

PrinivniG 

Printing on the Screen 43-49. 58-60 

PRINT Statement T30 

PRINT* Statement 1 31 

PRINT USING Statemem i31-'.34 

Prim Zones 58-60 

Programming Mode 46 

PUDEF Sialement 134-135 



READ Statemem 1 35 

inai Operators 54. 1 55-1 56 
REM Slalemenl 1 36 

RENAME Command 105 
RENUMBER Commano 106 
Reso'vod Variable Names 1 54-1 55 
Reset Button 7, 50 
RESTORE Statement 138 
RESUME Statement 136-137 
RETURN Statement 1 37 



RETURN Key 1 9 

Reverse Priitng 22 43-46 

RF JarhS. 10 

RUN Command 106-107 

RUN/STOP Key 19 

RVS ON,OFF Keys 22. 43-4G 



S 

SAVE Command 33-34 38. 107-1 0B 
Saving p-ograms 

On Cassette 33-34 

On Diskette 36 
SCALE Slalemenl 137 
Soeniil* Noiaion 55-58 
SCNCLB Command 50. 73. 1 38 
SCRATCH Command 108 

Scieen Display 42 

Screen Deploy Codes APPENDIX E 

Screen Editing 

Correcting Mistakes 46-49 

CLEAR/HOME Key 21 50.51 

Clearing the Screen 50 

ESC Key 23. 51 

INST/OEL Key 20-21. 47-48 

Printing On the Screen 58-60 
Scieen Wmoows 51-52 
Serial Socket 9 

Setting Up the Computer 9- 1 2 
Software 

CaMrtrtge 30-31 

Cassette 31-34 

Diskette 34-38 

Souno 

Musica Nole Table APPENDIX D 

SOUND Slalemenl 85-87 

VOL Slalemenl 84 
Sound Effects 

Music 87 88 

Noise 67-88 
SOUND Siatemeni 

Duration 86-67 

Nole Frequency 85-86, APPENDIX D 

Voices 64-87 
SSHAPE Slalemenl 139-t 40 
STOP Statement 1 40 
Subtraction 54 

Switctws ana Sockets 
Cassette Poil 3-9 
HlgruL ow Switch 8 




Swlcnes and Sockets— cont 

Joystick Sockett 7 

Memory Expansion Port 9. 30 

On/On* Switch 7 

Power Socket 7-9 

Reset Bumy, 7. 50 

BF (TV) jack 8. 10 

Serial Socket B-9 

V>OeoSoctiel8,9. 11 
SYS Statement UQ 



~BKt Siring Variables 50-61 , 1 S3 
fRAP Statement 141 
rnoFF Statement 141 
TRON Statement '4' 
Tioub«fihoctng Chart 11-12 



TVCaW«6. 10 

II 

Uwt Defined Functions 62 

V 

Variables 

Ftoatmp, Point Numeric 60*1 , 1 53 

Integei 60-61 . 153 

Tail String 6041 , t S3 

Variable Names 1 52-1 53 
VERIFY Command 1 08-109 
VideoSocKeI8.9. 11 

VOlume Statement 64-65. 142 

W 

WAIT Stater^ent 1 42 
Widows Si -52 



( 
I 
l 
I 
i 
I 

I 



I 






I 
I 



I 



184