Commodore Plus/4 User Manual
বিজ্ঞাপন
বিজ্ঞাপন
User's Manual
WOHD
PROCESSING
SPREAD
SHEETS
.
EATA
MANAGEMENT tr
USER'S "This equipment generates and uses radio frequency energy. If it is
MANUAL not Pr°Per|y installed and used in strict accordance with the manu-
STATEMENT facturer's instructions, this equipment may interfere \\ Ih ■ idio and television reception. This machine has been tested and found to com ply with the limits for a Class B computing device in accordance with the specifications in Subpart J of Part 15 of the FCC Rules, which are designed to provide reasonable protection against such interference in a residential installation. If you suspect interference, you can test this equipment by turning it off and on. If you determine that there is interference with radio or television reception, try one or more of the following measures to correct it;
• reorient the receiving antenna
• move the computer away from the receiver
• change the relative positions of the computer equipment and the receiver
• plug the computer into a different outlet so that the computer and the receiver are on different branch circuits
If necessary, consult your Commodore dealer or an experienced radio/ television technician for additional suggestions. You may also wish to consult the following booklet, which was prepared by the Federal
Communications Commission:
"How to Identify and Resolve Radio-TV Interference Problems."
This booklet is available from the U.S. Government Printing Office,
Washington, D.C. 20402. Stock No. 004-000-00345-4;
You should use only the cables, accessories, and peripherals re commended by Commodore for your Plus/4. All cables, including the cables for the television hookup, serial port, video port, Datassette™ and joysticks, are specially shielded, in accordance with the regula tions of the Federal Communications Commission. Failure to use the appropriate accessories and cables will invalidate the FCC grant of certification, and may cause harmful radio interference.
Copyright © 1984 by Commodore Electronics Limited
All rights reserved.
This manual contains copyrighted and proprietary information. No pan ol this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of Commodore Electronics Limited
Commodore BASIC v 3 5
Copynghi ■£■ 1984 by Commodore Electronics Limited,all rights reserved.
Copyright © 1977 by Microsoft, all rights reserved.
-
COMMODORE PLUS/4
USER MANUAL
TABLE OF INTRODUCTION
CONTENTS CHAPTER 1 Unpacking and Setting Up
CHAPTER 2 Using the Keyboard and Screen
CHAPTER 3 Using Software
CHAPTER 4 Getting Started
CHAPTER 5 Beginning BASIC
CHAPTER 6 Numbers and Calculations
CHAPTER 7 Using Graphics and Color
CHAPTER 8 Making Sound and Music
COMMODORE PLUS/4 ENCYCLOPEDIA
1 BASIC 3.5 Encyclopedia
Commands
Statements
Functions
Variables and Operators
2 BASIC 3.5 Abbreviations
3 Conversion Programs
4 Error Messages
5 TEDMON
6 Screen Display Codes
7 ASCII and CHRS Codes
8 Screen and Color Memory Maps
9 Memory Register Map
10 Deriving Mathematical Functions
11 Musical Note Table
12 Programs To Try n?
115
1 u—
130
15b—
16^
196
199
201—'
203
204
206 '
169
U%~^
17^
184
193—
7
1 _
22
33 —
42
58
68 —'
83 _
104
~ n
n
13 RS-232 Guidelines
14 Book List
INDEX
209
215
216
_
INTRODUCTION
H
~ n
You've made a wise purchase... the Plus/4 is the first home computer ever designed especially for productivity applications. Of course, it's still able to do all the other things a home computer can be used for.
This manual is designed to help you learn those "other things" your
Plus/4 can do. You'll learn how to:
• Set up your Plus/4
• Use the different functions of all the keys on the keyboard
• Access different types of Commodore Software
• Use the mathematical, graphics, sound and programming capabilities of your Plus/4
The other manual included with your computer (T/ie Plus/4 Built-in
Integrated Software Manual) tells you how to use the wordprocessing.
electronic spreadsheet, database and graphics packages. If your main interest is in these productivity applications, and you can't wait to get started using them, we still recommend that you read through at
least chapter one of this manual ("Unpacking and Setting Up") before
reviewing the Built-in Software Manual.
WHAT'S
SPECIAL
ABOUT
THE
PLUS/4
64K RAM (60K available for BASIC programming)
Full Typewriter Style Keyboard
Optional Built-in Software
Screen Window Capability
HELP Key
8 Pre-programmed, Reprogrammable Function Keys
Four Separate Cursor Keys
Uses Most COMMODORE 64 and VIC-20 Peripherals
121 Colors (16 primary colors, 8 luminance levels)
Over 75 BASIC Commands
High Resolution Graphics Plotting
Split-Screen Text With High-Res Graphics
Graphic Character Set On Keyboard
Keyboard Color Controls
320 x 200 Pixel Screen Resolution
Reverse and Flashing Characters
2 Tone Sound Generators
Built-in Machine Language Monitor (17 commands)
CREATING
A COMPLETE
COMPUTER
SYSTEM
"i
Computer: Commodore PLUS/4
-
n
Display; Commodore 1702 or 1802/1803 Color Monitor
Storage: Commodore 1531 Datasselte (tape recorder) or Commodore
Disk Drive
Printer: Commodore Printer
._
-
H
Modem: Commodore
MODEM/300 n n
Controller: Commodore PLUS/4 Joysticks
WHERE By now you've done enough reading and you want to get started.
jn Here's what we recommend you do now:
FROM • Send in your warranty card
HERE? • Subscribe to the Commodore magazines to get the latest informa
tion on your computer
Read this manual and try the exercises. Read the built-in software manual and get used to the four integrated packages. Keep checking in with the Commodore dealers in your area for new developments in software, books and peripherals. Learn, program, file, write, calculate, graph, play... enjoy your new Commodore Plus/4!
CHAPTER 1
UNPACKING
AND
SETTING
UP
• Unpacking your Commodore Plus/4
• Getting to know the switches and sockets
• Setting up your Commodore Plus/4
• Troubleshooting chart
• Peripherals
UNPACKING Now that yc
YOUR thls manual, the first
COMMODORE youhave
PLUS/4
———=
t0
Your Commodore Plus/4
2. The power supply
s into the right side of
—
3. The TV switchbox
This connects to the antenna jack on the back of your TV. You don't need Ihe switchbox if you plan to connect your Plus/4 to a monitor.
4. The RF cable
This connects the TV switchbox to the RF output jack on the left
side of the Plus/4. You don't need this cable to connect your Plus/4
to a monitor.
5. The user manual
6. Other assorted literature
Warranty card
Commodore Magazines subscription card
7. The Plus/4 Built-in Integrated Software Manual
If you don't find all these items in the box. check with your dealer immediately for replacements.
Before you connect anything, you should look over these drawings of your computer. These drawings identify all the outlets so you can set up your computer system quickly and easily.
_
GETTING
TO
KNOW
THE
SWITCHES
AND
SOCKETS
The Right
Side of Your
PLUS/4
1
. r.
The On/Off Switch
Your Plus/4 should be turned OFF when you install or remove car tridges or any peripheral device such as a printer or disk drive. There is a red power light located below the keyboard on the left, so you can be sure whether power is off.
2 The Reset Button
There are two ways to use the RESET button:
1. You can use the RESET button to reset your computer as if you'd just turned it on. Just press the reset button once. Remember: when you press the reset button, you lose any BASIC program currently in memory."
2. If you want to reset your Pius/4 and keep your BASIC program, hold down the RUN/STOP key and then press the RESET button. When you do this, your Pius/4 goes to the built-in machine language monitor.
Type an X and press the RETURN key to get back to BASIC. Your pro gram remains intact in the Plus/4 memory. Just type LIST to display the program on your screen.
'When you press RESET, the Plus/4 automatically issues the NEW command, which clears the screen. This can be reversed. See the
PluS'4 Programmer's Reference Guide tor information on UNNEWing your program if you've pressed the reset button by accident.
_
_
H
The
Left
Side
Of
Your
PLUS/4
~~ n
H
The
Back of
Your
Computer
The socket and the switch on the left side of the Plus/4 are both used for TV connections. Neither is used if you're connecting your Plus/4 to a monitor.
3 The RF Jack
This is where you plug in one end of the RF cable (the thin black cable). You can plug either end into this jack and the other end into the
TVswitchbox.
4 The High/Low Switch
This switch controls which channel is used for Plus/4 video output. Set the H/L switch to L for output on channel 3. Set the H/L switch to H for video on channel 4.
You can use either channel 3 or 4 on your TV to display the video pic ture from your computer. If you have a channel 3 TV station in your area, select channel 4, and vice versa. Experiment to see which setting gives you the best picture.
m
■i
The sockets on the back of your computer connect a variety of accessories to your Plus'4. Each connector is different. Be sure you plug each accessory into the correct socket.
The Power Socket
The end of Ihe power supply cable fits here. Plug the other end into a standard wall socket for three-prong plugs.
5 The Serial Bus
You can plug a disk drive or a printer into this socket. If you want to plug in both, first plug the disk drive into this opening, then plug the printer cable into the back of the disk drive.
7 The Cassette Port
The Commodore 1531 Datassette tape recorder plugs in here.
8 The RS-232 Port
Accessories such as a modem or an RS-232 adapter plug in here.
An RS-232 adapter makes it possible to hook up accessories not ac commodated by standard Commodore equipment ports.
9 The Memory Expansion Port
Plus 4 software cartridges and the Plus/4 SFS-481 disk drive plug in here. Before you install or remove cartridges, make sure your Plus/4 is OFF.
10 Joy 1 and Joy 2 : The Game Ports
You can plug joysticks into these sockets. The Plus/4 uses specially designed joysticks available from your Commodore dealer.
11 The Video Socket
This is where you plug in the cable that connects a monitor to your
Plus/4. Although this socket is an 8-pin connector, you can use a 5-pin cable in this socket as well. Commodore color monitors come with an
8-pin cable for use with the Plus/4.
—
TING • To set UP y°ur P'us''4' y°u'" need at leasl tw0 wa" P'ugs. one for your
yp Plus/4 and one for your TV or monitor.
YOUR • If you're installing a disk drive and a printer, you'll need additional
PLUS/4 wall plugs.
• Your Plus'4 should be placed a comfortable distance from your TV.
• Make sure that your computer is OFF before you start the setup.
Check that the POWER LIGHT on the front left is not lit.
If you are connecting the Plus'4 to a television set. you'll need a small screwdriver to attach the TV switchbox. The way you connect the switchbox depends on what type of antenna connection your TV set has
IMPORTANT: If your antenna is connected to your TV by a single round-ended cable {the 75-ohm co-ax type), you will need either the 300 ohm to 75 ohm adapter, which came with your TV, or you must get a replacement 75 ohm to 75 ohm switchbox. The adapter is a small plastic part with a co-ax connector on one side and two screws on the other If you do not have one, you can buy one at most electronics stores. Once you attach the adapter to the co-ax connector on your set. you can follow the rest of these instruc tions. A 75-ohm switchbox allows you to hook the antenna lead into the switchbox, which is connected to the TV, so that you only have to move the switch on the switchbox to watch TV.
You need only connect the switchbox once. When you want to use your computer, just move the switch to the COMPUTER position. When you want to watch TV, move the switch to TV. The switchbox will not interfere with your TV reception.
13
STEP 1 Disconnect the antenna from your TV: use a screwdriver to loosen the screws on the TV Remove the two antenna leads
STEP 2 Connect the TV swilchbox lo Ihe TV where Ihe anienna leads were attach the leads on the box to Ihe antenna inpul on your TV
STEP 3 Connect the antenna to Ihe swilchbox attach the leads from the antenna to the screws on the side of the switchbox.
__
Connect to Antenna input (300 ohm] n Rear of TV
RF Cable u
Power Supply li you have the round coax type anienna connection on your TV sfEP 1 Disconnect the antenna from your TV unscrew the antenna wire You can disconnect it by hand
STEP 2 Connect the swilchbox to your TV hand fasten it onto Ihe antenna inpul post on (he back of your TV
STEP 3 (For the 75-ohm switchbox) Connect ihe anienna lo the switchbox. hand-lurnmg the antenna cable into the switchbox.
If an Adapter is Necessary
Remove to Connect
Anlenna
Lead lo TV
Once the switchbox is m place, gel the RF cable (the thin cable with connectors on both ends) that came with your Plus"! Plug one end into
;he sockei on the side of the switchbox. Conned the other end into the socket marked RF on the lelt side of your computer
NOTE II you're using the 300- to 75-ohm adaptor and you want to watch TV, you must disconnect the switchbox and plug the an tenna lead back in. This is easily done by hand, and may be done as often as you like, with no damage to your TV. computer, orantenna
Selecting
A Channel
On Your TV
YOUr tO a Monitor
As we explained earlier, your TV should be set on either channel 3 or 4 when you are using your computer. Don't choose a channel that
Droadcas!s in your area. If you use channel 3, set the H/L switch on the side of the computer to L. If you use channel 4. set this switch to H.
lf y°u re connecting your computer to a monitor instead of a TV, follow
'^e 'ns'ruc''ons 'n tne manual thai is included with the monitor. Hook-
ing up a monjtori |jj<e the Commodore 1702 Color Monitor, is simple. It requires only one cable that connects directly from your monitor to the VIDEO socket in the back of your computer.
'-"
1.
Attach the power supply cable from the power box to your Plus/4.
Plug the round end of the cable into the POWER socket on the back of the computer; plug the power supply into the wall socket.
2.
If you are using a TV, make sure that the setting on the H/L mod ulator and the channel on your TV are in agreement. (If your com puter is set at L, the TV must be on channel 3; the TV should be tuned to channel 4 with your computer at H.) Make sure that the switchbox is set to the COMPUTER setting.
If you are using a Commodore color monitor, use the rear jacks, and check that the backfront switch is set to back.
3.
Turn on your computer. {The switch is on the right side as you face the Plus/4.)
If all is well, this message appears on your screen:
COMMODORE BASIC 3.5 60671 BYTES FREE
READY.
The flashing cursor under the READY message tells you that the
Plus/4 is waiting for you to start typing. The background color is white, while the letters are printed in black, with a light purple border around the screen.
4.
Check the troubleshooting chart if you have problems. You may need to adjust your TV set to get a sharper picture.
U
16
-TROUBLESHOOTING
CHART
-
"
~
Symptom
Indicator light not'ON'
Cause
Computer not turned ON
Power cable not plugged in
Power supply not plugged in
Bad fuse in computer
No picture TV on wrong channel
Incorrect hookup
Video cable not plugged in
Computer set for wrong channel
Switchboxnot set to computer
TV not on
Random pattern on TV with cartridge in place
Picture without color
Cartridge not properly inserted
Poorly tuned TV
TV not connected
Remedy
Make sure power switch is in ON position
Check power socket for loose or discon nected power cable
Check connection with wall outlet
Take system to au thorized dealer for replacement of fuse
Check other channel for picture (3 or 4)
Computer hooks up to
VHF antenna terminals
Check TV output cable connection
Set computer for same channel as TV
Check that switchbox is in 'computer1 position
Turn TV on
Reinsert cartridge after turning OFF power
RetuneTV
Check connections properly
17
Picture OK, but no sound
TV volume too low
Poorly tuned TV
Auxiliary output not properly connected
Adjust volume of TV
Retune TV
Check connection as shown on diagram on page 14-15
—
—
-
IMPORTANT: Some TV sets cannot display the entire Plus/4 screen. Instead, their picture cuts off the far left and far right column of the Plus/4 screen display. We recommend using a different TV set or a monitor such as the Commodore 1702 or
1802/1803 color monitor.
If this is not possible, you can deal with the problem by pressing the ESCape key, followed by the 'R' key. This reduces the com puter screen display size so the entire picture can fit onscreen.
You must repeat this each time you power up or reset your Plus/4.
18
—
.
PERIPHERALS Peripherals are the accessories that you can add to your Plus/4 sys tem. These accessories are available at your Commodore dealer, and allow you to use the Plus/4 to the fullest. Peripherals give your Plus/4 system the capability to store and save data, print hard copy (in black and white or color), use disk and cassette-based software, and access the information and services available through telecommunications.
n
-
n
To save or recall programs, you'll need a device that stores data. Data can be stored on and retrieved from both diskettes and cassette tapes.
To use diskettes, you'll need a DISK DRIVE. Disk drives are typically fast and efficient to use. Disk drives that are compatible with your
Plus/4 are the Commodore models 1541 and 1551. For cassette-based storage and retrieval, the Commodore 1531 DATASSETTE tape recorder fills the bill.
19
When using a wordprocessing program or a graphics package on the
Plus/4, a printer will reproduce what is on the screen on paper. There are several models of Commodore printers available that work with the
Plus/4. These include the MCS-801, MPS-802. MPS-803 (with tractorfeed) and DPS-1101 (letter quality). Different printers specialize in dif ferent types of print-outs. Ask your dealer which best suits your needs.
„
Your television may not give you as clear a picture as you'd like for your computer. Commodore color monitors are specially designed to give
you the sharpest, brightest picture for your Plus. 4* screen output. There
are several Commodore monitor models available, including the 1702, and 1802/1803.
-_
20
n
—
— n n
There are networks that you can reach over the phone whose purpose is to provide information, programs, news, stock market reports, enter tainment, and almost anything else you could think of to computerists by using the phone lines. To gain access to the tremendous range of services, software, and information available, you must be equipped with a MODEM.
The Commodore PI us/4 MODEM connects your Plus/4 to these information services over telephone lines. With one of these modems, you can have access to computer services such as CompuServe and
The Source. Commodore supports its own service called the Commo dore Information Network, which is available through CompuServe.
The Commodore Information Network (CIN) specializes in information for the Commodore owner, including current dealer lists, Commodore hardware and software tips, and a direct line to Commodore Customer
Support. A wide assortment of programs is available on the Commo dore User Database segment of CIN. including graphics, music, educational programs, utilities and games.
-
CHAPTER 2
USING
THE
KEYBOARD
AND
THE
SCREEN
• A tour of the keyboard
• Special keys
• Graphic keys
Programmable function keys
The HELP key
22
A
TOUR
OF
THE
KEYBOARD
LJ
Most of the keys on the Plus/4 keyboard are identical to the 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 © key and the cursor arrow keys. This section will show you the extra features of every key, including how to use the graphic symbols pictured on the fronts of —■ many of the keys.
While we guide you on the tour of the Plus/4 keyboard, you should find — the keys and practice using them.
23
„
SPECIAL RETURN
KEYS
You have to press the return key at the end of each line of instructions you enter on your Commodore Plus/4 keyboard. You might think of this key as an ENTER key because RETURN actually enters information and instructions into the computer.
SHIFT
This key works like the shift key on a regular typewriter. Your Plus/4 has two SHIFT keys and a shift lock , which works like (he shift lock on a typewriter.
By pressing the SHIFT key. you can get the graphic symbol on the right side on each graphics key when you are in upper-case/ graphics mode.
fs
Your Plus/4 is automatically in upper-case/graphics mode when you turn it on. In upper-case/graphics mode, all the letters appear upper case without the SHIFT key.
The SHIFT key pressed with a letter key gets upper-case (capital) letters when you are in upper/lower-case text mode (the same as the
SHIFT key on a typewriter). When in this mode, the letters you type are ii ower-case except whei /ouusethe shift ke^
NOTE: You can go back and forth between upper-case/graphics and upper/lower-case text modes by pressing the shift and key at the same time.
RUN/STOP
Press this key to break into a running program to STOP what your
Plus/4 is doing. When the Plus/4 is running a program, pressing this key returns control back to you and the keyboard.
When you hold down the shift and RUN/STOP keys simul taneously, the Plus/4 loads and runs the first program on a disk in the disk drive.
24
-
The
Cursor
Keys
It's easy to move the cursor quickly around the screen in any direction.
Just press the cursor arrow key that points in the direction you want to go. Like all keys on the Plus/4 keyboard, each cursor key can repeat indefinitely while the key is held down. This automatic repeat function — keeps the cursor moving until you release the key.
NOTE: You can move the cursor over letters and numbers on the screen without affecting those characters.
INST/DEL —
You can INSERT and DELETE letters and numbers from the line you are typing by pressing this key. When you press this key by itself, that character immediately to the left of the cursor disappears, and the cursor moves over to where the missing character was. You can use tne cursoi Keys to go : act- l \ the mid lie of a me in I thei use
DEL to DELete a letter. When you do this, the letter to the left is deleted, and the rest of the letters on the line move over one space to the left to close the gap.
—
You can open up space to insert letters and numbers by using the
shift and inst keys. Space opens to the right of the cursor; —I
the cursor itself does not move. When you insert space in the middle of a line of letters, the rest of the line moves to the right.
The INST/DEL key saves a lot of time when you want to edit or change what you've typed.
CLR/HOME
This key serves three functions: HOME, CLEAR, and CLEAR
WINDOWS. When you press this key, the cursor immediately moves to — the top left corner of the screen. This is called the HOME position. The rest of your screen stays the same. If you hold down the shift key _ and press CLR/home , no! only does the cursor move to HOME, but the screen clears. All that remains on the screen is the blinking cursor at the top left corner of the screen. If you press this key twice.
—'
25-
_
—
—
— any screen windows that you have set up are erased. Screen windows are work areas that you designate on part of the screen; there'll be more about them later,
CONTROL
This key always works with another key. The CONTROL key works like the SHIFT key you must hold it down while you press the other key.
1.
As the COLOR KEYS section explains, pressing CONTROL and a color key allows you to choose the colorpf the text printed on the screen.
2.
You can pause a program that is PRINTing or LISTing on the screen by pressing CONTROL and the S key (press any key to resume program output).
3.
CONTROL is also used with the REVERSE ON/OFF" and
FLASH ON/OFF keys
;■ iddition, ome software program! thai /ou buy make use ol the
CONTROL key fc their own special functions.
MM
Like the CONTROL key, the Commodore key works with other keys.
il has four functions:
1.
When used with the shift key, the O key lets you switch between upper-case/graphics mode and upper/lower-case
text modes.
,^_-_
2.
When you're in either mode, the &■'_> key acts as a shift to let you type the graphics symbol pictured on the LEFT front of each
key. Just hold down Jt£S$ and press the graphic key you want.
3.
When you want to change the color you are typing in to one of the
8 colors listed on the BOTTOM row of the face of the color keys, press ~@ji£§ and the color key you want.
4.
When you want to slow down a scrolling program display, hold
down the (HESB Key. The display scrolling speed slows down
considerably. When you release the key, the screen scrolling resumes normal speed. (Hey, it can do something by itself!)
You can change Ihe colors of the letters, numbers, and graphics symbols on the screen to any one of the 16 colors available on your
Pius/4. It's simple to do
• If you want one of the 8 colors listed on the TOP row on the front of the color keys (like BLK for black), just hold down the
CONTROL key and press the key with the color you want at the same time.
• If you want one of the 8 colors listed on the BOTTOM row on the front of the color keys (orange, for example), just hold down the O key and then press the color key with the color you want.
Practice changing colors to make sure you understand how to do this.
You'll notice that after you change the color, every letter and number lyped AFTERWARDS \i n ihecoioi /ou hs; i hose
REVERSE ON
REVERSE OFF
Your Plus/4 lets you print the reverse image of letters and numbers.
In other words, if you are using black letters on a yellow background, you can use the reverse image keys to print yellow letters on a black background.
Here's all you do to get reversed images Press the control Key and the RVS ON key. Now everything you type is displayec in reverse until you press the CONTROL and RVS OFF the
RETURN key. or the Escape key and 0 This returns you to typing normal (non-reversed) characters.
FLASH ON
FLASH OFF
You can make the characters on your screen flash continuously Just press CONTROL and the flash ON key to make whatever you type flash. Typing CONTROL and FLASH OFF .
RETURN , or
ESCape lets you type normal (non-flashing) characters again
27
—
~~
—
__
—
—
GRAPHIC As we mentioned before, when you turn on the Plus/4, it is in upper-
KEYS case/graphics text mode. When you're in this mode, you can type the full set of more than 60 graphics you see on the fronts of many of the keys, as well as all upper-case letters without using the SHIFT key The shift key lets you type graphics in this mode, instead of upper-case letters
There are two graphic symbols on each graphics key:
• To print the graphic symbol on the right, hold down the SHIFT key while you press the appropriate key.
^^^
• To print the graphic symbol on the left, hold down the O key
while you press the selected key.
You can create pictures, charts, and designs by printing graphics side-by-side or on top of each other, like building blocks. Try printing some of the graphics keys to see how they work. Chapter 7 explains more about graphics.
You can switch between upper-case/graphics mode and upper/lower case mode by pressing the SHIFT and C* keys at the same lime. In either mode, type BASIC commands without holding down the
SHIFT key.
In this mode, you can type upper- and lower-case letters, just like a regular typewriter. {You will have to shift for upper-case letters.) You also can use the graphic characters on the left front of the keys, which print as in upper-case/graphics mode; hold down C and press the graphic key. The left side graphics are ideal for creating charts, graphs, and business forms.
ESCAPE
The Escape key lets you perform many special screen edit ing functions, including functions utilizing the windowing capability of the Plus/4. Windows are areas of the screen (defined by you) that may be used as work space without affecting the rest of the screen. The
ESCape key can perform several window editing functions, as well as many other regular uses, such as inserting, deleting, and scrolling.
The ESCape key is typically used with standard alphabet keys. To activate a function, press the ESCape key followed by one of the keys listed below.
28
I
J
K
L
A Automatic insert mode
B Set the bottom right corner of the screen window
(at the current cursor location)
C Cancel automatic insert mode
D Delete current line
Insert a line
Move to the beginning of the current line
Move to the end of the current line
Turn on scrolling
M Turn off scrolling
N Return to normal screen display size
0 Cancel insert, quote, reverse, and flash modes
P Erase everything up to the cursor position on the current line
Q Erase everything up to the end of the current line from
cursor position
R Reduce screen display
T Set the top left corner of the screen window
V Scroll screen up
W Scroll screen down
X Cancel the escape function
Special Symbols
The Plus/4 Keyboard also contains special symbols not found
on many typewriters, or even on most computers. These special
symbols include the English pound sign (£?), pi (it), greater and less
than signs (< >), brackets ([ |), and arrows {]). These special sym bols keys are used in programming your Plus/4.
—
29 —
~ n
PROGRAMMABLE
FUNCTION
KEYS
The four keys at the top of your keyboard are special function keys that let you save time by performing repetitive tasks with the stroke of just one key.
You can display what each key does by typing KEY and pressing
RETURN.
The screen displays:
KEY
KEY1
KEY 2
KEY 3
KEY 4
GRAPHIC"
'DLOAD1'-CHR${34)
DIRECTORY" + CHR${13)
SCNCLR"-CHR${13)
DSAVE"-CHR${34) KEY 5
KEY 6
KEY7,"LIST"-CHR$(13)
KEY8I"HELP"+CHR$(13)
Here's what each key does:
KEY 1
KEY 2
KEY 3
KEY 4
KEY 5
KEY 6 enters one of the GRAPHICS modes when you supply the number of the graphics area (e.g., GRAPHICS 2, which is split screen, high resolution mode) and a RETURN . On computers with built-in software. KEY 1 is redefined so that pressing it activates the software package prints DLOAD" on the screen. All you do is enter the program name to oa:; a program from :i Bk and hit
RETURN instead of typing out DLOAD yourself.
lists a DIRECTORY of files on the disk in the disk drive.
clears the screen (even in one of the graphics modes.) prints DSAVE " on the screen. All you do is enter the program name to save the current program on disk and press RETURN
RUNs the current program.
30
KEY 7
KEY 8 displays a LJSTing of the current program
(the HELP, key) highlights errors in program statements in flashing print.
To use one of these functions, just press the appropriate function key.
You need to use the SHIFT key to get FUNCTIONS 4. 5. 6. and 7.
You can redefine any of these keys to perform a function that suits your needs. Redefining is easy, using the KEY command. You can redefine the keys from BASIC programs, or change them at any time in direct mode. {The new definitions are erased when you turn off your
Plus'4.) You can redefine as many keys as you want and as many times as you want.
—
31
THE
HELP
KEY
HELP
When you make an error in a program, the Plus.4 displays an error message to tell you what you did wrong. These error messages are further explained in Section 4 of Ihe Plus/4 Encyclopedia in the second half of this manual
You can get more assistance with errors by using the HELP key
After an error message, press help to locate your error When you
press | HELP the line with the error is displayed on the screen with
ihe error flashing on and off For example:
'SYNTAX ERROR IN
LINE 10
Plus 4 displays this
10 PRONT -COMMODORE
COMPUTERS"
You press HELP
Plus'4 displays this with your error flashing
■;■
u
Lj
_
33
CHAPTER 3
USING
SOFTWARE
• Introduction
• Built-in software
Cartridges
Cassettes
Diskettes
INTRODUCTION The fami!v of software available for your Plus/4 is growing quickly. Your
dealer can keep you up-to-date on new products and inform you about the features of software that's currently available.
Your Commodore Plus/4 can use software on CARTRIDGE. CAS
SETTE TAPE and DISKETTE form, available from your Commodore dealer. All you do is load them into your Plus/4. You can also create and store your own programs on cassette tapes or floppy disks
BUILT-IN
SOFTWARE
Your Plus 4 is equipped with built-in software packages These are programs built into the Plus/4, turned on by pressing the appropriate
FUNCTION key. Your Plus'4 built-in software makes your computer a word processor, database, spreadsheet and graphics machine. A built-in package is ready to use whenever you power up your com puter. When you turn on your Plus/4, the screen message tells you which packages are available and what function key to use to activate them. Also, you can use the KEY command to see the function key definitions. H there is function key software built into your Plus 4, the definition for KEY 1 will be: SYS XXXXX:package name. Just press
FUNCTION KEY 1 and press RETURN to activate the program.
_
_
_
34
-
CARTRIDGES
Loading
Cartridges
Commodore produces a full assortment of cartridge software for your Plus/4. There is a variety of personal, education, and business programs, as well as exciting games available on cartridge for your
Plus/4. Follow these steps to use cartridges:
STEP 1 Turn OFF your Plus/4.
IMPORTANT: YOU MUST TURN OFF YOUR COMPUTER
BEFORE YOU INSERT OR REMOVE CARTRIDGES, IF
YOU DONT. 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 slot into the back of your computer.
STEP 3
STEP 4
Turn ON your Plus/4.
Begin the game or program according to the instructions that come with the software. A cartridge program starts immediately, while function software starts after pressing the function key.
35
CASSETTES
Loading
Cassette
Tapes
A variety of software products for the Plus/4 is available on cassette tape. These cassette tapes are similar to the music cassettes that you play on your tape deck or stereo. Computer tapes run in the Datassette tape recorder, available from your Commodore dealer.
You can also use cassette tapes and the Datassette to store programs you write yourself. The next section explains how to save programs on tape.
The steps for loading tape are the same whether you are using prerecorded software or programs you saved yourself.
STEP 1
STEP 2
STEP 3
Insert the cassette into your Datassette and close the door.
Rewind the tape to the beginning by pressing the REWIND —.
button on the Datassette.
When the tape is rewound to the beginning, type LOAD and —l press the RETURN key. The computer responds with the following message:
PRESS PLAY ON TAPE
STEP A Press the PLAY button on the Datassette. The screen goes
blank as the Datassette starts When a program is found, Hi
the screen displays this message:
FOUND "program name"
LJ
STEP 5 Press the Commodore key to load the program that was
FOUND. If there is more than one program on the tape, and the program the PlusM found isn't the one you want, press ___
the space bar to keep searching.
36 ^
When the program is loaded, the word READY appears. If you want to stop the loading before it's complete, press the RUN/STOP key.
After the software is loaded, type RUN to start the program. You can
also LIST the program or change it, if it is a BASIC program.
NOTE: To LOAD a specific program on the tape, use the LOAD
"program name" form of the LOAD command.
Saving When you write a program and want to save it on cassette tape, follow
Programs !nesesteps:
On STEP1
Cassette
Tape
Type:
SAVE "program name"
The program name you use can be anything you want, but can be no more than 16 letters and/or numbers long.
STEP 2 Press the RETURN key. The computer displays
this message:
PRESS RECORD AND PLAY ON TAPE
STEP 3 Press the RECORD and PLAY buttons on your Datassette.
The screen goes blank. When your program is saved, the word READY appears on the screen.
Examples of SAVE Commands for Cassette Tape:
SAVE "MYJOB"
SAVE "3TEST"
This name is the specific name of the program being saved
When LOADing or SAVEing a program, if you decide to stop before it's finished, you must press the RUN/STOP key first. After pressing
RUN/STOP on the keyboard, then press the stop button on the
Datassette.
37
NOTE: When saving a program onto a cassette tape, always be aware of where the tape is positioned. In particular, be care ful noi to save a program at the absolute beginning of a tape, since many tapes have magnetic leaders, which will not record information. Thus, part of the program would not be saved.
DISKETTES
Loading
Programs
From
Diskette
Disks are fast and easy to 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.
The steps are the same for loading all disks: __
STEP 1 Make sure that your disk drive is ON.
_
STEP 2
STEP 3
STEP 4
STEP 5
Insert the disk into the disk drive. The label side of the disk must face up. insert the disk into the opening so that the la beled end goes in last. Look for a little notch on the side of disk (it might be covered with a sticker). This notch should be the left side as you put in the disk, assuming that you're facing your disk drive. Be sure the disk is in all the way.
Close the protective door on the disk drive after you insert the disk.
Type:
DLOAD "program name"
Specific name of the program to be
LOADed
To save time, you could press FUNCTION KEY 2 and type in
the program name and the second quote marks.
Press the return screen says: key. The disk spins and your
38
-
SEARCHING FOR PROGRAM NAME
LOADING
READY
~
~
STEP 6 Your software is ready to use. Now type RUN and press the
RETURN key to start the program.
If the red light on the disk drive blinks after the DLOAD is finished, something went wrong. Type:
?DS$ (and hit RETURN ) to find out what went wrong.
Examples of DLOAD commands:
Headering
A
Diskette
DLOAD11*"
DLOAD "MYFILE"
DLOAD "SET*"
DLOAD "$"
LOADs the 1st program on the disk.
LOADs a disk program called
MYFILE.
LOADs the first program on the disk that begins with the letters SET.
LOADs the directory, a listing of all the programs on the disk in the drive.
Headering prepares a new BLANK disk for use. Any blank disk must be formatted before it may be used, by using the HEADER command.
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.
. I
The format for the HEADER command is:
HEADER "disk name", Udevice#, Ii.d.#.Ddrive#
• The name you use is the name of the entire disk. Give the disk any name up to 16 characters.
• Device # specifies which device for your computer (disk drive as opposed to Daiassette), and is usually number 8.
• Thei.d. is the letter I and any two letters and/or numbers, like 121,
IR5, etc. Give the disk any i.d. you want, but you should give every disk a different i.d. to avoid confusion.
• If you have a dual drive, add DO or D1 to identify the drive
number. If you have a single drive, you must use DO.
—
_
ARE YOU SURE?
As soon as you press RETURN after typing the HEADER command, the Plus/4 asks ARE YOU SURE? This is to give you a last chance to change your mind.
To header the disk, type YES or Y and press return . If you decide not to header the disk, type NO or N and press return
Here are some examples of HEADER commands:
—
HEADER "LETTERS", U8.107.D0
HEADER "FINANCES", U8,IS3,D0 —
Now that you know how to HEADER a disk, you're ready to use disks to write and save programs on your Pius/4. The first section of the Plus/4
Encyclopedia has more information about the HEADER command.
When you want to reuse a program you've written, be sure to SAVE it
PrnnramQ before you LOAD another program or turn off the Plus/4. If you don't,
riuyidina you'll lose the program.
Diskette When you change a SAVEd program, you have to save it again if you
— want to keep the new version.
When you reSAVE a program, you are replacing the old version with —
.
40^
_
._.
the new one. If you want to keep both the old and the changed versions, you have to 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 . The computer displays this message when the program is saved;
SAVING "program name"
OK
READY.
Example:
DSAVE "MYPR0G5"
The program name can be up to 16 characters long.
If the red light on the disk drive blinks after the DSAVE is finished, something went wrong. Type:
?DS$(andhit RETURN ) to learn what went wrong.
THE When you SAVE programs on disk, the computer keeps a listing of all
DIRECTORY the files saved on tnat ^'sk. 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 RETURN
(or press FUNCTION KEY 3)
As soon as you press RETURN . your Plus/4 displays every thing on your disk.
You can also display just part of the table of contents:
DIRECTORY "MY*"' return Lists every file on the disk that starts with the letters MY.
41
LJ
—
!
I
~
~
-
CHAPTER 4
GETTING
STARTED
Keyboard colors
Color and reverse printing
Some simple programs
Correcting typing mistakes
Introduction to the Plus/4 screen
More about PRINTing on the screen
Screen windows
42
INTRODUCTION The purpose of this chapter is to begin to acquaint you with some of the —■ characteristics and capabilities of the Plus/4, and how to take the first
steps toward programming with your computer.
i
_i
LJ
43
U
~
KEYBOARD Y°u can change the color of the characters on the screen to improve
COLORS readaDility or !o fincj a color combination you like. To see how the differ
ent color characters look on your screen, try this:
STEP 1 Hold down the CONTROL key
STEP 2 Press the 6 key while you're holding the key down . The cursor turns green.
CONTROL
STEP 3 Le! go of CONTROL and type some letters. Everything you type appears in green now.
HOLD CONTROL
WITH COLOR KEY
5
6
3
4
7
8
1
2
COLOR
RESULT
BLACK
WHITE
RED
CYAN
PURPLE
GREEN
BLUE
YELLOW
Using the CONTROL key with the number keys 1 through 8 allows you to choose the colors shown on the top of each color key.
Now hold down the Cc key. By typing on the keys between
1 and 8, the cursor changes one of the 8 colors printed on the bottom of each color key. All 16 colors can appear on the screen at the same time.
HOLD i# •■■■
WITH COLOR KEY
1
2
3
6
7
8
4
5
COLOR
RESULT
ORANGE
BROWN
YELLOW-GREEN
PINK
BLUE-GREEN
LIGHT BLUE
DARK BLUE
LIGHT GREEN
44
COLOR
AND
REVERSE
PRINTING
Your Plus/4 can display numbers, letters and graphic symbols in the 16 — different colors. You can also display these characters in reverse, wiih the primary (cursor) and background colors reversed
STEP1
STEP 2
Clear your screen by pressing
CLR'HOME
SHIFT and
Hold down the control key and press the rvs ON key rti
STEP 3
STEP 4
STEP 5
Release the keys and hold down the space bar (the long bar at the bottom of the keyboard).
Hold down the space bar as long as you want. While you hold down the space bar, a line the same color as the letters on your screen should get longer. If the line gets to the end of the row, it continues on the next row.
Release the space bar (but don't press the return key)
STEP 6 Hold down the CONTROL key and press one of
the color keys (not a color that's already on your screen)
As soon as you do this, the cursor will be the color of the key you pressed.
STEP 7 Hold the space bar down again. Now your Plus/4 wilt draw i me ii the new color Continue changing colors ■:. Eh ihe
CONTROL, or O keys and the color keys.
Then hold down the space bar to make different colored lines.
STEP 8 Turn off reverse print by holding down CONTROL
and pressing the RVS OFF key Pressing the
RETURN key also turns off reverse printing.
-'5
__
Try typing some letter in reverse. Just hold down CONTROL and
RVS ON to turn on reverse, and then type whatever you want. Reverse letters make excellent headlines You can also use them to highlight
45
~
46 special words and numbers. Try this:
PRINT" Q COMMODORE H PLUS/4"
t
Press CONTROL
and rvs on
\
\ Press CONTROL
and rvs off
Now try the same line, replacing reverse on and off with FLASH ON and OFF:
PRINT" || COMMODORE 5 PLUS/4"
t
Press CONTROL
and FLASH ON
\
\ Press CONTROL
and FLASH OFF
Both functions may also be used on the Plus/4 as part of a program statement.
SOME
SIMPLE
PLUS/4
PROGRAMS
Type this program exactly as it appears here. Don't leave out the numbers at the beginning of the line, since they are the line numbers that tell the order that the lines of the program are implemented by your computer. Be sure to press the RETURN key at the end of each line you type.
10PRINT"PLUS/4"
This line tells your computer to PRINT
Plus/4 on the screen.
_
20 GOTO 10
This line tells your computer to go back to line 10 and print
Plus/4 again.
RUN
This commands your computer to carry out what the 2 lines tell it to do.
Press the RUN/STOP key to stop the program.
Why did your Plus/4 print its name so many times? GOTO tells your computer to go back to line 10 and PRINT Plus/4 again and again.
This repetition is called a loop.
Now type this:
NEW RETURN
_
Here you tell the computer to forget the last program and get ready for a new one
The computer responds:
READY.
You DONT type this; your Plus/4 does to tell you it's READY fora new program.
47
n
-
-
10PRINT"PLUS14>
20 COLOR 0,12
Same line 10 as last time. PRINT tells your
Plus/4 to display everything between the quotes.
This command tells the computer to change the color of the screen.
RUN
This time there's no GOTO loop in the program, so your orders are carried out just once.
CORRECTING
TYPING
MISTAKES
If you make a mistake when you're typing, there are several ways to make changes.
1.
YOU CAN RETYPE A LINE anytime, even after you've RUN the program. The Plus/4 automatically replaces the old line with the new one when you press RETURN to enter the new line.
The old line still appears on the screen, but the Plus/4 ignores it.
When you have two statements with the same line number, your
Plus/4 uses only the last one entered. For example, in a brief program using the COLOR command to change the color of the screen background, a mistake might occur
10COKOR0.3
20 PRINT "PLUS/4" mistake
Press the return key to get to a fresh line, and just retype line
10 correctly:
10 COLOR 0,3 RETURN
Now the first line 10 is replaced by !he second line 10. You can check this by typing LIST, which displays a line-by-line LISTing of
48
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:
LIST RETURN
The screen reads:
10 COLOR 0,3
20 PRINT "PLUS/4"
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 the old line. For example, instead of correcting the spelling of COLOR, you can type this:
. space
10 PRINT "TEN IS SIX "
RETURN
Now RUN the program and see what happens.
2 YOU CAN ERASE AN UNWANTED LINE just by typing the number of the line and pressing return .The computer ignores the line even though it still appears on the screen.
Type LIST to get the program LISTing to make sure the line is gone from the program.
—
—
10 PRINT "TEN IS SIX"
20 PRINT "PLUS/4"
10
LIST
RETURN
RETURN
RETURN
RETURN
20 PRINT "PLUS/411 u
3 YOU CAN EDIT A LINE. Use the cursor keys to move to the place in the line that you want to change. Now just type over what you want — to change. Press return when you finish.
49
_
—
— n
—
—
—
NOTE: When working with numbered program lines, you don't have to be at the end of the line to press return .
Your Plus/4 remembers the whole line even if you press
RETURN in the middle of the line.
10 PRINT "IT IS ONE O'CLOCK"
If you want to change the time to TWO, move the cursor to the
0 in ONE.
10 PRINT "IT IS 0 NE O'CLOCK"
And now just type TWO over ONE and press RETURN
10 PRINT "IT IS TWO O'CLOCK" RETURN
NOTE: When you type a quotation mark after a PRINT statement, you enter QUOTE MODE. In quote mode, some keys work dif ferently. For example, if you press the cursor-down arrow while you're in quote mode, the cursor won't move and you'll see a reverse Q printed on the screen. When you run the PRINT state ment, the reverse Q isn't PRINTed; instead the cursor moves down. In quote mode, the computer assumes that everything you type is something you want to display or do later when you execute the PRINT statement.
4.
YOU CAN OPEN UP SPACES IN A WORD OR LINE with the inst key (get this insert key by holding down shift while you press inst/del ). 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 to the right.) Then just type what you want to insert.
10 PRINT "CORE" RETURN
To change this to COMMODORE-Plus/4, move the cursor to the hyphen between the C and the 0 and press the shift and
INST keys until enough space opens up. Don't bother to count out the spaces. You can just guess and then open up more if there aren't enough.
10 PRINT "C ■ORE"
"*
Now add the other letters:
cursor
10 PRINT "COMMODORE" RETURN
5.
YOU CAN ERASE CHARACTERS AND CLOSE UP SPACE with the DEL key (get this delete key by pressing
INST/DEL ). This key erases characters or spaces immediately to the LEFT of the cursor.
10 PRINT "AFTERNOON SCHEDULE" RETURN
You can change this to WEEKLY SCHEDULE by moving the cursor to the E in AFTERNOON, pressing the INST/DEL key three times, and typing WEEKLY-
10 PRINT "AFT Q RNOON SCHEDULE"
and press INST/del three times.
10 PRINT" Q RNOON SCHEDULE"
Type in WEEKLY to replace ERNOON
and press RETURN
fa Now that you've experimented a little with your Plus/4, here's a pro-
Little 9ram t0 trVthat w'"take a littie lon9er t0 type in. (Any experienced
I nnnor programmer will tell you that, if nothing else, programming can help
Lunger yOU really improve your typing.)
Program
First, clear the screen by holding down the SHIFT key while you press the CLR/HOME key. This erases your screen.
Then, clear out old programs from memory by typing NEW and pressing RETURN .
Type in this program exactly as i! appears. Remember to type in the line numbers and all punctuation marks. Use the tips for correcting mistakes if you type something incorrectly. Don't forget to press
RETURN after each line.
NOT! Remember, you can stop a progi in by pressing the
RUN/STOP key.
—.
—
_^
—
—■
—
—'<
51
~ n
NEW
10 COLOR 1,8
20 PRINT "A FUNNY THING HAPPENED
30 COLOR 1,3
Be sure to leave a space here
40 PRINT "ON MY WAY TO THE KEYBOARD
50 COLOR 1,7 t
Be sure to leave a space here
60 PRINT"
70 GOTO 60
Get the hearts by holding down
SHIFT while you press the S key 6 times
RUN
After you STOP the program {by pressing the RUN/STOP key), try typing LIST. When the program is displayed on your screen, recall the tips for correcting errors and try changing this program to make it say something more profound.
TIP: Want to slow down this program without stopping it? Just hold down the .h^S key.
THE Try typing this program. (Don't forget to press RETURN after entering
PLUS/4 eachline-)
TEXT
SCREEN
NEW
10 PRINT" press andS
SHIFT
52
20 GOTO 10
RUN
Now your screen fills with hearts. When the entire screen is covered with hearts, press the RUN/STOP key to end the program.
This program shows you how hig your Pius/4's screen is.
Now type this program
NEW
10 PRINT" press shift and clr/home
20FORX= 1TO40 press SHIFT and S
30 PRINT" ¥ ";
40 NEXT X
RUN
When you RUN this program, the first row on your screen fills completely with hearts. There are 40 hearts altogether, Since the row is full, you can see that there are 40 positions across the screen. Each position across the screen is called a COLUMN.
Now type this program:
NEW
10 PRINT" press shift and clr/home
20 FOR X - 1 TO 25
30 PRINT "♦
40 NEXTX press shift and Z
RUN
When you run this program, the first column on your screen fills with diamonds. There are 25 diamonds printed, but the first three disappear al the top of the screen because the word READY surrounded by two blank lines always appears at the end of the program. There are, then,
25 rows. A little deductive logic tells you that your Plus/4 has 40 col umns and 25 rows. The Plus/4 has 1000 different positions on the screen for letters, numbers, graphic symbols, etc.
NOTE: Sometimes you'll type a particularly long line on your
Plus/4, such as this:
10 PRINT "I LIKE YOUR TOUCH ON MY KEYBOARD. DO YOU
COME HERE OFTEN?'1'
(Thai's quite a line—over 50 characters long!)
You'll notice that as you type this, you run out of room on one row.
But keep typing; the Plus/4 automatically moves on to the next row and continues printing there until your line is finished. You can type as many as 80 characters on one program line {up to two full rows).
Now try RUNning this one line program. The message is printed on two rows. If your line is longer than one row, the Plus/4 lets it spill over to the next row. The Plus/4 considers the line ended when you press the RETURN key. not when you type to the end of the row.
You'll get used to this as you use your Plus/4.
Now type this program:
NEW leave a space on each side of the heart
10 PRINT1' ¥
20 GOTO 10
RUN press andS shift
When you RUN this program, you can see that it's possible to tell the
Plus/4 exactly where to PRINT something on the screen.
SCREEN
WINDOWS
COMMDOBE BI1S1C U3 •> MIP.VI BYItS
Ni
■ fl
....
SPM II II imUf (in i"'
At[n i>
.' i -
Windows let you define a specific area of the screen as your workspace. Everything you type (lines you type. LISTings of pro grams, etc.) after setting a window appears within the window's boundaries, not affecting the screen outside the window area.
You can set up a window anywhere on the screen.
1
To set a window, follow these sleps
Move the cursor to the screen position you want as the top left corner of the window.
2.
Press the ESCape Key. and then the letter T.
3 Move the cursor to the position you want to be the bottom right corner of Ihe window.
4 Press ESCape, followed by B. Your window is now set.
AN screen output is confined to the 'oox' you have defined. To cancel the window, press the home key twice. The window is then erased, and the cursor is positioned in the top left corner of the screen
J
57
n n
CHAPTER
NUMBERS
AND CALCULATIONS
Numbers and basic operators
Performing calculations
Using variables
Immediate mode
Numeric functions
Random numbers and other functions
58
NUMBERS
AND
BASIC
OPERATORS
You can use your Plus/4 like a simple calculator Besides the standard
+ and - signs, your Plus/4 uses the 'sign for multiplication and the / sign for division and fractions. (Computers use the * sign instead of an
X (or multiplication because a computer can't tell the difference be tween the letter X and the mathematical symbol x.) You can use these operators and numbers in direct mode (no line numbers) or in a pro gram. Neither numbers or operators should be in quotes for your Plus/4 to perform mathematical operations.
BASIC MATHEMATICAL
OPERATORS
Addition
Subtraction
Division and fractions
Multiplication
Exponentiation
+
-
/
*
BASIC RELATIONAL
OPERATORS
Greater lhan
Less than
Equals
Greater than or equal
Less than or equal
Not equal to
>
<
=
=>
< = oorx
NOTE; Your Plus/4 doesn't accept commas as part of a number.
For example, you must type 109401 instead of 109,401. If you put a comma in a number, your Plus/4 thinks you mean two numbers
(separated by the comma), so your Plus/4 would read 109 and
401 instead of 109401.
FRACTIONS
AND
DECIMALS
You can write a fraction like this: .5
or like this: V2 Your Plus/4 is actually performing the division
If you put a fraction in a PRINT statement, your answer is always returned as a decimal or whole number. For example:
PRINT 139 493
5.28194726
RETURN
Here's an example that uses pi (3.14159256...), which represents the ratio of the circumference of a circle to its diameter. Use this value by just pressing the 77 key
PRINT 77, 374
B.39998036E-03
RETURN
59
_J
SCIENTIFIC
NOTATION
What did your Plus/4 mean by the E-03 part of the above answer?
Your Plus-4 displays decimal numbers in the range -999.999.99910
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 Plus/4 will read them with no trouble (certainly less trouble than you had converting them}. Scientific notation is often useful, since this special notation lets your Plus/4 display large numbers in fewer digits.
Here is how the number 198.505.478 would be written in scientific notation
Only ONE digit is shown to the left of the decimal point
1 98505478E
This number is the number of digit places the decimal point is moved
For a number less than one with several decimal places, the second number would be a - instead of a +, indicating that the decimal point is moved to 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 To P^orm a calculation type PRINT and then the math problem.
CALCULATIONS Remerntjer not t0 Put tne problem in quotes.
Type this program:
NEW
10 PRINT 1^2. 2-1
20 PRINT 2 2, 4/2
RUN
3
4
1
2 use the slash on the 9 kev
For the first time. PRINT didn't print exactly what you typed in the statement. Instead, your Plus'4 solved the calculations and PRINTed the answers. All you have to do to use PRINT to calculate is omit the quotation marks. Now try this.
NEW
10PRINT"2001'20l0"
20 PRINT 2 h 3
RUN
2001 2010
6 one space is left for the answers sign u
Since the calculation in line 10 is in quotes, your Plus*'4 just PRINTs the problem as if it were regular text" exactly as it appears between the quotation marks. The problem isn't solved, and no space is left for the sign of the number
Now move the cursor back to line 10 and change the line to (his
3-1
I—
RUN
2 3-1 = don't forget the semicolon this space is left for the answer's sign the answer for line 20 stays the same
If you want lo both PRINT the problem AND solve it you have to type twice once in quotes and once out of quotes, like this1
61
n
IMMEDIATE You can Put any calculation in a program, or get an immediate answer
MODE Dy 'yPin9 PRINT and the problem without a line number and pressing
RETURN, like this:
PRINT 3-6
3
PRINT 24/(6
3
■2)
With numbers as well as with commands and text, when you don't have a line number before a BASIC statement, you don't have to type RUN to tell the computer to fohow the instruction; it's in IMMEDIATE, or DIRECT
MODE. Having a line number means the statement is part of a BASIC program; it's in PROGRAM MODE. Either way is acceptable.
You can also include both a text statement in quotation marks and a mathematical problem to be solved in a single PRINT statement in immediate mode.
PRINT "2 TO THE 3RD POWER
EQUALS";2I3 this arrow stands for exponentiation, get it by typing SHIFT andO
2 TO THE 3RD POWER EQUALS 8 the message is
PRINTed and then the problems solu tion is PRINTed
ORDER T(ie second example in the last section shows that you can perform
fie more than one calculation in one line. Try typing this
CALCULATION PRINT200+50/B
Is the answer what you expected? Try this
PRINT (200-50) 5
Your PlusM always performs calculations in a certain order. Problems are solved from left to right; within that general rule, some types of calculations are solved first. The order which your Plus/4 evaluates expressions is called the order of precedence of operators.
FIRST Your Plus/4 checks for negative numbers (not subtraction, just negative numbers).
SECOND Your Plus/4 solves any exponents
THIRD: Your Plus/4 solves all multiplications and divisions, from left to right.
FOURTH Your Plus/4 solves additions and subiractions. from left to right
NOTE: Your Plus/4 always solves any portion of the problem surrounded by parentheses first. You can even put parentheses within parentheses: 36* (12 + (A/ 3)). The contents of the inner most parentheses are solved first.
Sometimes it's a good idea to put negative numbers in parentheses for clarity. For example, if you want to multiply 45 by - 5. type it like this
45*:(-5). Your Plus/4 can understand with or without parentheses.
_
63
_
p^
_
___
—
—
USING The example 36*(12+(AZ3)) shows one of the most powerful features
VARIABLES of a comPuter When we used a letter instead of a number in a mathe
matical problem, we used a VARIABLE. A variable represents a value.
10A = 3
20 PRINT "TOTAL:";A * 4
If you RUN this program, the screen result is:
TOTAL 12
There are three types of variables you can use
TYPE
Floating point
Integer
Text string
SYMBOL DESCRIPTION real (decimal) or whole numbers
SAMPLE
EXAMPLES VALUES
X. AB. T4 23.5, 12,
1.3E + 2
7o s whole numbers letters, numbers, and all olher characters in quotes
X%, Al%
X$, MS$
15, 102.3
'TOTAL:-.
"DAYIVCBM"
Every time you want a variable to be an integer variable, the symbol for that variable would include the % sign. A variable that contains text
MUST end with a S as part of the variable. If it doesn't have that symbol, your Plus/4 considers it a floating point number. A variable without either of the symbols (% or $) is read as a floating point number (a
"regular" number). Integer variables are a subset of floating point vari ables; they are numbers with no decimal places
Always use the right 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 out what happens when you try out different types of data.
10 REM THIS PROGRAM NEEDS NUMERIC DATA
20 PRINT "ENTER A NUMBER"
30 INPUT x% —
■
I this is the variable
to be input
40 PRINT "NICE GOING, ACE! "
50 PRINT "I READ YOUR NUMBER AS"; X%
Try to enter these values and see what happens:
ONE FIFTH
.043
10
64™
NUMERIC Included in your Plus/4 BASIC 3.5 language are numeric functions.
FUNCTIONS wn'cn are like lne advanced calculations found on most scientific cal
culators (such as sine, cosine, tangent, etc )
Most of the functions can be used by typing the name of the function and the number to be operated by the formula in parentheses, like this.
FUNCTION(X)
For example, to find out the sine of a variable, you would type
PRINT SIN(X) with X as any number you want to input
You could also include one of the functions in a program line, as the following example shows.
10FORX=lTO5
20 PRINT "THE SQUARE ROOT OF": X;"IS"; SQR(X)
30 NEXT X
There is a complete listing of the numeric functions in the BASIC 3.5
Encyclopedia. Some of the more complex functions are explained in the following paragraphs.
RANDOM
NUMBERS
AND
OTHER
FUNCTION
Selecting a random number is Itke taking 10 pieces of paper, writing a number from 1 to 10 on each piece and putting the 10 pieces of paper into a hat and drawing one piece of paper. The number chosen is a
RANDOM number. The number is put back into the hat. and another number is drawn. Each time a number is drawn, it is put back in the hat.
keeping the pool of possible numbers the same. When a number is selected, there is no way of knowing what number is going to come up next, but you do know that the number will be between 1 and 10 This is the basis of RANDOM NUMBERS
._
Random numbers are extremely useful in programming, providing the element of chance or (obviously) randomness. Random numbers usu ally have a range, meaning theres an upper limit and a lower limit to the numbers you can draw. In the hat example, the range of numbers is
1 to 10. The lower limit is "1" and the upper limit is "10", which means that any number from 1 to 10 can come up randomly each time a new number is selected.
65
-
Lets examine how your Plus/4 handles random numbers, and some of the things you can do with them This program generates five com pletely random numbers
10 FOR X- 1 TO 5:PRINT RND(X):NEXT X
These random numbers are all rather complex, with several p;aces on the right side of the decimal point... but most uses for random numbers require whole numbers You can make your numbers come out as whole numbers (without decimal places) by using the INTeger function, which cuts off all the digits on the right side of the decimal point. The following gives you a formula for generating random num bers in any range you want. You can use this formula almost anywhere you would use a variable or number in your program,
INT(range" RND(l)) lower limit
The INT command tells the computer to cut off any decimal places and only give you whole numbers like 1, 45. or 320, instead of numbers like
1.223, 45,6677, or 320.59. Whole numbers are easier to work with when using random numbers.
Lower Limit in the formula refers to Ihe lowest number you want the computer to choose from.
Range is how many numbers are in the total group.
For example, if you want to choose a random number from 1 to 5.
Ihe lower limit is 1 and the range is 5. If you want to choose a random number from 15 to 20. the lower limit would be 15 and the range is 6.
because you are choosing from a pool of 6 numbers. If you're choosing numbers from 2 to 100. the lower limit is 2 and the range is 99. Now let's try out a program:
10 PRINT INT(5"RND(1)) - 1
Type RUN and press return RUN the program a few times
Each lime you run the program, you get a random number from 1 to 5.
Now let's onnt 15 random numbers, with the lower limit 1 and the range
5 note that all 15 numbers chosen are selected at random from between 1 and 5 n.
10 FOR X- 1 TO 15
20 PRINT INT(5'RND(1)) - 1
30 NEXT X sets loop for 15 times
_.
selects RaNDom number
Type RUN and press RETURN
An effective way lo use this formula is to make it into a user defined
function. User defined functions are extremely useful in mathematical calculations, and extremely easy to implement using your Plus/4 User defined functions allow you to program a formula, and then let your
Plus/4 plug in values to be calculated This can be used for many dif ferent purposes. Section 10 of the Encyclopedia section contains a listing of mathematical function derivatives which can be used to define functions.
Here is a statement utilizing the user defined function for generating random numbers
~~
fcj
—
—
10DEFFNR(X) = INT<X"RND(l)) + 1
This gives us random numbers in the range from 1 to X. FNR is the name of the function defined by this statement.
EXAMPLE using a defined function:
■-—
10DEFFNR(X) = INT(X'RND(l)) + 1
20 DO
30 COLOR 1, FNR(16), 5: REM PICK A COLOR FROM 1 TO 16
40 PRINT "THE SEARCH GOES ON"
50 LOOP
Using the defined function saves memory space when you use the function more than once, and makes your programs easier to read and understand.
"—'
—
67 —
n
-
—
"1
H
CHAPTER 6
BEGINNING
BASIC
PROGRAMMING
• Introduction
► Programming modes
» Input/Output statements
t
» Control statements and loops
*
» Conditional statements
> Subroutines
► REMarks
68
Up until now, you may or may not have understood exactly what was going on in the programs that introduced you to some of the capabili ties of your Plus/4. This chapterwill explain some of the BASIC com mands that were used in those programs. This chapter focuses on some of the more often used BASIC statements that you will need to construct your own programs. At the end of this chapter we will touch on some programming techniques. This chapterwill give you a quick introduction to programming, but il is still an introduction. To really learn to program, we suggest you pick up a good book on BASIC at your local bookstore. (See the bibliography in Section 14 of the Ency clopedia for suggestions.) There are many versions of BASIC, each a little different. Your Plus/4 is equipped with an advanced version of the
BASIC language called Commodore BASIC 3.5.
.-
_
__
69
PROGRAMMING Your Plus,4 gives you two ways to use BASIC staiements and
MODES commands, in direct mode and indirect mode Direct mode is often referred to as immediate mode, and indirect mode is also known as program mode.
DIRECT, or IMMEDIATE MODE, as the name implies, executes state ments and commands immediately (as soon as you press RETURN y after typing in a command). You do not type line numbers when using commands or statements in direct mode. You omy type the command or statement and press the RETURN key. This mode is used if you want your computer to perform calculations and give you an immediate result. Commands such as LIST, SAVE, LOAD, VERIFY and RUN are usually used in direct node Most (but not all) BASIC statements work in direct mode.
INDIRECT, or PROGRAM MODE, allows you to organize a series of
BASIC statements into a set of instructions that will be performed in ihe order that you decide. Each of the lines in the program has a line number which tells the computer to execute the lines in a certain order. You ve already seen several examples of program mode in
Chapter 4 Remember that when you use program mode, you must press RETURN to enter each line of the program into the mem ory of your Plus/4, if you don t press RETURN , and just go to the next line, the line you typed has not been entered. Once the program is in memory, nothing will happen until you enter the RUN command.
The RUN command te'is the Plus/4 to execute the program starting with the lowest numbered line.
Lines are most often numbered by tens, since you II frequently have to add lines in different places in the process of writing a program.
You could, if need be, add nine new lines between line 10 and line
20 in a program. However, your Plus/4 features a BASIC command,
RENUMBER, that allows you to add new lines and change the existing line numbers. This saves a lot of confusion that often occurs when changing and rearranging lines
70
INPUT/OUTPUT
STATEMENTS
Input/Output (I/O) statements are used in programs to communicate with the person RUNning the program. Before the program is run. if all the data for the calculations is available, there is really little need for input statements. It is often more useful if the computer can get data from the person RUNning the program (we'll call him or her the pro gram user). Programs are much more versatile if the data is not "set in stone" before running them. Output statements can be used by the computer to tell the person running the program the answers that the computer has calculated. Obviously, output statements are vital; there would be little sense in RUNning a program that had no output state* ments. {Kind of like a tree falling in a forest with no one around to hear; does it make a sound? Does it matter?)
Advanced programmers also use I'O statements to communicate with devices instead of with the program user. You've probably done this yourself, but not in a program—when you used LOAD or SAVE with your
Datassette or Disk drive. LOAD is basically an input statement since the Plus 4 gets data (your program) from your Datassette or disk drive while SAVE is an output statement, as the PI us'4 sends data to those devices.
In this introduction to I/O statements, we will limit ourselves to a few of the most important ones, the ones that you'll need immediately.
They are. PRINT. INPUT, GETKEY, and READ, DATA. PRINT is an output statement, while the others are input statements
(Remember that all BASIC 1,0 statements can be found in the BASIC
Encyclopedia at the end of this book.)
_
Statement name: PRINT
Format. PRINT "text in quotes' or calculations, etc.
or variables or numbers
You have used the PRINT statement often in programs in earlier chap ters. From that, and from the format example above, you can see that
PRINT is a very versatile statement. You can use it to PRINT out mes sages, pictures made out of graphic characters, perform calculations, display the value of a variable, and more. Since the PRINT statement is used so often, it pays lo learn to use it well.
_
Use#1 Text Display
Suppose in your program, you want to inform the user that his or her checking account balance is negative, or that purple lizards are
■■
—
— not allowed in the controf room. The easiest way would be to PRINT your statement as a text string. Text strings are printed out exactly as you type them in. They must be surrounded by double quotes ("").
For example
100 PRINT "YOU ARE BROKE!" would tell the user that there is no money left, while
150 PRINT "YOU CAN'T BRING YOUR FRIEND INTO THE
CONTROLROOM" could be used in the second example.
Whatever appears between the quotation marks is known as a literal, because it is PRINTed exactly as it appears. It doesn't matter whether it is words, letters, numbers, punctuation marks, etc.
Certain keys, like the cursor and color keys, act differently when used
in text strings. Instead of changing the color or moving the cursor when you type the key, a reverse character is printed in the string. When the program is RUN. the character is translated into what you wanted typed in the first place. This lets you clear the screen, change the color your are PRINTing in, move the cursor, all within your program. For example, try this:
10 PRINT" SHIFT CLR'HOME
CONTROL 7
CONTROL 3
TESTING''
TESTING.
Remember to type the following keys simultaneously when you use the SHIFT and CONTROL keys. The reversed symbols are the signals to [he computer that tells it to perform the dear screen, color change or move the cursor.
Use #2 Printing Numbers and Calculations
PRINT can display the answer to a calculation made within the print statement. (SEE NUMBERS and CALCULATIONS). The Plus/4 per forms the operations needed to gel the answer, then displays it on the screen For example.
100 PRINT 58*15,23,45-1-100O-45*(4-3) prints
870 23 1000
72
This gets more interesting when variables are also used. User input can be displayed, and earlier calculations saved in variables can also be PRINTed out, or even used in additional calculations.
Examples
TYPE
—i
— 10R-10 ' 2: N = R 5
20 PRINT "RIS ";R;" AND N IS ";N
30 PRINT "BUT R TIMES 2 IS";R*2
40 PRINT "AND N MINUS 2 IS";N-2
Normally, after each PRINT statement, the cursor automatically goes to the beginning of the next line You can override Ihis by putting a semicolon (:) after the PRINT statement like this
__
—
200 PRINT 'THESE TWO SENTENCE PARTS WILL BE ";
210 PRINT "PRINTED ON THE SAME LINE"
—j
■•■,.:,-,,..,: n.tirit- INPUT —*
Format INPUT "optional message variable to be input
The INPUT statement lets you get data from the program user through the keyboard, and use it in the program. The optional message lets you tell the user exactly what you are asking for; the message is printed when the INPUT statement is executed, along with a question mark
Then the Plus 4 waits for the user to type an answer, followed by press- — ing the RETURN key The input from the user is placed in a variable You can either get a string from the user by using a string variable (AS, for example), or a number by using a numeric variable
The INPUT statement can only be used in program mode
Examples:
TYPE
10 PRINT "WHAT IS YOUR NAME";
20 INPUT AS
30 PRINT "I AM PLEASED TO MEET YOU"; AS;".11
40 INPUT'HOW OLD ARE YOU";AG
50 PRINT AG; " IS A BIT OLDER THAN I AM."
RUN
—
__
—
—
73'
—
_
__
Statement name: GETKEY
Format GETKEY variable to be input
GETKEY is another way for you to enter data while the program is being RUN. The GETKEY statement accepts only one key at a time. Whatever key is pressed is assigned to the string variable you specified in the GET statement (AS, for example). GETKEY is useful because it allows you to enter data one character at a time without having to press the RETURN key after each character.
The GETKEY statement may only be used in a program.
Example of GETKEY in a program:
1000 PRINT "PLEASE CHOOSE A, B, C, D, E, OR F"
1010 GETKEY A$
Statement Name READ'DATA
Format: READ variables to be input
DATA data items to be read
The READ/DATA statements are used as a convenient way to assign values to variables. You can think of the READ statement as an INPUT statement that asks the Plus/4 for the data, rather than the user The data is (naturally enough) kept in DATA statements. When the Plus/4 executes a READ statement, it looks at the next data item in the DATA statement, and assigns it to the variable in the READ statement.
The READ statement is always used with a DATA statement. A DATA statement is just a line of data (words or numbers) in a program. The
READ statement is used to assign those values to variables (For each variable listed in the READ statement, your Plus/4 "reads" a value from the DATA line for that variable.) A DATA statement is not executable and can appear anywhere in the program. The thing to remember about the READ statement is that the variable type must be the same as the type of data available in the DATA statement (number variables for numbers, text variables for text). Otherwise, a TYPE MISMATCH
ERROR occurs.
Example.
10READA$.B$,C$,D$,E$
20 PRINT A$:PRINT B$:PRINT C$
30 PRINT D$: PRINT E$
40 DATA GROUCHO, HARPO, CHICO
50 DATA ZEPPO, GUMMO
The computer responds with:
GROUCHO
HARPO
CHICO
ZEPPO
GUMMO
-
:
75—
n
~
~
CONTROL
STATEMENTS
AND
LOOPS
It would be pretty boring if your computer could only execute program lines in order. The computer could only star! at the beginning and go through each step in order until the end of the program. This would lead lo very long programs; if you wanted to do the same thing twice
(like PRINT "HELLO"), you would have lo duplicate the program lines.
With a small example like PRINTing HELLO, this doesn't make a lot of difference, but it could become difficult in larger programs. This is why computers have control statements. Control statements tell the com puter to ignore the normal order of the program lines, and go to another line regardless of the sequence. The Plus/4 has several varieties of control statements, unconditional (like GOTO) which always transfer control; counting statements (like FOR/NEXT} which transfer control a specified number of times; and, for you structured programming fans out there, DO/LOOP.
Statement Name: GOTO
Format.GOTO line #
GOTO tells your computer to immediately go from the current line in your program to the line number specified in the GOTO statement.
For example, if line 20 reads GOTO 40. your Plus/4 would jump to line 40, skipping any statements between 20 and 40.
Example using GOTO statement in a program.
TYPE:
10 PRINT "A PENNY SAVED IS BETTER THAN NOTHING"
20 GOTO 10
The computer responds by printing the message in line 10 again and again, until you press the STOP key, like this:
A PENNY SAVED IS BETTER THAN NOTHING
A PENNY SAVED IS BETTER THAN NOTHING
A PENNY SAVED IS BETTER THAN NOTHING
BREAK IN 10
READY.
If you press the
STOP key
This print statement will continue 'forever1. Every time your Plus/4 gets to the GOTO in line 20 it goes back to line 10. This is called an INFINITE
76
LOOP in computerese. While you might want to do this, usually you want to repeat only a certain number of times, or until something hap pens That is why the FOR/NEXT and DO/LOOP statements are avail able in BASIC
GOTO can also be used in direct mode. GOTO line # will start the program at the line you specify, while keeping the variables the same
(instead of clearing them as RUN does).
Statement Name FOR NEXT
Format FOR variable = start value TO end value some BASIC statements
NEXT variable
The FOR'NEXT statements let you create a loop that will repeat a certain number of times The program statements between the FOR statemenl and the matching NEXT statement are repeated in the loop
The variable in the FOR statement acts as a counter It is initially set at the start value you supply. Then, the program lines after the FOR are executed, until the computer gets to the matching NEXT statement.
The NEXT tells your Plus/4 to add one to the counter. If the counter is less than or equal to the end value, ihe computer returns to the pro gram line after the FOR statement. Otherwise, your Plus/4 continues with the first statemenl after the NEXT
Example using a FOR'NEXT loop
10 PRINT."COUNTUP..."
20 FOR J - 1 TO 10
30 PRINT "WE HAVE";J
40 NEXTJ
50 PRINT "WE COUNTED UP TO";J
One more thing about FOR'NEXT you can also specify a STEP value in the FOR statement. Instead of adding 1 to the counter variable, your
Plus/4 adds your STEP value. If you use a STEP of 5 with the statement
FOR M - 10 TO 30, for example, the counter would count 10, 15, 20,
25, 30 after each loop The STEP command even lets you count back wards (by using a negative STEP value).
77
—
—
—
—
—
H
Another example, with a negative STEP
10 PRINT "COUNTDOWN..."
20 FOR J = 10 TO 0 STEP 1
30 PRINT "WE ARE AT";J
40 NEXTJ
50 PRINT "WE HAVE LIFT-OFF AT" ; J
Statement Name: DO UNTIL/WHILE... LOOP UNTIL/WHILE
Format: DO UNTIL [conditionl WHILE [condition] some BASIC statements
I EXIT]
LOOP UNTIL {condition] WHILE [condition]
The DO, LOOP statement combination is another way to create a loop. This statement combination is very powerful and versatile. The
DO.'LOOP method of loops is a common technique of structured programming languages. In this chapter we'll discuss just a few possible uses.
If you want to create an infinite loop, just start a section of program lines with DO, and end it with a LOOP statement, like this
100 DO: PRINT "GOING UP"
110 LOOP
Press the STOP key to end the program.
A more useful form is to combine the DO; LOOP with the UNTIL statement. The loop will run continually unless the condition for
UNTIL happens.
100 DO: INPUT "DO YOU LIKE YOUR COMPUTER'1 ;A$
110 LOOP UNTIL A$="YES"
120 PRINT "THANK YOU"
For the other ways you can use the DO; LOOP, seethe BASIC
Encyclopedia at the end of this book
78
CONDITIONAL
OR
DECISION
MAKING
STATEMENTS
Conditional statements are used to make decisions. One of the most powerful abilities of a computer is to make decisions based on what is going on. One of the conditional statements available on Ihe Plus-4 is known as IF'THEN statements,
Statement Name: IF/THEN
—
Format: IF condition THEN do this (only if the condition is true)
Basically, the IF'THEN statement works like this.
IF (this statement is true) THEN (do this statement)
Actually, you have always known how conditional statements work
How many times have you heard this famous line9
_
IF you eat all your vegetables THEN you can have dessert That may seem a bit trivial, but that is the gist of the IF;THEN statement.
If the condition in the IF statement is true, everything after the THEN is executed.
EXAMPLE.
10 INPUT'WHAT'S THE TENTH LETTER OF THE ALPHABET"; AS"
20 IF AS^-J11 THEN PRINT "RIGHT": GOTO 100
30 INPUT "IS THIS AN A";X$
40IFXS = "A"THEN60
50 PRINT "WRONG, TRY AGAIN": GOTO 30
60 PRINT"TYPE AB"
70 GETKEYA$:IFA$ = "B"THEN PRINT "RIGHT"
100 PRINT "THAT'S ENOUGH OF THIS, ANYWAY"
—
In line 40, we just say THEN 60. This actually means THEN GOTO 60. j
but since the THEN GOTO combination is used so often, BASIC allows you to leave off the GOTO. An optional step for the IF'THEN statement is the ELSE clause, that directs your computer to a specific action if the original IF condition was not met- An example showing the ELSE clause would be: IF B > 5 THEN 40 ELSE GOTO 10. The BASIC Ency- clopedia explains the IF/THEN/ELSE statement more fully.
7&-
SUBROUTINES lf y°u have something in your program that has to be repeated in more
than one place in your program, you have two choices: you can have duplicate routines, or you can create a subroutine. A subroutine is a section of your program that can be used from anywhere else in your program When the subroutine is finished, the program automatically continues at the statement just after where the subroutine was called.
Statement Name- GOSUB/RETURN
Format:GOSUBIine #
The GOSUB statement is used to call a subroutine. Like the GOTO statement, control is transferred to the line number specified in the statement However, unlike the GOTO, the Plus/4 remembers where the GOSUB is located. When a RETURN is next encountered, control returns to just after the GOSUB statement.
Example
5T = 0:FORJ = 1 TO 99
10 PRINT "GIVE ME A NUMBER FROM 1 TO 10"
20 INPUT N
30IFN- 1 THEN GOSUB 100:GOTO 20
40IFN 10 THEN GOSUB 100:GOTO 20
50T = T + N
60 NEXTJ
70 PRINT "THE TOTAL IS"J
80 END
100 PRINT "THAT NUMBER IS OUT OF RANGE"
105 PRINT "PLEASE TYPE A NUMBER BETWEEN 1 AND 10
110 RETURN
If a RETURN is encountered when there are no active GOSUBs, you get a RETURN WITHOUT GOSUB ERROR You should be careful that the computer never gets into one of your subroutines except by GOTO.
One method is to group the GOSUB and GOTO statements together, protected from normal program execution by an END statement.
Statement Name REM
Format REM message
The REM statement is used to comment (or REMark) on your pro grams. The REM statement is not executed as part of the program; it is
80
a message that can be seen only when looking over the LISTing of a program. Often, if you don't comment, six months after you write the program you might forget what some part does. You can use REM statements to put in reminders, so you can more easily figure out what — you really meant, or give others information with your messages.
Example:
1560 E= R/I"9:REM THIS FIGURES OUT APITCHER'S ERA
100 INPUT A, B: REM A IS HEIGHT IN INCHES AND B IS WEIGHT
81
-
SUMMARY As we REMarked in the introduction, this would not be a complete tuto
rial on BASIC. We just gave you some of the BASICs. Every BASIC command in the Plus/4 is in the BASIC Encyclopedia, with format, description, and examples. Don't be afraid to experiment. If you are serious about learning BASIC, get some of the books on BASIC pro gramming listed in the Section 14 of the Encyclopedia. Programming is like eating salted peanuts: once you start, you may not be able to stop.
82
n
-
~
"I
CHAPTER 7
USING
GRAPHICS
AND
COLOR
Graphics characters
Character animation
Controlling colors
High resolution graphics
Points, lines, and labels
Squares, circles, polygons, and painting
Multi-color graphics
83
GRAPHICS Eacn le!ter key contains 2 different graphic characters, as do the @.
.
CHARACTERS "■ ancl ^nRl!si?. PQur|d keys. To print graphics characters, you must hold
down the SHIFT or C* ^eys while you press the key tor the graphics symbol you want.
/.■ e* /(■..■ Plus A • ippei c i: e y;r.: hies mode, h Id ;.■
SHIFT and press a letter key to display 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 let you draw many different pictures on your screen.
Here are some examples to help you get used to these characters,
Exercise 1: Large Circle
Step 1
2
3
4
5
Press down the SHIFT LOCK key
Press the letter U then the letter I
Press the RETURN key.
Press the letter J then the letter K.
Press ihc
Exercise 2: Snake
RETURN key.
Step 1
2
3
4
5
Press down the shift lock key
Press U. then I, then U. ther i, then U. then I.
Press the return Key.
P-ess K. then J, then K, then J, then K. then J
Press the RETURN key
Exercise 3: Crooked Line
Step 1 Press down the SHIFT LOCK key
2: Press E, then D, then C, then *, then F, then R.
3 Press the RETURN key
Exercise 4: Two Crosses
Step 1 ■ Press down the SHIFT LOCK key
2: Press M. then SPACE, then N. then SPACE, then -
6
7
3
4.
5.
Press the RETURN key.
Press SPACE, then V, then SPACE, then '.then +,
Press the RETURN key.
Press N, then SPACE, then M, then SPACE, then -
Press the RETURN key.
then u
-
-
-
_
84
When you are finished, press shift lock again so it pops up.
Did you wonder why the computer doesn't say SYNTAX ERROR when you hit RETURN 9 After all, you had characters on the line that weren't commands that the computer can understand.
The reason is that the Plus 4 doesn't pay attention to the line you typed if you hold down SHIFT wher you press RETURN, If you press return without the SHIFT key, the computer tries to figure out
.'.■,;■ .o . ■■ ■■ :■ /.he1 . >u re us1 ira*vn : picl res
So far we haven't talked about the graphics characters on the left side of the keys. These graphics work just like the right side characters, ex cept that you hold down the . O key instead of SHIFT There is no <£ lock, so you must hold it down yourself.
You can print this set of graphics in either upper-case/graphics mode or upper'lower-case mode. They are always available.
The left side graphics characters include lines and angles used for draw ing charts and tables. For example, here's how to underline a word-
First, move the cursor to Ihe line below the word you want to underline.
Then hold down the S 0^. key and the T key, which prints an under
line graphic. Hold these two keys down until the word is underlined.
Exercise 5: Half Bar
Step 1; Hold down the CE exercise.
key with one hand during the whole
2 Press D, then I, then I, then F.
3: Press Ihe _RETU8N_key.
_
Exercise 6: Wedge
Step 1: Hold down the 0= key and hit I then Y, then U
2: Hold down the CONTROL key and hit 9.
3: Hold down the O key and hit I, then 0, then P, then @,
then SPACE
4: Press the RETURN key
85
Exercise 7: Window
Step 1: Hold down the 0= key until step 4.
2: Press A, then R, then S, then RETURN.
3: Press Q.
4: Let go of 0= (its OK, honest).
5 Hold down SHIFT and hit+.
6.
Let go of SHIFT and hold down & again. Don't let
7: goof it any more.
Press W, then RETURN .
8: Press Z, then E, then X, then RETURN
The purpose of these exercises is to show you how the graphic symbols of the Plus/4 can be manipulated to create different shapes and figures. These are only a handful of the figures and representations you can develop. Now that you have a good idea of what is involved in using the graphic symbols to build different forms, you should experi ment with them yourself, and see what you come up with.
—
—
,
B6
CHARACTER Movies are really a sequence of still pictures. Each picture is a little
ANIMATION different from the one tnat came before. The projector shows each
picture for a very short time, then goes on to the next one. The scene
becomes animated.
Computer animation works the same way. First the computer draws
one picture, then it changes the picture slightly. The Plus/4 is fast enough to allow objects to move smoothly all around the screen in your games and practical programs.
You can't type fast enough to create animation. A movie is animated
at a rate of 30 pictures per second. The changes must be fast enough
to fool the eye. So you must use a program to draw a picture, wait for
a split second, then change to a new picture.
To get the program to create pictures we use the PRINT statement with
the graphic characters. The simplest type of animation involves alter
nating two characters to get the effect of movement.
This program simulates the movement of a pulsing ball.
Type NEW and press RETURN before entering each new program.
Remember to press RETURN after each line in all these programs.
10 PRINT" HOME
20 FOR L = l TO 100
30 NEXT L
40 PRINT" HOME
50FORL = lTO100
60 NEXT L
70 GOTO 10
SHIFT Q"
SHIFT Type these keys simultaneously
Type RUN and press RETURN
To get a more interesting effect you can build a small picture from several graphic characters, then change a few of the characters while leaving others in the same place. This gives the effect of part of an object moving, demonstrated in the following program.
87
IMPORTANT TO NOTE: Each time SHIFT or O
is referred to, it should be typed at the SAME TIME as the key following it when entering the program.
10 PRINT1' HOME SHIFT M SHIFT W SHIFT N"
20 PRINT "SPACE O + SPACE "
30 PRINT" SHIFT N SPACE SHIFT M"
40 FOR L= I TO 100: NEXT L
50 PRINT" HOME SPACE SHIFT W SPACE"
60 PRINT "O T O + C< T"
70 PRINT "SPACE C* G O G"
80 FOR L -1 TO 100: NEXT L
90 GOTO 10
Type RUN and press return
In both examples of animation so far, we ve worked on only one area on the screen. The next step is to move the animated figure around. The
TAB function helps when you want to move objects from the left edge.
The following program portrays a snake crawling on the screen.
Remember that SHIFT and the following key are still typed together.
5 FOR A- 0TO30
10 PRINT" SHIFT
20 PRINT TAB (A) "
30 PRINT TAB (A) ''
^^^
CLR "
SHIFT
SHIFT u
K
40FORL=1TO 100: NEXT L
50 PRINT" SHIFT CLR "
SHIFT
SHIFT
I
J
SHIFT
SHIFT
U
K
60 PRINT TAB (A+l) " SHIFT I SHIFT U SHIFT I
SHIFT U"
70PRINTTAB (A-l) " SHIFT J SHIFT K SHIFT J
SHIFT K "
80 FOR L = 1 TO 100: NEXT L
SHIFT
SHIFT
90 NEXT A
1 I
1 J
—
Using characters like the ball
(
SHIFT Q). you can play video
games on the screen. To move a ball, just erase the ball and replace it at a new position, as in this program.
10 PRINT" SHIFT CLR "
20 PRINT "SPACE SHIFT Q || ";■
30 FOR L= 1 TO 50: NEXT L
40 GOTO 20
Left cursor arrow leave a space liere
Type RUN and press the RETURN you want to stop moving the ball.
key. Press the STOP key when
89
_
CONTROLLING
COLORS
Separate colors can be put into each part of the screen. The border can be one color, the background a different one, and each character can have its own color. You already know how to set the character col ors using the keyboard. The COLOR command adjusts the color of the other screen areas.
Turn the border of your screen red by typing the command COLOR 4,3 and pressing the return key. The number 4 in the command stands for the border area, and color number 3 is red (the same number as on the key marked RED).
Now type COLOR 0, 7 and hit return . The screen background turns blue. The number 0 stands for the background, while the 7 is blue
(also the same as the keyboard).
The first number after the word COLOR stands for the area on the screen you want to change. Area 0 is the background, 1 is the char acter color, 4 is the border. You'll learn about areas 2 and 3 when you get into multi-color graphics later in this chapter.
_
_
Screen Area Numbers
AREA#
2
3
4
0
1
AREA NAME
Background
Character
Multi-color 1
Multi-color 2
Border
Each color also has an adjustable brightness level, called the lumi nance. You can add a number from 0 (darkest) through 7 (brightest) after the color number to vary the color. Type COLOR 4 ,3, 0 and hit
RETURN.
The border becomes a dark red. Type COLOR 4, 3, 7 and the border changes to a bright red.
90
—
—
.
—
Color Numbers
COLOR#
3
4
5
6
2
1
7
8
COLOR
BLACK
WHITE
RED
CYAN
PURPLE
GREEN
BLUE
YELLOW
COLOR#
9
10
1 1
12
13
14
15
16
COLOR
ORANGE
BROWN
YELLOW GREEN
PINK
BLUE GREEN
LIGHT BLUE
DARK BLUE
LIGHT GREEN
In short, the COLOR command looks like this:
COLOR area, color, luminance
Here is a quick program to show you all the P!us/4's colors:
First type NEW and hit return . Don't forget to hit return after each program line.
10 COLOR 0, 7, 7
20FORM = 0TO7
30FORN-1TO2
40FORL = lTO16
50 PRINT '■
60 READ A
CONTROL
70 COLOR 1, A, M
80 PRINT" ";
RVS ON " ;
90 NEXT L
100 PRINT
110 RESTORE
120 NEXT N,M
130 COLOR 1,2,4
200 DATA 7,14,4,13,6,16,11,8,10,9,3.12,5,15,2,1
Now type RUN and hit return ■ , to see a bright blue screen with each of the other 15 colors shown at each luminance level.
NOTE: Like most of the BASIC graphic terms reviewed in this
chapter, COLOR may be referred to as a statement or command interchangeably. The distinction is unimportant in ex plaining COLOR, or any other graphic commands, since i! is based on whether the term is more often used in direct or pro gramming mode.
91
HIGH
RESOLUTION
GRAPHICS
Your Plus/4 screen contains 25 rows of 40 characters each, or 1000 total character positions on the screen. Each character is formed out of 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. Your Plus/4 has control over every single dot.
Using normal graphics, you have limited control over the individual dots. You must use the 256 characters in each character set built into the Plus/4, which lets you create many pictures. But think of how many you could create if you could control each dot by itself!
The high resolution graphics ability of the Plus/4 lets you do just that.
You can use commands that let you draw and erase dots, lines, circles, and other shapes.
There is one limit to high-res graphics The Plus/4 can only use two colors in each 8x8 character position. That is, each 8x8 space on the screen where characters usually go is limited to two colors (fore ground and background color for that square). You can use different colors for each different character position, but only two colors within that position Another graphic mode that will be covered later in this section, multi-color mode, allows up to four different colors per character position at the cost of the resolution available in the highresolution mode
This program utilizes some of the high resolution graphics capability of the Plus/4, in particular the GRAPHIC command. Start by typing NEW and hitting return Hit the RETURN key after typing each line. After typing in the entire program, type RUN and hit RETURN as usual.
10 COLOR 0,1
20 GRAPHIC 1,1
30 FOR L = 2 TO 16
40 COLOR 1.L.2
50 DRAW l,0.L"12 TO 319.1/12
60 DRAW 1,1/18,0 TO 1/18.199
70 NEXTL
80FORL-lTO5u00:NEXT
90 COLOR 1,2,3
100 GRAPHIC 0
Notice that the colors change near the intersections.
92
To switch from normal graphics (also called Text Mode) to high-res, just type the command GRAPHIC 2,1 and hit RETURN . What hap pens? The screen goes blank and the cursor reappears near the bot tom of the screen. The Plus/4 divided up the screen into 2 separate sections the top for g'aphics and the bottom five lines for text- If you don't want 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 0 switches the screen back to text, while GRAPHIC 2 switches back to high-res without eras ing the screen. Adding ,1 after the command erases the screen
In general the GRAPHIC command looks like this:
GRAPHIC mode, dear this part is optional
Mode
Number Effect
Text
High-res
High-res + text
Multi-color
Multi-color + text
Clear
Number
0
1
Effect
Don't clear screen
Clear screen
There is another way to clear the high-resolution screen. The command
SCNCLR erases the screen without changing the graphic mode.
Once you use high-resolution graphics, the computer sets aside 10K of
memory for your hi-res screen. This memory is taken from the BASIC program area. When you are through using graphics, you can reclaim this memory by using the command GRAPHIC CLR.
93
POINTS,
LINES,
AND
LABELS
Type the commands GRAPHIC 2,1: DRAW 1,0,0 and hit RETURN
Look closely at the upper left corner of the screen. The Plus/4 drew a black dot there.
In the DRAW command, the first number is either 1 (foreground color) or 0 (background). The next two numbers are for the row and column positions for the dot. So if you wanted to draw a dot at column 17, row
20, just type DRAW 1,17,20. To erase the same dot 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 100,100. This draws a line from 1,1 to 100,100.
If you are used to drawing graphs in math, you might get a little con
fused at first while using the computer. The coordinate system in the
Plus/4 is different from what you're used to. In math the 0,0 point would
either be at the center or the lower left corner of the screen, but on the computer it is the upper left corner. You'll get used to the system in the computer 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 the last point drawn to column 150, row 50. If your program uses a
lot of DRAW TO commands, you could place the first dot at a position on the sc/een by using the LOCATE command, as in LOCATE 100,100.
The DRAW command can have several forms, such as:
COMMAND
DRAW color source, column, row
DRAW color source, column, row TO column, row
DRAW color source TO column, row
RESULT
POINT
LINE
LINE DRAWN
FROM LAST POINT
Color source is 0 for the background, 1 for the foreground
To erase points or lines on the screen, use the DRAW command fol lowed by the number 0. If you created a point with DRAW 1,1,1, you can erase it with DRAW 0,1,1. A line created with DRAW 1,1,1 TO 100,100 is — erased by DRAW 0,1,1 TO 100,100.
94
This program draws a curve based on the sine function. Type NEW and hit RETURN . Remember to hit the RETURN key after each line, then type RUN.
10 COLOR 0.1
20 COLOR 1,2
30 GRAPHIC 1,1
40 LOCATE 0,100
50 FOR X=l 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 0
Don't type NEW after RUNning the last program. To plot the program differently, change line 70 to:
70DRAW1.X, Y
The
Char
Command
This program plots Ihe same curve using points instead of lines.
Graphs are more easily understood and useful if you label them. You can use the CHAR command to mix text right into a high resolution drawing. For instance, the statement CHAR 1,0,5,"HELLO" puts the word HELLO into the sixth row at the left edge of the screen. The first number after the word CHAR is either 1 (for draw) or 0 (for erase). The next two numbers are the column and row where the text appears.
Leave the last two programs in the computer: don't type NEW. Add these lines
95
81 CHAR 1,0,0,"GRAPH OF":CHAR 1,0,1,"FORMULA'
82 CHAR l,0,2,"Y = SIN(X)"
83 DRAW 1,0,100 TO 319,100,189,0 TO 189,199
84 CHAR 1,0.12,"X-AXIS": CHAR l,22,0,"Y"
85 CHAR 1,22,2,"A": CHAR 1,22,3,"X"
86 CHAR 1,22,4,"!": CHAR 1,22,5."S"
-
-
96 --
-
-
--
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 the command DRAW 1,0.0
TO 100.0 TO 100,100 TO 0,100 TO 0,0 (plotting each endpoint of the square) or you can just use the BOX command.
Drawing
Rectangles
THE BOX COMMAND
Your Plus'4 includes a command to make it easier to draw squares and other rectangular shapes. The BOX command lets you pick the points of 2 opposite corners of the square. To duplicate the same box as in the above example, just use BOX 1,0,0,100,100- The number 1 again means that you want to draw and not erase. The next four numbers are the coordinates of the box's opposite corners, {0,0} at the upper-left corner and (100,100) near the middle of the screen.
The BOX command can form any rectangle just by changing the cor ners. You can even rotate the box by specifying an angle (in degrees) after the last coordinate, like this: BOX 1,50,50,100,100,45. The box is rotated 45 degrees clockwise.
If you would like to draw a solid box instead of just the outline, you just add a comma 1 after the angle. A solid box at the center of the screen is shown as BOX 1,100,50,220,150,,1. Notice that you need a comma to take the place for the angle, even though you don't want the box rotated.
Some typical forms of the BOX command are:
COMMAND
BOX on, columni, row!, column2, row2
BOX on. con, rowl, col2, row2, angle
BOXon.coM, row1.col2, row2, , fill
BOX off, col1,row1, col2, row2, angle, fil
EFFECT
Outline
Rotated
Solid box
Erase area of screen
Here are a couple of programs that use the BOX command:
Don't forget to type NEW then hit RETURN before entering each program, and press return after typing in each line.
10 COLOR 0,1
20 COLOR 1,2
30 GRAPHIC 2,1
40A=RND(l)*20 + 10
97 continued on next page
50 FOR L = 0 TO 359 STEP A
60 BOX 1, 100, 30, 220, 130, L
70 NEXT L
80FORL-1 TO 2000: NEXT L
90 GRAPHIC 0,1
5 TRAP 60
10 GRAPHIC 2,1
20DEFFNA(X)=-- INT(RND(1)' X)
30 COLOR 1, FNA(15) + 1
40 BOX 1, FNA(320). FNA(160), FNA(320), FNA(160),, 1
50 GOTO 30
60 COLOR 1,2,3: GRAPHIC 0
Hi; return and type RUN after each program is completely en tered Hold down the STOP key to end the program.
The second program draws different colored squares all over the screen. You'll notice some parts of the screen changing when other parts near them change. The reason for this was discussed earlier in this chapter.
Drawing Your Plus'4 also has commands (or drawing circles. Like the BOX
Circles C0!r'mand. we can vary tne shape of the circle to form an oval (also
called an ellipse), and we can rotate the oval. We can also just draw a section of the shape (called an arc)
This command draws a circle in the center of the screen: CIRCLE
1.160,100.50. This tells the Plus/4 to draw a circle with its center at row
160 and column 100, with a radius of 50. This actually produces an oval, since the dots on the screen 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, like this CIRCLE 1.160.100,50,42
The Plus/4 can also draw a square, triangle or other polygon using the
CIRCLE command. Just tell the computer how many degrees to go between points on the circle, like this CIRCLE 1.160.100,50.42....120
This command draws a triangle, since each side is 120 degrees
(Omitting number values while including commas in a graphic com mand causes the computer to read standard default values for the missing number.) A simple formula to get the angle for a polygon with
N sides is 360/N.
Here's a quick program for drawing polygons
~
—
.
10 GRAPHIC 2,1
20 INPUT-HOW MANY SIDES'1; A
30 IF A<2 OR A>100 THEN PRINT "DON'T BE RIDICULOUS"
GOTO 20
40 CIRCLE 1,160,80,40,33,,,,360/A
50 GOTO 20
You can choose to draw only an arc instead of a whole circle.
The CIRCLE command accepts the starting and ending angles in degrees, right after (he height number. The command CIRCLE
1,160,100.50,42,90,180 displays only the lower right section of the circle.
To rotate an oval, add the angle of clockwise rotation after the command, like this example- CIRCLE 1,160,100,100,20,,,30.
The usual forms of the CIRCLE command are:
COMMAND
CIRCLE on.
CIRCLE on,
CIRCLE on,
CIRCLE on,
CIRCLE on, center column, center row, c-col, c-col, c-col, c-col, c-row, c-row, c-row, c-row.
width, height radius wid, ht, start,' width, height, inish
,.angle
wid, ht,,.,point angle
EFFECT oval circle/oval arc rotate oval polygon
NOTE: When there are commas without numbers in a command such as CIRCLE or BOX, the Plus/4 automatically interprets the comma as an input of the default value for that parameter of the command. For example, CIRCLE,160,40.100,100 is read by the computer as CIRCLE 1, 160.... reading the default value of 1 for the color source.
This next program uses the CIRCLE command for an interesting effect.
Type NEW then hit RETURN to erase the last program (rom memory before typing in this program
99
10 COLOR 0,1
20 COLOR 1,2
30 GRAPHIC 1,1
40A = RND(l)*20 + 10
50 FOR L = 0 TO 359 STEP A
60 CIRCLE 1, 160, 100, 80, 40,,,L
70 NEXT L
80FORL=lTO2000: NEXT L
90 GRAPHIC 0,1
Here's a program you can try that uses the CIRCLE command to create a simple design.
NEW
10 COLOR 0,1
20 COLOR 1,2
30 GRAPHIC 2,1
40FORL = lTO4
50Y=50
60IFL = 2ORL = 4THENY=100
70X=L*35 + 50
80 CIRCLE 1, X, Y, 50, 42
90 NEXT L
100 PRINT "PLUS/4 CIRCLES"
u
100 —
-
The Tne PA|NT command fills in any enclosed area up to the boundaries
Paint 'orrned by anY ''nes drawn on the screen. If there are no drawn lines,
Pnmmanil the screen is filled ri9ht t0 tne ed9e-Tne B0X command can be used
color in irregular shapes and other non-uniform areas on the screen that can't be filled with other commands.
In the last exercise, we created a 4-ring symbol. By adding some
PAINT commands to the program we can color in only the areas between the rings.
Add these lines to the last program:
110FORL=0TO 1
120 PAINT 1,120 + 35 *L, 75
130 NEXT L
101
MULTI- Tne plus/4 high resolution graphics give you control over every single ■—■
COLOR cio*or Pixel on the screen, but you have seen that the ability to put
colors close together is limited. Most high-res programs can use only one or two colors.
For including more different colors, your Plus/4 has a special "inbetween" graphics mode called multi-color graphics. In multi-color graphics, you control half as many dots on each row as in high-res be cause 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 colors, which is slightly lower resolution.
•—'
To begin using multi-color graphics, review the GRAPHIC command earlier in this chapter You'll see that the multi-color screen without text is GRAPHIC 3 and the multi-color 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 colors. You can use any of the three colors (1. the text color; 2, an extra color; and 3, another extra color) These colors do not interfere with each other on the screen the way the high-res colors do in some previous programs in this chapter
—
These two programs make use of multi-color graphics, the first with the rings and ihe second showing a "neon sign" effect.
. -
10 COLOR 0,1
20 GRAPHIC 4,1
30FORL = 1 TO 4
40Q = L: IFQ>3THENG=Q-3
50 COLOR Q,L+1
60Y-50
70IFL 2ORL 4 THEN Y-100
80X- L'18 ■ 25
90 CIRCLE Q,X,Y, 25,42
100 NEXT L
102-
—
—
—
—
Type NEW then hit ' RETURN . Don't forget to hit the RETURN key after each line. Type RUN and hit RETURN at the end
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.55 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
130FORM-1 TO 100: NEXT M
140 GOTO 80
200 GRAPHIC 0; COLOR 1,2,7
Color area 3, the second of the multicolor areas, has a special ability that none of the others has. Once you have drawn on the screen using area 3, you can change that color everywhere it appears on the screen by using the COLOR command. If you set the color with COLOR 3.5
and draw using that color, your graphics appear in purple. If you then change the color with COLOR 3.6. all the purple areas would change to green. This doesn t work with any other area
The Plus/4 Programmer's Reference Guide contains more information about graphics
103
-
U
--
-
-
-u
n
104
CHAPTER
MAKING
SOUND
AND
MUSIC
ON
THE
PLUS/4
Introduction
Volume command
Sound command
Creating sound effects
Making some music
The Plus/4 Music Machine
INTRODUCTION
Here is a short program to make music on your Plus/4. Type in the pro gram exactly as it appears, and remember to press RETURN at the end of each line. When the program is typed in, type RUN and then press RETURN When the program asks you to enter a number, type any number from 0 to 1023 and press program, enter a zero as your value.
RETURN To stop the
—-
10 VOL 8
20 DO
30 INPUT X
35EFX -1023ORX-- 0 THEN PRINT "0 TO 1023, PLEASE": GOTO 30
40 SOUND 1,X, 10
50 LOOP UNTIL X=0
Press the RUN/STOP key to stop the program
Here's how to play a single note on your Plus/4. Type NEW and press return to clear the Plus/4's memory.
First Type NEW and press RETURN
Type VOL 8 and press RETURN
Second- Type SOUND 1,266,60 and press RETURN
You should hear a note play for about a second and then stop If you don't hear anything, turn up the volume of your television or monitor and try it again.
These two steps are the only commands that you need to know to play music on your Plus/4. Lets look at what these two commands do
THE The VOL command controls the VOLume of the noies that the Plus/4
VOLUME
COMMAND
plays. Think of the first three letters of the word "volume" to remember the VOL command. The number that comes after VOL is the setting for the volume. Think of the VOL command as a volume knob on the
Pi us; 4 When the knob points to zero, the volume is off and you won't
hear anything. When the knob is set at 8. the volurre is turned up all the way, and your Plus'4 plays as loud as it can.
Try the first example again and use a different number after the VOL command. The smaller the number, the softer the note is played.
—
^
i^J
105
-
THE ^ne SOUND command tells your Plus/4 everything it needs to know
SOUND abou! tne souncl y°u want t0 Plav The SOUND command is followed
COMMAND
by three numbers that describe the note.
SOUND voice, note value, duration
The first number in the sound command refers to voice. The number for voice can be a 1,2 or 3. The Plus/4 sound is produced by two different
"voices", 1 for the first voice and 2 for the second voice. The third voice option applies to voice 2's ability to produce either a tone or noise.
Voice 1 —This voice plays only tones. Select this voice with a 1 after the
SOUND command.
Voice £ —This voice is like voice 1. but can be used to play tones or noise for sounds. Type a 2 in the command to 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 the note value (fre quency). This can be any number from 0 to 1023. It tells your Plus/4 how low- or high-pitched a note to play As the numbers get larger, the notes get higher. The highest values (in the 1023 neighborhood) are not audible to the human ear
Note: Noise is "white" only in the range of 600-940 with Voice 3.
You can use register values outside this range to create interest ing sound effects.
Here is a chart that shows all of the notes in one scale, along with the note value to use. There is a complete chart of notes for the Plus/4 in
SOUND
NOTE
FREQUENCY
106
-ML
—-"
--—
---
4P
0
M9 ■
■39 r
19; ■■
•' "98
:.; :
494
9'
-•
85- B& Rfll
-
" —
B5B
59 BBO 7
—
Try the following program on your Plus/4:
NEW
10 VOL 7
20 X = 0
-*
30 DO
40 SOUND 1.X.5
50 X - X + 5
"*
60 LOOP UNTIL X - 1020
70 VOL 0 -^
80 END sets VOlume plays note turns off VOLume
Type RUN and press RETURN to show off some of its musical range.
This program allows your PI us'4
The third number after the word SOUND controls the duration (length) __i of the note. This tells the Plus/4 how long to play the note. This number can be anything from 0 to 65535. This number sets a timer, which counts time in sixtieths of a second. A duration of 60 keeps the note on for one second A rule of thumb for duration is the larger the number, the longer the note stays on. In fact, if you use 65535. the note stays on —■ for over 16 minutes. To turn a sound off, use a zero duration, which does not allow the sound to be produced.
107
--
A
MUSICAL
SOUND
EFFECT
Sound effects can be created using either musical tones or noise.
Combining simple BASIC programs and sound commands can gener ate unusual and entertaining effects. For instance, the FOR... NEXT ..
STEP loop can be used creatively in sound effects. This program uses a FOR... NEXT loop with a negative step, to count down from a high number to a lower one.
sets VOLumeat 8
10 VOL 8 -*
20 FOR S - 1000 TO 700 STEP -25
30 SOUND l.S. 1
40 NEXTS creates loop, with downward STEPs
Type RUN and press RETURN to hear the sound effect. The key is line 20. which selects a number range from 1000 to 700 going down the scale. STEPping down 25 numbers at a time. Finally, line 30 in structs your Plus/4 to play each note for just an instant by setting the
DURATION to 1. which is 1/60 of a second. Experimenting with dif ferent number and duration values can give you some very interest ing effects.
H
108
CREATING
A NOISE
SOUND
EFFECT
Using a value of 3 when selecting a voice in the SOUND command specifies noise. This is used to create sound effects with noise rather than tone. The following program uses voice 3 to create the sounds of a windstorm.
sets VOLume level
10 VOL 2
20R = INT(RND(0)
30FORX = 1TOR
40 SOUND 3, 600 + 30*X, 10
50 NEXT X
60FORX-RTO1STEP -1
70SOUND,3,600-30*X, 10
80 NEXT X
90 T = INT{RND(0)-100)-30
100 SOUND 3, 600, T
110 GOTO 20 selects RaNDom number from 1 to 10
Lines 30 and 60 set up loops for the note value (frequency) of the sound, one increasing and one decreasing, based on the random number from line 20. It is important to have variation in pitch, since windstorms have different forces of gusts of wind. Lines 40 and 70 are the SOUND commands that create the noise. Lines 90 and 100 set up a random delay to recreate the uneven nature of a windstorm with time lapses between howls The program selects a RaNDom number that is used for the duration of another SOUND command. This SOUND command stays at the same pitch and provides a consistent back ground noise that serves as a counterpoint to the gusts of wind.
Creating sound effects using noise is extremely challenging, trying to capture the right elements of the sound you wanl exactly. To create good sound effects, you have to be willing to experiment.
~
109
MAKING Now Inat we've looked at some ways to create sound effects on your
SOME P'us/4. let's make some music. Here are a couple of programs to try:
MUSIC The first program turns the keys from 1 through 8 into a piano. Type in
the program and then type RUN.
5SCNCLR ~«
10 FOR X = 1 TO 8: READ N(X): NEXT X
20 VOL 7
30 DO
40GETAS: IFA$ = " "THEN 40
50 A = ASC(AS): IF A<49 OR A>56 THEN 90
60N = A-48
70 SOUND 1,N(N), 5
80 COLOR 0, N, 3
90 LOOP UNTIL A-32
100 VOL 0: COLOR 4, 2, 7
110 DATA 169, 262, 345,383,453, 516, 571, 596 clears the screen
Press numbers 1 through 8 to play notes. The screen border even changes colors with the different notes. When you finish playing, press the space bar to stop the program.
Here are the numbers to press for a familiar song:
Twinkle, Twinkle Little Star
115 5 6 6 5
4 4 3 3 2 2 1
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
110
This program plays a song by reading a list of DATA statements. The
DATA statements are in pairs The first number is the note value for the
SOUND command and the second number is the duration for the
SOUND command
Row Boat
10 VOL 8
20 DO
30 READ X, Y
40 SOUND 1.X.Y
45FORD=1 TO550:NEXT
50 LOOP UNTIL X=0
60 END
100 DATA 169
110 DATA 262
120 DATA 262
130 DATA 453
140 DATA 345
150 DATA 383
160 DATA 169
200 DATA 0, 0
45, 169,45, 169, 30
15, 345,45,345,30
15, 345,30, 383, 15
60, 596,45,453,45
45, 169,45,453,30
15.
60
345,30,262, 15
This loop creates a brief delay between notes
--
-
This program plays notes going up and down scales at different speeds, and displays some color bars along with Ihem.
10 VOL 8
20 DO
30D = INT(RND(0) '5)- 2: REM DURATION
40S = INT(RND(0) '300)- 700 : REM START
50R-INT(RND(0)'(1020 S)}: REM RANGE
60P-INT(RND(0)*30)- 5: REM STEP
70T = SGN(RND(l) - .5): IF T = 0 THEN 70
80FORZ = STOS + T'RSTEPP^T
90 SOUND l.Z.D
100Y = {ZAND15) + 1:FORX-1TOD
110 PRINT CHR$(18);:COLOR1. Y: PRINT'1
120 NEXT X,Z
130 LOOP these REMark state ments help you keep track of which line does what leave a space here
_
-
THE
GREAT
PLUS/4
MUSIC
MACHINE
The last program is a little longer. This is the ''GREAT PLUS/4 MUSIC
MACHINE". When you press a key from 1 through 9, the note is played, and a note appears on the staff on the correct line
5 GOSUB 1000
6FORX-1TO9: READN(X): NEXT X
8 CHAR 1,8. l.'-THE GREAT MUSIC MACHINE1":
10 VOL 7
20 DO
30GETA$:IFA$ = ""THEN30
35 A-ASC(AS): IF A<49 OR A>57 THEN 50
36 N- A - 48
40 SOUND 1, N(N),4
45GSHAPENS. 150.8 * (6 + (9-N)),4
46 FOR Z - 1 TO 50: NEXT Z
47GSHAPENS, 150,8 '{6 + (9-N)),4
50 LOOP UNTIL A = 32
55 VOL 0: GRAPHIC 0: SCNCLR
60 END
100 DATA 345, 383, 453, 516, 571, 596, 643, 685. 704
1000 GRAPHIC 1.1
1010 FOR Y-60 TO 124 STEP 16
1020 DRAW 1. 100, Y TO 200, Y no space
1030 NEXT Y
1040 AS- ■■FEDCBAGFE"
1050 FOR X=l TO 9: C=13
1060 IF INT(X 2) - X;2 THEN C = 14
1070 CHAR 1, C. X-6, MID$ (A$, X, 1), 0
1075 CHAR 1, C -10, X-6, RIGHTS (STRS (10 X). 1)
1080 NEXT X
1090 FOR X=l TO 8: FORY=11 TO 16: DRAW 1, X, Y: NEXT Y. X
1100Y=l:X=8: DRAW 1,8, 16TOX, Y
1110SSHAPENS, 1. 1, 8. 16
1120GSHAPENS, 1, 1.4
1130 RETURN
As you can see, it's not hard to write your own sound programs. The ones in this chapter just give a taste of the music capabilities of your
Plus/4 Don't be afraid to try new sounds and noises and create your own masterpiece
112
PLUS/4
ENCYCLOPEDIA
The Plus/4 Encyclopedia contains information useful for both the com puter novice and expert. Some sections are musts for beginners, like
the BASIC 3.5 Encyclopedia, which lists and explains all the BASIC
commands, statements and terminology. Other sections will be use
ful for those computerists whose knowledge extends beyond BASIC.
TEDMON, the Ptus/4's machine language monitor, provides some di rection for machine language programming on the Plus/4. Other sec tions can be helpful for all Plus/4 owners... listings of error messages, programs to try out, the musical note table, and more. The Plus,4 En cyclopedia has something for all Plus/4 programmers, whether you're just beginning to experiment or you're a high-level programmer.
114
BASIC
3.5
ENCYCLOPEDIA
This manual has given you an introduction to the BASIC language, to give you a feel for computer programming and some of the vocabulary involved. This encyclopedia gives a complete list of the rules (SYNTAX___ of the BASIC 3.5 language, along with a concise description of each.
Experiment with these commands, and remember that you can't dam age your Plus/4 by typing in programs, and that the best way to learn - computing is by doing.
The encyclopedia provides formats and brief explanations and examples of the BASIC 3.5 commands and statements. It is not in tended to teach BASIC. If you are interested in learning BASIC,
Section 14 lists tutorial books that will help.
Commands and statements are listed in separate sections Within the —' sections, the commands and statements are listed in alphabetical order. Commands are used mainly in direct mode, while statements ^_ are most often used in programs. In most cases, commands can be used as statements in a program if you prefix them with a line number
You are able to use many statements as commands by issuing them in ~~' direct mode (i.e., without line numbers).
.
The different types of operations in BASIC are listed in sections based on the following criteria:
• COMMANDS: the commands used to work with programs, edit, store, and erase them.
• STATEMENTS: the BASIC program statements used in numbered lines of programs.
• FUNCTIONS: the string, numeric, and print functions.
• VARIABLES AND OPERATORS: the different types of variables, legal variable names, and arithmetic and logical operators.
^*
A fuller explanation of BASIC 3.5 commands is provided in the Plus/4 *
Programmer's Reference Guide, available from your Commodore dealer or your local bookstore.
115-
COMMAND
AND
STATEMENT
FORMAT
The commands and statements presented in this section of the ency clopedia are governed by consistent format conventions designed to make them as clear as possible. In most cases, there are several ac tual examples to illustrate what the actual command looks like. The following example shows some of the format conventions that are used in the BASIC commands and s;atements
EXAMPLE LOAD1'program name ".DO. U8 additional arguments
Ipossibly optional | keywords argument
The parts of the command or statement that you must type in exactly as they appear are highlighted in boldface type in the 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 italics.
When quote marks ("') appear (usually around a program or file name), you should include them in the appropriate place according to the format example.
• KEYWORDS, also called RESERVED WORDS, appear in upper case letters and boldface type. YOU MUST ENTER THESE
KEYWORDS EXACTLY AS THEY APPEAR. However, many key words have abbreviations that you can also use (see Section 2)
Keywords are words that are part of the 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 want it to take. These words cannot be used as variable names.
• ARGUMENTS (also called parameters) appear in lower-case italics.
Arguments are the parts of a command or statement that you select; they complement keywords by providing specific information about the command or statement. For example, a keyword tells the com puter to load a program, while an argument tells the computer which specific program to load and a second argument specifies which drive the disk containing the program is in. Arguments include filenames, variables, line numbers, etc
• SQUARE BRACKETS [1 show OPTIONAL arguments. You select any or none of the arguments listed, depending on your requirements.
• ANGLE BRACKETS <> indicate that you MUST choose one of the arguments listed.
116
VERTICAL BAR separates items in a list of arguments when your choices are limited to 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 no! to use any arguments.
ELLIPSIS .... a sequence of three dots, means that an option or argument can be repeated more than once.
QUOTATION MARKS" enclose character strings, filenames, and
other expressions. When arguments are enclosed in quotation marks in a format, you must include the quotation marks in your command or statement. Quotation marks are not conventions used to describe formats; they are required parts of a com mand or statement.
PARENTHESES () When arguments are enclosed in parentheses in a format, you must include the parentheses in your command
or statement- Parentheses are not conventions used to describe
formats; they are required parts of a command or statement.
VARIABLE refers to any valid BASIC variable name, such as X, A$, orT%.
EXPRESSION means any valid BASIC expression, suchas A + B-2 or.5'(X+3).
117.
n n
BASIC
COMMANDS
AUTO [line* |
AUTO
Turns on the automatic line numbering feature which eases Ihe |Ob of entering programs by typing the line numbers for you. As you enter each program line and press RETURN the next line number is printed on the screen, with the cursor in position to begin typing that line. The (line# | argument refers to the increment between line num bers AUTO with NO ARGUMENT turns off auto line numbering, as does RUN This statement is executable only in direct mode.
EXAMPLE
AUTO 10
AUTO 50
AUTO automatically numbers line in increments of ten automatically numbers line in increments of fifty turns OFF automatic line numbering
BACKUP BACKUP Ddnv(}# TO Dc/nve# |, ON Uun//#|
This command copies all the files 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 all the information on the diskette, in cluding the format You should always BACKUP important diskettes in case the original is lost or damaged.
Because the BACKUP command also HEADERS diskettes, it destroys any information on the diskette onto which you're copying information.
So if 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 be used with dual disk drives,
EXAMPLE.
BACKUPDO TO Dl
BACKUP DO TO Dl, ON U9
Copies all files from the disk m drive 0 to the disk in drive 1
Copies all files from drive 0 to drive 1 in disk drive unit 9
118
_
COLLECT COLLECT \Ddnve#} [,ONUun/f#l
Use this command to free up space allocated to improperly closed files and delete references to these files from the directory.
_
-
CONT
(Continue)
EXAMPLE
COLLECT DO u
CONT
This command is used to re-start the execution of a program that has been stopped by either using the STOP key, a STOP statement, or an ,
END statement within the program. The program will resume execution where it left off CONT will not work if you have changed or added lines of the program (or even just moved the cursor to a program line and hit' return without changing anything), if the program stopped due to an error, or if you caused an error before trying to re-start the pro gram. The error message in this case is CAN T CONTINUE ERROR
-
COPY COPY\Ddrive#, \ "source file" TO \Ddnve#,\"othertile" I.ONUi;/»r#|
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 creates a copy of a file on the same drive (with a different file name).
EXAMPLES
COPY DO. "test" to D1, "test prog"
Copies "test" from drive 0 to drive 1. re naming it "test prog" on drive 1
COPY DO, -STUFF" TO Dl, "STUFF"
Copies "STUFF' from drive 0 to drive 1
—.
^
—
COPY DO TO Dl
Copies all files from drive 0 to drive 1
COPY "WORK.PROG" TO "BACKUP"
Copies
'WORK PROG as a program called
"BACKUP" on the same drive
_
119
_
n
~
DIRECTORY "AB"
DIRECTORY DO, "FILE ?.BAK'
Lists all files start ing with the letters
■AS1, like ABOVE.
ABOARD, etc
The? is a wild-card that matches any single character in that position FILE
1.BAK, FILE2.BAK.
FILE3.BAKall
match the string
NOTE: To print out the DIRECTORY of drive 0. unit 8. use the following;
LOAD"$CT,8
OPEN4,4:CMD4:LIST
PRINT#4:CLOSE4
DLOAD DLOAD "filename" [,Ddnve#\ [,\Junit#\
This command loads a program from disk tnlo current memory (Use
LOAD to load programs on tape.) You must supply a program name
-LJ
EXAMPLES
DLOAD "BANKRECS"
DLOAD {AS)
Searches the disk fortne program
"BANKRECS"and
LOADs it
LOADs a program from disk whose name is in the variable
AS You will get an erro1" if A$ is empty
The DLOAD command can be used within a BASIC program to find and RUN another program on disk. This is called chaining.
121
_
n n n
-
—
~
H
DSAVE DSAVE "filename" [.Ddrive#\ [,Uunit#]
This command stores a program on disk. (Use SAVE to store programs on tape.) You must supply a program name
EXAMPLES
DSAVE "BANKRECS"
SAVEs the program
■'BANKRECS"todisk.
DSAVE (AS)
*—1
DSAVE "PROG 3", D0.U9
SAVEs to disk pro gram whose name is in the variable AS.
SAVEs the program
"PROG 3" to the disk drive with a unit num ber (Serial bus ad dress) of 9
HEADER HEADER "diskname" \.li.d.#\ ,Vdrive# [,ONUuntt#\
Before you can use a new diskette for the first time you must format it
with the HEADER command. If you want to erase an entire diskette for
reuse you can use the HEADER command. This command divides the disk into sections called blocks, and it creates a table of contents, called a directory or catalog, on the disk. The diskname can be any name up to 16 characters long. The i.d. number is any 2 characters.
Give each disk a unique i.d. number. Be careful when you HEADER a disk because the HEADER command erases a!! stored data. Giving no i.d. number allows you to perform a quick header. The old i.d. number is used. You can only use the quick header method if the disk was pre viously formatted, since [he quick header only clears out the directory rather than formatting the disk.
EXAMPLES:
HEADER "MYDISK", 123, Dl
HEADER "RECS", 145, Dl, U8
122
HELP HELP
The HELP command is used after you gel an error in your program
When you type HELP, the line where the error occurred is listed, with
the portion containing the error displayed in flashing characters
KEY ^key *■ stnn91
There are eight (8) function keys available to the user on the Pius 4 computer four unshifted and four shifted. The Plus/4 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 function key is pressed The maximum length for all the definitions together is 128 characters. Entire commands (or a series of commands) can be assigned to a key. For example
KEY 7. "GRAPHICO" + CHR$(13) + "LIST"1 + CHRS(13) causes the computer to select text mode and list your program whenever the 'F71 key is depressed (in direct mode) The CHRS(13) is the ASCII character for RETURN double quote into a KEY string.
Use CHRS(34) to incorporate a
The keys may be redefined in a program For example
10 KEY 2."TESTING" + CHRS(34):KEY3, "NO"
I0FORI-1 TO8:KEYI,CHR$(I- 132):NEXT
'—
—
— defines the function keys as they are de fined on the Commo dore 64 and VIC 20
To restore all function keys to their default values, reset the Plus 4 by turning it off and on. or press the RESET button.
_
123
n n n n n n
LIST LIST \firstline#] [-[last line #]]
The LIST command lets you look at lines of a BASIC program that have been typed or LOADed into the Plus/4'S memory. When used alone
(without any numbers following it), the Plus/4 gives a complete LISTing
of the program on your screen, which may be slowed down by holding
down the C* key, paused by CTRL S (unpaused by press ing any other key), orSTOPped by hitting the RUN/STOP key. If
you follow the word LIST with a line number, the Plus/4 only shows that line number. If you type LIST with two numbers separated by a dash, the Plus/4 shows all lines from the first to the second line number. If you type LIST followed by a number and just a dash, it shows all the lines from that number to the end of the program. And if you type LIST, a dash, and then a number, you get all the lines from the beginning of the program to that line number. Using these variations, you can examine any portion of a program, or easily bring lines to the screen for modification.
EXAMPLES:
LIST
LIST 100-
LIST 10
LIST-100
LIST 10-200
Shows entire program.
Shows from line
100 until the end of the program.
Shows only line 10.
Shows lines from the beginning until line 100.
Shows lines from
10 to 200, inclusive.
LOAD L0AD ["filename"][,device#] [.relocate flag\
This is the command to use when you want to use a program stored on
cassette tape or on disk. If you type just LOAD and hit the RETURN
key, the Plus/4 screen goes blank. Press play, and the Plus/4 starts
124
looking for a program on the tape. When it finds one, the Plus/4 prints
FOUND "filename". You can hit the O key to LOAD. Once the pro
gram is LOADed, you can RUN, LIST, or change it.
You can also type the word LOAD followed by a program name, which is most often a name in quotes ("program name"). The name may be followed by a comma (outside of the quotes) and a number (or numeric variable), which acts as a device number to determine where the pro gram is stored (disk or tape)- If there is no number given, the Plus/4 assumes device number 1, which is the cassette tape recorder.
The other device commonly used with the LOAD command is usually the disk drive, which is device number 8.
L_
EXAMPLES:
LOAD
LOAD "HELLO"
LOAD A$
LOAD-HELLO-,8
Reads in the next program on tape
Searches tape fora program called
HELLO, and LOADS if found.
Looks for a program whose name is in the variable called A$.
Looks for the pro gram called HELLO on the disk drive, or the program last accessed.
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 flag of 0 tells the Plus/4 to load the program at the start of the BASIC program area, and a flag of 1 tells it to LOAD from the point where it was SAVEd. The default value of the relocate flag is 0.
This is generally used only when loading machine language programs.
_
125
—
—
PI
_
~
_
—
—.
H
_
~
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 is lost until you type it in again. Be careful when you use this command.
The NEW command can also be used as a statement in a BASIC program. When the Plus/4 gets to this line, the program is erased and everything stops. This is not especially useful under normal circumstances.
RENAME R£NAME IDdrive #] "old name" TO "new name" [.U unit #]
Used to rename a file on a diskette.
EXAMPLE.
RENAME "TEST" TO "FINALTEST"
Changes the name of the file "TEST" to
"FINALTEST"
RENUMBER reNUMBEB\ new starting line # [.increment [,old starting line //111
The new starting line is the number of the first line in the program after renumbering. It defaults to 10.
The increment is the spacing between line numbers, i.e. 10, 20, 30 etc.
It also defaults to 10.
The old starting line number is the line number in the program where renumbering is to begin. This allows you to renumber a portion of your program. It defaults to the first line of your program.
This command can only be executed from direct mode.
EXAMPLES:
■^
Starting at line 65,
_j renumbers in incre ments of 10. Line 65 becomes line 10.
126
RENUMBER, . 65
Starting at line 1, renumbers the program. Line 1 becomes line 20, and olher lines are numbered in incre ments of 20.
_
RUN RUN[//ne#]
Once a program has been typed into memory or LOADed, the RUN command makes it start working. RUN clears all variables in the pro gram before starting program execution. If there is no number follow ing the command RUN, the computer starts with the lowest numbered program line. If there is a number following the RUN command execu tion starts at that line. RUN may be used within a program.
EXAMPLES:
RUN
RUN 100
Starts program working from lowest line number.
Starts program at line 100.
SAVE SAVEi"Wename" [,device# [,EOTflag\\\
This command stores a program currently in memory onto a cassette tape or disk. If you just type the word SAVE and hit RETURN the Plus/4 attempts to store the program on the cassette tape. It has no way of checking if there is already a program on the tape in that loca tion, so be careful with your tapes. If you type the SAVE command fol lowed by a name in quotes or a string variable name, the Plus/4 gives the program that name, so it may be more easily located and retrieved in the future. If you want to specify a device number for the SAVE, fol low the name by a comma (after the quotes) and a number or numeric variable. Device number 1 is the tape drive, and number 8 is the disk.
After the number on a tape command, there can be a comma and a second number, which is either 0 or 1. If the second number is 1, the
Plus/4 puts an END-OF-TAPE marker (EOT flag) after your program. If
_
—
127
-
~
~ n trying to LOAD a program and the Plus/4 finds one of these markers rather than the program you are trying to LOAD, you get a FILE NOT
FOUND ERROR.
EXAMPLES:
SAVE
SAVE "HELLO"
SAVE A$
SAVE "HELLO", 8
SAVE "HELLO", 1,2
Stores program to tape without a name
Stores on tape with
the name HELLO
Stores on tape with name in variable AS
Stores on disk with name HELLO
Stores on tape with name HELLO and places an END-OF-
TAPE marker after the 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" before the Plus/4 completes the operation. Type a Y to perform the SCRATCH or type N to cancel the operation. Use this command to erase unwanted files, to create more space on the disk.
EXAMPLE:
SCRATCH "MY BACK", Dl-
Erases the file MY
BACK from the disk in drive 1
VERIFY VERIFY "filename" [,device#] \ .relocate flag]
This command causes the Plus/4 to check the program on tape or disk againsi the one in memory. This is proof that the program you just
SAVEd is really saved, in case your tape is bad or something isn't working. This command is also very useful for positioning a tape so that
Plus/4 writes after the last program on the tape. All you do is tell the
128
Plus/4 to VERIFY the name of the last program on the tape. It will do so, and tell you thai 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.
VERIFY without anything after the command causes the Plus/4 to check the next program on tape, regardless 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 for disk). The relocate flag is the same as in the LOAD command.
EXAMPLE:
VERIFY
-^
VERIFY "HELLO"
'
Checks the next pro gram on the tape.
Searches for HELLO on tape, checks against memory.
VERIFY "HELL0",8,l
Searches for HELLO on disk, then checks.
_
_
129
n n
~
~
BASIC BOX \colorsource #lah b1, a2, b2, [[.angle] [.paint]]
color source
BOX a1, b1 a2, b2
Color source (0-3); default is 1 (foreground angle paint
Corner opposite a1, b1 (scaled); default is the PC
Rotation in clockwise degrees; default is
0 degrees
Paint shape with color (O:off, 1 :on); default isO
This command allows you to draw a rectangle of any size anywhere on the screen. To get the default value, include a comma without entering a value. Rotation is based on the center of the rectangle. The Pixel
Cursor (PC) is left at a2, b2 after the BOX statement is executed.
EXAMPLES:
BOX1, 10,10,60,60
BOX, 10, 10,60,60,45,1
Draws the outline of a rectangle
Draws a filled, rotated box (a diamond)
BOX, 30, 90, .45, 1
Draws a filled, rotated polygon
CHAR CHAR I co/or source #1 ,x,y [,text string] [.reverse flag]
Alternate:
CHAR I color source #1 ,x,y [."text string"] [.reverse flag] color source x y string reverse
Color source (0 - 3)
Character column (0 - 39)
Character row (0 - 24)
String to print
Reverse field flag (0 = off, 1 = on)
130
Text (alphanumeric strings) can be displayed on any screen at a given location by the CHAR command. Character data is read from Plus/4 character ROM area. You supply the x and y coordinates of the starting position and the text string you want to display. Color source and re verse imaging are optional.
The string is continued on the next line if it attempts to print past the right edge of the screen. When used in TEXT mode, the string printed by the CHAR command works just like a PRINT string, including re verse field, cursors, flash on/off, etc. These control functions inside the string do not work when the CHAR command is used to display text in
GRAPHIC mode.
NOTE: when in multicolor mode, to display a character in multi color 2, set the color source to 0 and reverse flag to 1. To display a character in multicolor 1, set the color source to 0 and the reverse flag to 0.
CIRCLE crRCLE fcsl '^^l ■ xr I [y'l I tsaJ I teaJ I Lang/e] line] ]]]]
cs a,b xr yr sa ea angle inc
Color source (0 - 3)
Center coordinate (scaled)
(defaults to the Pixel Cursor [PC])
X radius (scaled)
Y radius (default is xr)
Starting arc angle (default 0)
Ending arc angle (default 360)
Rotation in clockwise degrees
(default is 0 degrees)
Degrees between segments
(default is 2 degrees)
—
_
131 —
—
—
With the CIRCLE command you can draw a circle, ellipse, arc, triangle or an octagon. The final coordinate is on the circumference of the circle at the ending arc angle. Any rotation is about the center. Set ting the Y radius equal to the X radius does not draw a circle, since the
X and Y coordinates are scaled differently, Arcs are drawn from the starting angle clockwise to the ending angle. The segment increment controls the coarseness of the shape, with lower values for inc creating rounder shapes.
EXAMPLES:
CIRCLE „ 160,100,65,10
CIRCLE , 160,100,65,50
CIRCLE , 60,40,20,18,,,,45 circle , 260,40,20,,,,,90
CIRCLE , 60,140,20,18,,,,120
Draws an ellipse.
Draws a circle.
Draws an octagon.
Draws a diamond.
Draws a triangle.
CLOSE
CLOSE file #
This command completes and closes any files used by OPEN state ments. The number following the word CLOSE is the file number to be closed.
EXAMPLE
CLOSE 2
Logical file 2 is closed.
CLR CLR
This command erases any variables in memory, but leaves the pro gram itself intact- This command is automatically executed when a
RUN or NEW command is given, or when any editing is performed.
CH/ID CMD file # [.write list]
CMD sends the output which normally would go to the screen (i.e.
PRINT statement, LISTS, but not POKEs into the screen) to another device instead. This could be a printer, or a data file on tape or disk.
This device or file must be OPENed first. The CMD command must be followed by a number or numeric variable referring to the file.
EXAMPLES
OPENS device #4, which is the printer.
OPEN 1,4
All normal output now goes to the printer.
CMD1
LIST
The LISTing goes to the printer, not the screen—even the word READY.
PRINT#1
Set output back to the screen.
CLOSE 1
Close the file.
COLOR C0L0R source #. color # [.luminance # I
Assigns t color to one of the 5 color sources:
Number Source background foreground multicolor 1 multicolor 2 border
Colors you can use are in the range 1-16 (BLACK, WHITE ...). As an option, you can include the luminance level 0-7, with 0 being lowest and 7 being highest. Luminance defaults to 7. Luminance lets you select from eight levels of brightness for any color except black.
DATA DATA list of constants separated by commas
This statement is followed by a list of items to be used by READ state
ments. The items may be numbers or words, and are separated by
commas. Words need not be inside of quote marks, unless they con-
133
—
—-
—
—
—
— tain 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. Also see the RESTORE statement.
which allows the Plus/4 to re-read data.
EXAMPLE:
DATA 100, 200, FRED, "HELLO,MOM'1, , 3, 14, ABC123
DEF FN DEF FN name (Var/'ab/eJ = expression
(DEFine FunctioN)
This command allows you to define a complex calculation as a function. In the case of a long formula that is used several times within a program, this can save a lot of space. The name you give the function begins with the letters FN, followed by any legal numeric variable name. First you must define the function by using the statement DEF followed by the name you have given the function. Following the name is a set of parentheses {) with a numeric variable (in this case, X) en closed. 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
10 DEF FNA(X) = 12*(34.75-X/.3) + X
20 PRINT FNA(7)
The number 7 is in serted each place X is located in the for mula given in the
DEF statement.
DIM DIM vanable (subscripts) \,vanable(subschp(s)]...
Before you can use an array of variables, the program must first exe cute a DIM statement to establish the DIMensions of that array (unless there are 11 or fewer elements in the array). The statement DIM is fol lowed by the name of the array, which 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 than one di mension is called a matrix. You may use any number of dimensions, but keep in mind that the whole list of variables you are creating takes up space in memory, and it is easy to run out of memory if you get car-
134
ried away. To figure the number of variables created with each DIM, multiply the total number of elements in each dimension of the array.
(Each array starts with element 0.)
NOTE: Integer (single-digit) arrays take up 2/5ths of the space of
floating point arrays.
EXAMPLE:
10 DIM A${40),B7(15),CC%(4,4,4)
L t 1
41 Elements 16 Elements 125 Elements
You can dimension more than one array in a DIM statement by sepa rating the arrays by commas. If the program executes a DIM statement for any array more than once, you'll get a re'DIMed array error mes sage. It is good programming practice to place DIM statements near the beginning of the program.
DO/
LOOP/
WHILE/
UNTIL/
EXIT
DO| UNTIL boolean argument WHILE boolean argument \ state ments |EXIT|
LOOP | UNTIL boolean argument WHILE boolean argument\
Performs the statements between the 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 indefi
nitely. If an EXIT statement is encountered in the body of a DO loop,
execution is transferred to the first statement following the LOOP statement. DO loops may be nested, following the rules defined for
FOR-NEXT loops. If the UNTIL parameter is used, the program con
tinues 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. An example of a boolean argument is A=1. or
G>=65.
—
135
-
"
~
~
~
EXAMPLE:
DOUNTILX = OORX=1
LOOP
DO WHILE A$="":GET
A$:LOOP
DRAW DRAW color source #[, a 7, b 1 [TOa2, b2...]\
With this command you can draw individual dots, lines, and shapes.
You supply color source (0-3), starting (a1, b1)and ending points
(a2. b2).
EXAMPLES:
DRAWL 100, 50—no endpoint specified, defaults to a1,b1 value for a2,b2 to create a dot a dot: lines: a shape:
DRAW, 10,10 TO
DRAW, TO 25,30
100,60
DRAW, 10.10TO
10,60 TO 100,60 TO
10,10
END
END
When the program executes an END statement, the program stops
RUNning immediately. You may use the CONT command to re-start the program at the statement following the END statement.
FOR...
TO...
STEP
FOR variable = start value TO end value [STEP increment |
This statement works with the NEXT statement to set up a section of the program that repeats for a set number of times. You may just want the
Plus/4 to count up to a large number so the program pauses for a few
136
seconds, in case you need something counted, or something must be done a certain number of limes (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 for the loop variable.
The logic of the FOR statement is as follows: First, the loop variable is set to the start value. When the program reaches a line with the com
mand NEXT, it adds the STEP increment (default = 1) to the value of
the loop variable and checks to see if it is higher than the end of loop
vaiue. If it is not higher, the next line executed is the statement im
mediately following the FOR statement. If the loop variable is larger than the end of loop number, then the next statement executed is the
one following the NEXT statement. See also the NEXT statement.
EXAMPLE:
10 FOR L - 1 TO 10
20 PRINT L
30 NEXT L
40 PRINT "I'M DONE! L - "L
This program prints the numbers from one to ten on the screen, fol lowed by the message I'M DONE! L = 11.
The end of loop value may be followed by the word STEP and another number or variable. In this case, the value following the STEP is added each time instead of one. This allows you to count backwards, by frac tions, 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 iast loop to start is the first one to end.
EXAMPLE OF NESTED LOOPS:
10 FOR L - 1 TO 100
20 FOR A - 5 TO 11 STEP 2
30 NEXT A
\
40NEXTL
This FOR... NEXT loop is "nested" in side the larger one.
137
n
~
~
H
~
~
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, it no character was typed, then a null (empty) character is returned, and the program continues without waiting for a key. There is no need to hit the RETURN key, and in fact the
RETURN key can be received with a GET.
The word GET is followed by a variable name, usually a string variable.
If 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 to be struck to continue. The GETKEY statement could also be used in this case. This command can only be executed within a program.
EXAMPLE:
10GETA$:IFA$ "A"THEN 10
This line waits for the
A key to be pressed to continue.
GETKEY
GETKEY variable list
The GETKEY statement is very similar to the GET statement. Unlike the GET statement, GETKEY waits for the user to type a character on the keyboard. This lets it be used easily to wait for a single char acter to be typed.
This command can only be executed within a program.
EXAMPLE:
10 GETKEY A$
This line waits for a key to be struck.
Typing any key will continue the program.
GET#
GET# file number.variable list
Used with a previously OPENed device or file to input one character at a time. Otherwise, it works like the GET statement. This command can only be executed within a program.
138
EXAMPLE:
GET#1,A$
GOSUB GOSUB//ne#
This statement is like the GOTO statement, except that the Plus/4 re members where it came from. When a line with a RETURN statement is encountered, the program jumps back lo the statement immediately following the GOSUB. The target of a GOSUB statement is called a subroutine. A subroutine is useful if 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 sei it up as a subroutine, and GOSUB to it from the different parts of the pro gram. See also the RETURN statement.
EXAMPLE;
20 GOSUB 800 means go to the subroutine begin ning at line 800 and execute it.
800 PRINT "HI THERE":RETURN
GOTO
or GO TO
GOTO line #
After a GOTO statement is executed, the next line to be executed will be the one with the line number following the word GOTO. When used in direct mode, GOTO line # allows you to start execution of the pro gram at the given !ine number without clearing the variables.
EXAMPLE:
10 PRINT-COMMODORE"
20 GOTO 10 -*—
The GOTO in line 20 makes line 10 repeat continuously until you press RUN/STOP
GRAPHIC GRAPHIC <mode [.clear option} I CLR>
This statement puts the Plus/4 in one of its 5 graphic modes:
139 -
~
~
~
Imode
:!
3
4
1
0 description normal text high-resolution graphics high-resolution graphics, split screen multicolor graphics multicolor graphics, split screen
When executed, GRAPHIC 1 -4 allocates a 10K bit-mapped area, and the start of the BASIC text area is moved above the hi-res area.
This area remains allocated even if the user returns to TEXT mode
(GRAPHIC 0). If 1 is given in the GRAPHIC statement as the second argument, the screen is also cleared. Executing a GRAPHIC CLR command de-allocates the 10K bit-mapped area, and makes it avail able once again for BASIC text and variables.
IF...
THEN
:ELSE]
IF expression THEN then-clause I:ELSE else-clause ]
IF...THEN lets the computer analyze a BASIC expression preceded by IF and take 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 expres sion 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, if present, must be in the same line as the IF-THEN part. 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.
Then
Pnnl
OK
If
Check.
XXD?
:_' ■■
End
140
EXAMPLE:
50 IF X>0 THEN PRINT "OK" :ELSE END
Checks the value of
X. If X isgreaterthan
0, the THEN clause is executed, and the
ELSE clause isn't. If
X is less than 0, the
ELSE clause is exe cuted and the THEN clause isn't.
INPUT INPUT \Prompt string;] variable list
The INPUT statement allows the computer to ask for data from the per- — son running the program and place it into a variable or variables. The program stops, prints a question mark (?) on the screen, and waits for the person to type the answer and hit the return . key.
The word iNPUT is followed by a variable name or list of variable —I
names separated by commas. There may be a message inside of
quotes before the list of variables to 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, they should be separated by commas when typed in. If not, the computer asks for the remaining values by printing two question marks (??). If you press the RETURNS key without INPUTting a value, the INPUT
— variable retains the value previously input for that variable. This state ment can only be executed within a program.
EXAMPLE:
10 INPUT "PLEASE TYPE A NUMBER11; A
20 INPUT "AND YOUR NAME";AS
30 INPUT B$
40 PRINT' 'BET YOU DIDN'T KNOW WHAT I WANTED!''
INPUT-# INPUT#Me nun / er.variable list
This works like INPUT, but takes the data from a previously OPENed file or device. No prompt string is allowed. This command can only be used in program mode.
EXAMPLE:
INPUT#2, A$, C,D$
n
~
~
LET I LET | vanab/e expression
The word LET is hardly ever used in programs, since it is not neces
sary, but the statement itself is the heart of all BASIC programs. When ever a variable is defined or given a value, LET is always implied. The variable name which is 10 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
40D$= "HELLO'1
LOCATE L0CATE ^-coordinate, y-coordinate
The LOCATE command lets you put the pixel cursor (PC) anywhere on the screen. The PC is the current location of the starting point ol the next drawing. Unlike the regular cursor, you can't see the PC, but you
can move \\ with the LOCATE command* For example:
LOCATE 160, 100
positions the PC in the center 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-coordmate and RDOT(1) to get the Y-coordinate. The color source of the dot at the PC can be found by printing RDOT(2). (In all drawing commands where a color option is available, you may select a value from 0 to 3, corresponding to the background, foreground, multicolor
1, or multicolor 2 as the color source.)
MONITOR
MONITOR
This command takes you out of BASIC into the built-in machine lan guage 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 hitting >_BETURN i sets you back to BASIC.)
142
NEXT NEXT Wanable,.,. .variable \
The NEXT statement is used with the FOR statement. When the com puter encounters a NEXT statement, it goes back to the corresponding
FOR statement and checks the loop variable. (See FOR statement (or more detail.) If the loop is finished, execution proceeds with the state ment after the NEXT statement. The word NEXT may be followed by a variable name, a list of variable names separated by commas, or no variable names. If there are no names listed, the last loop started is the one being completed. If the variables are given, they are completed in order from left to right.
EXAMPLE:
10FORL - 1TO 10:NEXT
20 FOR L - 1TO 10:NEXTL
30 FOR L = 1TO 10:FORM - 1 TO 10: NEXT M, L
—
_
_
QJI ON expression < GOTO GOSUB > line #7 [.line #2,...)
This command can make the GOTO and GOSUB statements into spe cial versions of the IF statement. The word ON is followed by a formula, then either GOTO or GOSUB. and a list of line numbers separated by commas, if rhe result of the calculation of the formula (expression) is
1, the first line in the list is executed. If the 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 the state ment following the ON statements. If the number is negative, an
ILLEGAL QUANTITY ERROR results.
EXAMPLE:
10 INPUT X:IF X- 0 THEN 10
20 ON X GOTO 50, 30, 30, 70
25 PRINT "FELL THROUGH":GOTO 10
WhenX=1.ON
sends control to the first line number in the list.
WhenX- 2, ON sends control to the second line (30), etc.
30 PRINT "TOO HIGH":GOTO 10
—
—
—
50 PRINT "TOO LOW":GOTO 10
70 END
143
-
-
-
OPEN 0PEN ffle #. device # [.secondary address \ [/'filename, type, mode"]
The OPEN statement allows the Plus/4 to access devices such as the cassette recorder and disk for data, a printer, or even the screen of the
Plus/4. 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 always a second number after the first called the device number. Device number 0 is the Plus/4 keyboard, 3 is the Plus/4 screen, 1 is the cassette recorder. 4 is the printer. 8 is usually the disk.
A zero (0) may be included in front of the device number digit (e.g., 08 for 8, which are interchangeable for the Plus/4). It is often a good idea to 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 of the cassette, this can be 0 for read, 1 for write, and 2 for write with endof-tape marker at the end. in the case of the disk, the number refers to the channel number. In the printer, the secondary addresses are used to set the mode of the printer. See the Plus/4 Programmer's Reference
Manual or the manua^ for each specific device for more information for more 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 of the file on tape or disk. The type and mode refer to disk files only, (File types are prg.seq, rel, and usr; modes are read and write.)
EXAMPLES;
10 OPEN 3,3
OPENS the SCREEN as a device.
10 OPEN 1,0
20 OPEN 1,1,0,"DOT"
OPENs the keyboard as a device.
OPENs the cassette for reading, file to be searched for is named DOT
OPEN 4,4
OPEN 15,8,15
OPENs a channel to use the printer.
OPENs the command channel on the disk.
144
5 OPEN 8,8,12,"TESTFILE,SEQ,WRITE"-»1 creates a sequential disk file for writing.
See also: CLOSE, CMD, GET#, INPUT#, and PRINT# statements, system variable ST, DS, and DSS.
PAINT PAINT [colorsource] [,[a,b] Imode) ]
Color source a,b mode
(0-3); (default is 1, foreground color) starting coordinate, seated {default is at the PC)
0 = paint an area defined by the color source selected
1 = paint an area defined by any nonbackground source
The PAINT command lets you fill an area with color. It fills in the area around the specified point until a boundary of the same color (or any non-background color, 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 color of color source you name (or any non-background when mode 1 is used), there is no change.
EXAMPLE
10 CIRCLE, 160.100.65,50draws outline of circle
-
20 PAINT, 160,100 fills in the circle with cotor
145
—
— n
POKE P0KE address, value
The POKE command allows you to change any value in the Plus/4 RAM memory, and lets you modify many of the Plus/4 Input/Output registers.
POKE is always followed by two numbers, (or equations). The first
number is a location inside the Plus/4 memory. This could have any value from 0 to 65535. The second number is a value from 0 to 255, which is placed in the location, replacing any value that was there previously.
EXAMPLE:
10 POKE 28000,8 Sets location 28000 to 8.
20 POKE 28*1000,27 Sets location 28000 to 27.
Note: PEEK is listed under FUNCTIONS.
PRINT PRINT Printlisl
The PRINT statement is the major output statement in BASIC. While the
PRINT statement is the first BASIC statement most people learn to use, there are many subtleties to be mastered here as well. The word PRINT can be followed by any of the following:
Characters inside of quotes
Variable names
Functions
Punctuation marks
("text lines")
(A, B, A$, XS)
(SIN(23), ABS(33))
(;,)
The characters inside of 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) printed. Functions also have their number values printed. Punctuation marks are used to help for mat 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 re sults in the next PRINT statement acting as if it is continuing the last
PRINT statement.
146
EXAMPLE'
10 PRINT "HELLO" HELLO
20 A$ = "THERE":PRINT "HELLO,"AS HELLO,THERE
30A=4:B = 2:PRINTA + B 6
50J = 41:PRINTJ;:PRINTJ-l
= A-B:PRINTA;B;C,D
RESULT
41 40
4 2 6
PRINT #
See also: POS(}, SPC(), and TAB() FUNCTIONS.
fiie#, print list
There are a few differences between this statement and the PRINT.
First of ail, the word PRINT# is followed by a number, which refers to the device or data file previously OPENed. The number is followed by a comma, and a list of things to be PRINTed. The comma and semicolon act in the same manner for spacing as they do in the PRINT statement.
Some devices may not work with TAB and SPC.
_
EXAMPLE:
100 PRINT#1,"HELLO THERE!",A$,B$.
PRINT \#filenumber] USING format list; print list;
USING
These statements let you define the format of string and numeric items you want to print to the screen, printer, or another device. Put the for mat you want in quotes. This is the format list. Then add a semicolon and a list of what you want printed in the format for the print list. The list can be variables or the actual values you want primed. For example:
5X = 32: Y= 100.23: A$ = "CAT"
10 PRINT USING "$##.##" ;13.25,X,Y
20 PRINT USING 1'###>#11;"CBM",A$
When you RUN this, line 10 prints out:
S13.25
$32.00
prints ***** instead of Y value because
Y has 5 digits, which does not conform to format list (as ex plained below)
-
147
Line 20 prints this:
CBM CAT
leaves three spaces
before printing
"CBM" as defined in format list
CHARACTER
Pound Sign (#)
Plus( + )
Minus (-)
Decimal Point (.}
Comma (,)
Dollar Sign ($)
NUMERIC
X
X
X
X
X
X
X
STRING
X
Equal Sign (=)
Greater Than Sign (>)
X
X
The pound sign (#) reserves room for a single character in the ouiput field. If the data item contains more characters than you have # in your format field, the following occurs:
• For a numeric item, the entire field is filled with asterisks (").
No numbers are printed.
For example:
10 PRINT USING "####" X
For these values for X, this format displays:
A-12.34
12
A = 567.89
A- 123456
568
••••
For a STRING item, the string data is truncated at the bounds of the field. Only as many characters are printed as there are pound signs
(#) in the format item. Truncation occurs on the right.
The plus ( + )and minus (-) signs can be used in either the first or last
position of a format field but not both. The plus sign is printed if the number is positive. The minus sign is printed if the number is negative,
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 format 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 the number is positive. If there 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 (.) 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 printed without any decimal places
When you specify a decimal point, the number of digits preceding the decimal point (including the minus sign, if the value is negative) must not exceed the number of # before the 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 the comma in the format list indicates where the comma appears in a printed number. Only commas within a number are printed. Unused commas to the left of the first digit appear as the filler 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 first character even if the character posi tion is specified as a comma.
EXAMPLES:
FIELD EXPRESSION
####
####
-.01
1
-100.5
-1000
RESULT
0.01-
1.0
-101
#S##
10
1
10
$1
COMMENT
Leading zero added.
Trailing zero added.
Rounded to no decimal places.
Overflow because four digits and minus sign cannot fit in field.
Decimal point added
Leading Ssign.
A dollar sign ($) symbol shows that a dollar sign will be printed in the number. If you want the dollar sign to float (always be placed before
_
_
149
—
—
—
—
— the number), you must specify at least one # before the dollar sign. If you specify a dollar sign without a leading #, the dollar sign is printed in the position shown in the format field. If you specify commas and/or a plus or minus sign in a format field with a dollar sign, your program prints a comma or sign before the dollar sign.
The four up arrows or carets (TTTT) symbol is used to specify that the number is to be printed in E + format. You must use # in addition to the
TTTTt0 specify the field width. The TTTT can appear either before or after the # in the format field.
You must specify four carets (TTTT) when you want to print a number in
E - format (scientific notation). If you specify more than one but fewer than four carets, you get a syntax error. If you specify more than four carets only the first four are used. The fifth caret is interpreted as a no text symbol.
An equal sign ( = ) is used to center a string in the field. You specify the field width by the number of characters (# and =) in the formal field. If the string contains fewer characters than the field width, the string is centered 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 fit into the field, the right-most characters are truncated and the string fills the entire field.
PUDEF PUDEF "1 through 4 characters"
PUDEF lets you redefine up to 4 symbols in the PRINT USING state-
ment. You can change blanks, commas, decimals points, and dollar signs into some other character by placing the 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 to appear in place of blanks.
Position 2 is the comma character. Default is a comma.
Position 3 is the decimal point.
Position 4 is the dollar sign.
150
EXAMPLES:
10 PUDEF""1
20 PUDEF " (S "
30PUDEF" .,"
40 PUDEF" ,.£M
PRINTs* in the place of blanks.
PRINTs @ in place of commas.
PRINTs decimal points in place of commas, and com mas in place of decimal points.
PRINTS English pound sign in place of S, decimal points in place of commas, and commas in place of decimal points.
Other signs are the default values.
„
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 variable list may contain both strings and numbers. Care must be taken to avoid reading strings where Ihe READ statement expects a number, which produces an ERROR message.
EXAMPLE:
READAS, GS.45
REM message
The REMark is just a note to whoever is reading a LIST of the program.
It may explain a section of the program, give information about the author, etc. REM statements in no way affect the operation of the program, except to add to its length (and therefore slow it down).
The word REM may be followed by any text, although use of graphic characters gives strange results.
-
151
n n n n
"
~ n n
EXAMPLE:
10 NEXT X: REM THIS LINE IS UNNECESSARY
RESTORE RESTORE i//ne#l
When executed in a program, the pointer to the item in a DATA statement which is to be read next is reset to the first item in the list- This gives you the ability to re-READ the information. If a [line #] follows the RESTORE statement, the pointer is set to that line. Otherwise the pointer is reset to the first DATA statement in the program.
EXAMPLE:
RESTORE 200
RESUME RESUME l//ne # /NEXT |
Used to return to execution after TRAPping an error. With no argu ments, RESUME attempts to re-execute the line in which the error occurred. RESUME NEXT resumes execution at the next statement following the statement containing the error; RESUME line # will
GOTO the specific line and begin execution there.
RETURN return
This statement is always used with the GOSUB statement. When the program encounters a RETURN statement, it goes to the statement immediately following the last 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 <7/0>
The scaling of the bit maps in multicolor and high resolution modes can be changed with the SCALE command. Entering:
SCALE 1 turns scaling on. Coordinates may then be scaled from 0 to 1023 in both X and Y rather than the normal scale values, which are:
152
multicolor mode high resolution mode
X = 0 to 159 Y = 0 to 199
0 to 199
Scaling can be turned off by entering 'SCALE 0'.
0 to 319
SCNCLR SCNCLR
Clears the current screen, whether graphics, text, or both
(split screen).
SOUND SOUND voice #- frequency control, duration
This statement produces a SOUND using one of three voices with a frequency control in the range 0 - 1023 for a duration of 0 - 65535
60thsof a second.
V Voice
Voice 1 (tone)
Voice 2 (tone)
Voice 2 (white noise)
If a SOUND for voice N is requested, and the previous SOUND for the same N is still playing, BASIC waits for the previous SOUND to com plete. SOUND with a duration of 0 is a special case. It causes BASIC to turn off the current SOUND for that voice immediately, regardless of the time remaining on the previous SOUND. See the MUSIC NOTE
TABLE (SECTION 11) for the frequency control values that correspond to real notes.
EXAMPLE:
SOUND 2, 800, 360
Plays a note using voice 2 with fre quency set at 800 for one minute
SSHAPE GSHAPE SSHAPE and GSHAPE are used to save and restore rectangular areas
of multicolor or high resolution screens using BASIC string variables.
The command to save an area is:
SSHAPE string variable, a1,b1 [,a2,b2\ string variable String name to save data in
_
153
a1 ,b1 a2,b2
Corner coordinate (scaled)
Corner coordinate opposite (a1,b1)
(default is the PC)
Because BASIC limits string lengths to 255 characters, the size of the area you may save is limited. The string size required can be calcu lated using one of the following (unsealed) formulas:
L(mcm) - INT ((ABS(a1 -a2) + 1) / 4 + .99) * (ABS(b1 - b2) + 1) + 4
L(h-r) = INT((ABS(a1-a2) + 1)/8+ .99) * (ABS(b1 - b2) + 1) + 4
(mem) refers to multi-color mode; (h-r) is high resolution.
The shape is saved row by row. The last four bytes of the string contain the column and row lengths less one (i.e.: ABS (a1 -a2)) in low/high byte format (if scaled divide the lengths by 3.2 (X) and 5.12 (Y)).
The command to display a saved shape on any area of the screen:
GSHAPE string t [a,b\ [.mode] J string a,b mode
Contains shape to be drawn
Top left coordinate telling where to draw the shape (scaled the default is the PC)
Replacement mode:
0: place shape as is (default)
1: place field inverted shape
2: OR shape with area
3: AND shape with area
4: XOR shape with area
EXAMPLES:
SSHAPE 1'SHIP1'TO,O
GSHAPE "SHIP'1,,,!
Saves shape on screen area from the upper left corner to the cursor under the name "SHIP"
Displays inverted "SHIP" shape with the top left corner positioned where the cursor is located
154
STOP ST0P
This statement halls the program. A message, BREAK IN LINE #, where the # is the line number containing the STOR The program can be re-started at the statement following STOP if you use the
CONT command. The STOP statement is usually used while de bugging a program.
SYS address
The word SYS is followed by a decimal number or numeric variable in the range 0 to 65535. The program begins executing the machine language program starting at that memory location. This is similar to the USR function, but does not pass a parameter. See the Plus/4
Programmer's Reference Guide for information about machine language programs.
TRAP TRApl'/ne#|
When turned on. TRAP intercepts all error conditions (including the
STOP KEY) except "UNDEF'D STATEMENT ERROR". In Ihe event of any execution error, the error flag is set, and execution is transferred to the line number named in the TRAP statement. The line number in which the error occurred can be found by using the system variable
EL. The specific error condition is contained in system variable ER.
The string function ERRS(ER) gives the error message correspond ing to any error condition ER.
—
—
—
NOTE: An error in a TRAP routine cannot be trapped.
The RESUME statement can be used to resume execution.
TRAP with no iine# argument turns off error TRAPping.
_
TRON TR0N
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 that statement is printed.
—
155
—
TROFF TROFF
This statement turns trace mode off.
VOL VOL vo!ume level
Sets the current VOLume level for SOUND commands. VOLume
may be set from 0 to 8, where 8 is maximum volume, and 0 is off.
VOL affects both voices.
WAIT WAIT address, value 1 [, value 2]
The WAIT statement is used to halt the program until the contents of a location in memory changes in a specific way. The address must be in the range from 0 to 65535. Value 1 and value 2 must be in the range from 0 to 255.
The content of the memory location is first exclusive-ORed with value 2
(if present), and then logically ANDed with value 1. If the result is zero, the program checks the memory location again. When the result is not zero, the program continues with the next statement.
156
MORE ON
GRAPHIC
STATEMENTS
There are a few concepts that apply to all of 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 the PC. In addition, the locate command allows you to reposition the PC without drawing anything.
Wherever you would use X,Y 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 the right. A minus sign before the X value moves the PC to the left. Similarly, a minus sign before the Y coordinate moves the PC up, while a plus sign moves the PC down. For example:
LOCATE +100,-25
DRAWl, + 10, + 10TO100,100 moves the PC right
100 pixels and up 25.
draws a line 10 pixels right and 10 pixels below the current value of the PC to the absolute point 100,100.
You can also specify a distance and an 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.
157 —
FUNCTIONS Numeric functions are classified as such because they return num
bers. The functions they perform range from calculating mathematical functions to specifying a screen location. Numeric functions follow
Numeric
Functions
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 positive value of the argument X.
ASC(X$)
This function returns the ASCII code (number) of the first character ofX$.
ATN(X) (arctangent)
Returns the angle whose tangent is X, measured in radians.
COS{X) (cosine)
Returns the value of the cosine of X, where X is an angle measured in radians.
DEC (hexadecimal-string)
Returns decimal value of hexadecimal-string (0< hexadecimal string<FFFF)
EXAMPLE:
N=DEC("F4")
EXP(X)
Returns the value of the mathematical constant e (2.71828183) raised to the power of X.
FNxx(x)
Returns the value of the user-defined function xx created in a DEF
FNxx statement.
INSTR (string 1, string 2 \ starting-position \)
Returns position of string 2 in string 1 at or afterthe (starting-position].
The starting-position defaults to the beginning of string 2. If no match is found, a value of 0 is returned.
158
EXAMPLE
PRINT INSTR('THE CAT IN THE HAT", 'CAT") the result is 5, because CAT starts at the fifth character in string 1
INT(X) (integer)
Returns the integer portion of X, with all decimal places to the right of the decimal point removed. The result is always less-than or equal to X.
Thus, any negative numbers with decimal places become the integer less-than their current value (e.g. INT(-4.5)= -5).
If the INT function is to be used for rounding up or down, the form is
INT(X+/- .5),
—
—
—>
,
_
EXAMPLE.
X=IMT(X*100 + .5)/100
_
Rounds to the next highest penny.
—■
JOY (n) _
When n = 1 n = 2
Position of joystick #1
Position of joystick # 2 *—■
Any value of 128 or more means the fire button is also depressed. The direction is indicated as follows —
_ fire = 128+
LEFT 7
8
UP
1
0
2
3 RIGHT ~
6 4
5
DOWN
— u
EXAMPLE
JOY(2)=135 joystick #2 fires to the left
LOG(X) (logarithm)
This returns the natural log of X. The natural log is log to the base e
(see EXP(X)). To convert to log base 10, divide by LOG( 10).
__
~~
—
—
—
PEEK(X)
This function gives the contents of memory location X, where X is located in the range of 0 to 65535, returning a result from 0 to 255.
This is often used in conjunction with the POKE slatement.
RCLR(N)
Returns current color assigned to source N (0 < N < 4}
(0= background, 1 = foreground, 2 = multicolor 1,3= multicolor
2,4 = border).
RDOT(N)
Returns information about the current position of the pixel cursor (PC) at XPOS/YPOS.
N - 0 for XPOS
1 for YPOS
2 color source
RGR(X)
Returns current graphic mode (X is a dummy argument).
RLUM(N)
Returns current luminance level assigned to source N
RND{X) (random number)
This function returns a random number between 0 and 1. This is useful in games, to simulate dice rolls and other elements of chance, and is also used in some statistical applications. The first random number should be generated by the formula RND(-TI), to start things off dif ferently every time. After (his, 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 for X seeds the random number generator using X and gives a random number sequence. The use of 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)*6+1). First the random number from 0-1 is multiplied by 6, which expands the range to 0-6 (actually, greater 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 digit from 1 to 6.
To simulate 2 dice, add two of the numbers obtained by the above for mula together.
160 ^^^^^^^^^^^^^^^^^™
__
EXAMPLE: J
= INT{RND(l)*6)+INT(RND(l)t6) + 2
= INT(RND(1)*1000) + 1
= INT(RND(l)*150) + 100
Simulates 2 dice.
Number from 1-1000.
Number from 100-249.
SGN(X) (sign)
This function returns the sign, as in positive, negative, or zero, of X. The result is + 1 if positive, 0 if zero, and - 1 if negative.
-J
SIN{X) (sine)
This is the trigonometric sine function. The result is the sine of X, where
Xisan angle in radians.
_
SQR(X) (square root)
This function returns the square root of X, where X is a positive number or 0. If X is negative, an ILLEGAL QUANTITY ERROR results.
TAN{X) (tangent)
This gives the tangent of X, where X is an angle in radians.
USR(X)
When Ihis function is used, the program jumps to a machine language program whose starting point is contained in memory locations 1281 and 1282. The parameter X is passed to the machine language program in the floating point accumulator. Another number 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 Plus/4 PROGRAMMERS REFERENCE GUIDE for more details on this, and on machine language programming.
VAL(XS)
This function converts the string X$ into a number, and is essentially the inverse operation from STR$. The string is examined from the left most character to the right, for as many characters as are in recognizable number format. If the Plus/4 finds illegal characters, only the portion of the string up to that point is converted.
__
—.
EXAMPLE:
10X = VAL("123.456")
10X = VAL("3E03")
10X = VAL("12A13B")
161
—
10 X = VAL("RIUO17*M)
10 X = VAL("-1.23.23.23")
X = 0
X=-1.23
Strinp Stnn9 functions differ from numeric functions in that they return
Functions cnaracters> graphics or numbers from a string (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 condition N (see TRAP)
HEX$(N)
Returns a 4 character string containing the hexadecimal representa tion of value N (0 < N < 65535)
LEFTS(XS.X)
This returns a string containing the leftmost X characters of XS.
LEN(X$}
Returns the number of characters (including spaces and other symbols) in the string X$.
MID$(X$,S,X)
This returns a string containing X characters, starting from the Sth character in XS. MID$ can also be used on the left side of assignment statement as a pseudo-variable as well as a function. MID$ (string variable, starting position, length) = source string.
This function reassigns values of positions (starting position) through
(starting 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 DOG IN THE HAT":
20 PRINT A$
30MID$(A$,5,3)-"CAT"
40 PRINT A$
162
RIGHT$(X$,X)
This returns the right-most X characters in XS.
STR$(X)
This returns a string which is identical to the PRINTed version of X$.
EXAMPLE:
A$ = STR$(X)
Other fre(x)
Functions This function returns the number of unused bytes available in memory.
X is a dummy argument.
POS{X)
This function returns the number of the column (0-79) where the next
PRINT statement begins on the screen. X is a dummy argument.
SPC(X)
This is used in the PRINT statement to skip over X spaces. X can have a value from 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 0 to 255
7T{PI)
The 77 symbol, when used in an equation, has the value of 3.14159265.
—
_
"
__
163
VARIABLES
& OPERATORS
Tne plus/4 uses three types of variables in BASIC. These are: normal numeric, integer numeric, and string (alphanumeric) variables.
Normal NUMERIC VARIABLES, also called floating point variables.
Variables can nave anY value from 3ato ~3B, with up to nine digits of accuracy.
When a number becomes larger than nine digits can show, as in N ~10 or N10, the computer displays it in scientific notation form, with the number normalized to 1 digit and eight decimal places, followed by the letter E and the power of ten by which the number is multiplied. For example, the number 12345678901 is displayed as 1.234356789E+10.
INTEGER VARIABLES can be used when the number is from +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 point variables, particularly when used in an array.
STRING VARIABLES are those used for character data, which may contain numbers, letters, and any other character that the Plus/4 can make An example of a string variable is "Plus/4".
Variablfi Var|able names may consist of a single letter, a letter folowed by a
Names num':)er- or two letters. Variable names may be longer than 2 charac
ters, but only the first two are significant.
An integer variable is specified by using the percent {%) sign after the variable name. String variables 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, BZS
ARRAYS are lists of variables with the same name, using an extra number (or numbers) to specify an element of the array. Arrays are defined using the DIM statement, and may be floating point, integer, or string variables arrays. The array variable name is followed by a set of parentheses () enclosing the number of the variable in ihe list.
EXAMPLES:
A(7),BZ%(11),A$(87)
Arrays may have more than one dimension. A two dimensional array
may be viewed as having rows and columns, with the first number identifying the row and the second number in the parentheses identi fying the column (as if specifying a certain grid on a map).
Reserved
Variable
Names
EXAMPLES:
A(7,2),BZ%(2,3,4),Z$(3,2)
There are seven variable names which are reserved for use by the
Plus/4, and may not be used for another purpose. These are the vari ables DS, DSS. ER. EL, ST.TI, and TIS. You also can't use KEYWORDS such as TO and IF, or any names thai contain KEYWORDS, such as
SRUN. RNEW, or XLOAD as variable names.
ST is a status variable for 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
Plus/4 Programmer's Reference Guide, but in general, if ihe value of
ST is 0 the operation was sucessful.
Tl and TIS are variables that relate to the real-time clock built into the
Plus/4. The system clock is updated every 1/60th of a second. It starts at 0 when the Plus/4 is turned on, and is reset only by changing the value of TIS. The variable Tl gives you the current value of Ihe clock in
1/60ths of a seconds.
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 clock to 10 15 and 30 seconds (AM)
The value of the clock is lost when the Plus/4 is turned off. It starts at zero when the Plus/4 is turned on, and is reset to zero when the value of the clock exceeds 235959 (23 hours, 59 minutes and 59 seconds).
The variable DS reads the disk drive command channel, and returns the current status of the drive. To get 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.
165
n
n
166
ER, EL, and ERRS are variables used in error trapping routines. They are usually only useful within a program. ER returns the last error en countered since the program was RUN. EL is the line where the error occurred. ERRS is a function which allows your program to print one of the BASIC error messages. PRINT ERR$(ER) prints out the proper error message.
BASIC Tne ARITHMETIC operators include the following signs:
OPERATORS + addition
subtraction
/
* multiplication division raising to a power (exponentiation)
On a line containing more than 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, then 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 these operations to occur in a dif ferent order, Plus/4 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 par entheses as right parentheses, or you will get a SYNTAX ERROR message when your program is run.
There are also operators for equalities and inequalities, called
RELATIONAL operators Arithmetic operators always take priority over relational operators.
=
<
>
< = or =<
>= or =>
<> or >< is equal to is less than is greater than is less than or equal to is greater than or equal to is not equal to
Finally, there are three LOGICAL operators, with lower priority than both arithmetic and relational operators:
—*
—
—
AND
OR
NOT
These are used most often to join multiple formulas in IF... THEN statements. When they are used with arithmetic operators, they are evaluated last (i.e.. after + and -).
167
— EXAMPLES
IF A = B AND C=D THEN 100
IFA = B0RC = D THEN 100 requires both A-B & C = D to be true.
allows either A=B or C=D to be true.
A = 5:B=4:PRINT A = B
A=5:B=4:PRINT A>B displays a value of 0 displays a value of -1
PRINT123AND15:PRINT5OR7 displays 11 and 7
"
168
SECTION 2
Basic 3.5
Abbreviations
KEYWORD
ABS
ASC
ATN
AUTO
BACKUP
BOX
CHAR
CHR$
CIRCLE
CLOSE
CLR
CMD
COLLECT
COLOR
CONT
COPY
COS
DATA
DEC
DEFFN
::E_ETE
DIM
DIRECTORY
DLOAD
DO
DRAW
DSAVE
END
ERRS
EXP
FOR
FRE
GET
GETKEY
GET#
GOSUB
GOTO
GRAPHIC g getk e f f d de d d d a a b
b
ch c c c a a c c
CO
CO c
CO
ABBREVIATION
1
H
0
L
M
L
L
0
P
B
S
T
U
A
0
A
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT none d SHIFT A none
E
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
1
R
L none d d e e
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
E
E
X
0
R
R
S
N
R none
90 g g
SHIFT
SHIFT
SHIFT
S
0
R
TYPE function—numeric function—numeric function—numeric command command statement statement function—string statement statement statement statement command statement command command function—numeric statement function—numeric statement command statemenl command command statement statement command statement function—string function—numeric statement function—numeric statement statement statement statement statement statement
169
_
~
-
n
-
170
KEYWORD ABBREVIATION
GSHAPE
HEADER
HEXS
IF... GOTO
IF...THEN... ELSE
INPUT
INPUT#
INSTR
INT
JOY g be hi in i j
KEY
LEFTS
LEN
LET k le
1
LIST
LOAD
LOCATE
LOG
LOOP
MID$
MONITOR
NEW
NEXT
ON...GOSUB on.
ON...GOTO
OPEN
on
PAINT
PEEK
POKE
POS
PRINT#
PRINT USING
PUDEF
RCLR
RDOT
READ
REM lo lo m
■■•, n 1 go
...g
0
?
p
?us
p r r r
1
1 p p p
SHIFT
SHIFT
SHIFT none none none
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT none
S
A
E
N
S
U c
D
1
R s
0 p
in
I
1
E
0
C
0
0
E
0
A
E
0
TYPE statement command function—string statement statement statement statement function—numeric function—numeric function—numeric command function—string function—numeric statement command command statement function—numeric statement function—string statement command statement statement statement statement statement function—numeric statement function—numeric statement statement statement statement function—numeric function—numeric statement statement
TIS
TRAP
TROFF
TRON
UNTIL
USR
VAL
VERIFY
VOL
WAIT
WHILE
KEYWORD
RENAME
RENUMBER
RESTORE
RESUME
RETURN
RGR
RIGHTS
RLUM
RND
RUN
SAVE
SCALE
SCNCLR
SCRATCH
SGN
SIN
SOUND
SPC(
SQR
SSHAPE
STatus
STOP
STR$
SYS
TAB(
TAN
Tl re ren re res re s sc s i r r r r s sc s s s s s
ABBREVIATION
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
SHIFT
0
P
1
G
A
C
R
0 s
N u
A
1
L u
T
G
N
U s none s st s t
SHIFT
SHIFT
SHIFT
SHIFT
Y
A
T
R none none none u w w
V
V tro tr u
■ SHIFT
SHIFT
SHIFT
SHIFT
SHIFT none
SHIFT
SHIFT
SHIFT
SHIFT
0
A
H
R
F
0
N
3
TYPE command command statement statement statement function—numeric function—string function—numeric function—numeric command command statement statement command function—numeric function—numeric statement function—special function—numeric statement reserved—numeric variable statement function—string statement function—special function—numeric reserved—numeric variable reserved—string variable statement statement statement statement function—special function—numeric command statement statement statement
171
—
-
-
_
_
—
—
—
—
SECTION 3 Converting Standard BASIC Programs To Commodore BASIC 3.5
If you have programs written in a BASIC other than Commodore
BASIC, some minor adjustments may be necessary before running them on the Plus/4. Here are some hints to make the conversions easier.
Conversion
Programs
String Dimensions
Delete all statements that are used to declare the length of strings.
A statement such as DIM A$(l,J), which DIMensions a string array for J elements of length I, should be converted to the Commodore
BASIC statement DIM A${J).
Some BASICS use a comma or ampersand for string concatenation
(linking). Each of these must bexhanged to a + sign, which is the
Commodore BASIC 3.5 operator for string concatenation.
In Commodore BASIC, the MIDS. RIGHTS, and LEFTS functions are used to lake substrings of strings. Forms such as A$(l) to access the
Ith character in AS, or AS(I.J) to take a substring of AS from position
I to J, must be changed as follows:
Other BASIC
A$(l) - XS
AS(I.J) = XS
Commodore BASIC 3.5
MIDS(AS,I.J) = X$
MID$(A$,I,J) = X$
Multiple Assignments
To set B and C equal to zero, some BASICs allow statements of the form: 10 LET B- C =0
Commodore BASIC would interpret the second sign as a logical operator and set B = -1 if C = 0. Instead, convert this statement to:
10C = 0 B = 0
Multiple Statements
Some BASICs use a backslash (/) to separate multiple statements on a line. With 3.5 BASIC, use a colon (:) to separate all statements.
Mat Functions
Programs using the MAT functions available on some BASICs must be rewritten using FOR.. .NEXT loops to execute properly.
172
Reprogramming Function Keys
You can reprogram the function keys to match the function keys on the
Commodore 64 and VIC-20. (This also makes program conversions
from those machines easier).
To reprogram the keys, put the following line into your program:
H
10FORI=1 T08:KEYI, CHR$(I+132): NEXT
Now whenever you type a function key, it sends a non-printing character, from 133 to 140, like the Commodore 64 does. To check for — this in a program, you can use this method;
20 GETKEY A$: IF ASC(A$) -133 THEN PRINT "FUNCTION KEY 1
HIT": GOTO 20
30 IF ASC(A$) > 133 AND ASC(A$) < 141 THEN PRINT "SOME
OTHER FUNCTION KEY HIT"
40 GOTO 20 —
After your program is done, you have to redefine the keys again if you want them to say directory, dload, etc. You can do this by hand, in a program, or by resetting the Plus/4.
—
173
-
~ n
SECTION 4 These error messages are printed by BASIC. You can also PRINT
the messages through the use of the ERR$() function. The error number refers only to the number assigned to the error for use with this function.
Error Messages
ERROR # ERROR NAME
1 TOO MANY FILES
2
3
5
6
7
8
9
10
11
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 atone time.
An attempt was made to open a file using the number of an already open file.
The file number specified in an I/O statement must be opened before use.
Either no file with that name exists (disk) or an end-of-tape marker was read (tape).
The required I/O device not available.
An attempt made to GET or
INPUT data from a file that 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 the disk drive generally re quires a file name.
An attempt made to use a device improperly (SAVE to the screen, etc.)
Either loops are nested in correctly, or there is a variable name in a NEXT statement that doesn't correspond with one in a FOR.
A statement is unrecogniza ble by BASIC. This could be
174
13
14
15
16
18
19
RETURN WITHOUT
GOSUB
OUT OF DATA
ILLEGAL QUANTITY
OVERFLOW
OUT OF MEMORY
UNDEF'D STATEMENT
BAD SUBSCRIPT
REDIM'D ARRAY
DIVISION BY ZERO
ILLEGAL DIRECT because oi missing or extra parenthesis, misspelled keyword, etc.
A RETURN statement en countered when no GOSUB statement was active.
A READ statement en countered, without data leftunREAD.
A number used as the argument of a function or statement is outside the allowable range.
The result of a compu tation is larger than the largest number allowed
(1.701411833E+38)
Either there is no more room for program and program variables, or there are loo many DO, FOR, or GOSUB statements in effect.
A line number referenced doesn't exist in the program.
The program tried to refer ence an element of an array out of the range specified by the DIM statement.
An array can only be DIMensioned once. If an array is referenced before that array is DIM'd. an automatic DIM (to
10) is performed.
Division by zero is not allowed.
INPUT or GET statements are only allowed within a program.
, i
175
22
23
!4
25
26
33
34
35
29
30
11
32
27
28
TYPE MISMATCH
STRING TOO LONG
FILE DATA
FORMULA TOO
COMPLEX
CANT CONTINUE
UNDEF'D FUNCTION
VERIFY
LOAD
BREAK
CAN'T RESUME
LOOP NOT FOUND
LOOP WITHOUT DO
DIRECT MODE ONLY
NO GRAPHICS AREA
This occurs when a number is used in place of a string or vice-versa.
A string can contain up to 255 characters.
Bad data read from a tape file.
Simplify the expression
(break into 2 parts or use fewer 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 halt program execution
A RESUME statement en countered without TRAP statement in effect
The program has encoun tered a DO statement and cannot find the correspond ing LOOP
LOOP encountered without a
DO statement active.
This command is allowed only in direct mode, not from a program.
A command (DRAW, BOX, etc.) to create graphics encountered before the
176
36 BAD DISK
GRAPHIC command
was executed.
An attempt failed to HEADER a diskette, because the quick header method (no ID) was attempted on an unformatted diskette, or :he diskette is bad.
— u
_
_
177
-
~
-
DESCRIPTION
OF
DOS
ERROR
MESSAGES
These error messages are returned through the DS and DS$ reserved variables.
NOTE: Error message numbers less than 20 should be ignored with the exception of 01, which gives information aboul the num ber of files 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 in data block)
READ ERROR
(byte decoding error)
The disk controller is unable to lo cate the header of 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 seated diskette. Can also indicate a hardware failure.
The disk controller has been re quested to read or verify a data block that was not properly 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 there is an error in one or more of the data bytes. The data has been read into the DOS memory, but the checksum over the data is in 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 to an invalid bit pattern in the data
178
2E
:\
27
28
3 )
WRITE ERROR
(write-verify error)
WRITE PROTECT ON
READ ERROR
(checksum error in header)
WRITE ERROR
(long data block)
DISK ID MISMATCH
SYNTAX ERROR
(general syntax) byte. This message may also indicate grounding problems.
This message is generated if the controller detects a mismatch between the written data and the data in the DOS memory.
This message is generated when the controller has been requested to write a data block while the write protect switch is depressed.
Typically, this is caused by using a diskette with a write protect tab over the notch.
The controller has detected an error in the header ol the re quested data block. The block has not been read into the DOS memory. This message may also indicate grounding problems.
The controller attempls to detect the sync mark of the next header after writing a data block. If the sync mark does not appear within a pre-determined time, the error message is generated. The error is caused by a bad diskette format
(the data extends into the next block), or by hardware failure.
This message is generated when the controller has been requested to access a diskette which has not been initialized- The message can also occur if a diskette has a bad header.
_
The DOS cannot interpret the command sent to the command channel. Typically, this is caused
179
-
-
~
~
32
33
34
■■:
50
51
SYNTAX ERROR
(invalid command]
SYNTAX ERROR
(invalid command)
SYNTAX ERROR
(invalid file name)
SYNTAX ERROR
(no file given) by an illegal number of file names, or patterns are illegally used. For example, two file names may appear on the left side o( the
COPY command.
The DOS Goes not recognize the command- The command must start in the first position.
The command senl is longer than
58 characters.
Pattern matching is invalidly used in the OPEN or SAVE command.
The file name was left out of a command or the DOS does not recognize it as such. Typically, a colon(:} has been left out of the command.
SYNTAX ERROR
(invalid command)
This error may result if the com mand rent to command channel
(secondary address 15) is unrec ognized by the DOS.
RECORD NOT PRESENT Result of disk reading 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. If the intent is to ex pand the file by adding the 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. Information is truncated. Since the carriage re-
180
60
61
62
63
64
FILETOO LARGE
WRITE FILE OPEN
FILE NOT OPEN
FILE NOT FOUND
FILE EXISTS
FILE TYPE MISMATCH
NO BLOCK turn which is sent as a record ter minator is counted in the record size, this message will occur if the total characters in the record (in cluding the final carriage return) exceeds the defined size.
Record position within a relative file indicates that disk overflow will result.
This message is generated when a write file that has not been closed is being opened for reading.
This message is generated when a file is being accessed that has not been opened in the DOS.
Sometimes, in this case, a mes sage is not generated; the re quest is simply ignored
The requested file does not exist on the indicated drive.
The file name of the file being created already exists on the diskette.
The file type does not match the file type in the directory entry for the requested file,
This message occurs in conjunc tion with the B-A command. It indicates that the block to be allo cated has been previously allo cated. The parameters indicate the track and sector available with the next highest number. If the parameters are zero (0), then all blocks higher in number are in use.
181 '"
61
67
12
ILLEGAL TRACK
AND SECTOR
ILLEGAL SYSTEM
TORS
NO CHANNEL
(available)
DIRECTORY ERROR
DISK FULL
DOS MISMATCH (73,
CBMDOSV2.61541)
The DOS has attempted to ac cess a track or block which does not exist in the formal 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 requested channel is not available, or all channels are in use. A maximum of five sequential files may be opened at one time to the DOS- Direct access channels may have six opened files.
The BAM does not match the internal count. There is a problem in the BAM allocation or the BAM has been overwritten in 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 the blocks on the diskette are used or the directory is at its entry limit. DISK FULL is sent when two blocks are available on the 1541 to allow the current file to be closed.
DOS 1 and 2 are read 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
182
74 DRIVE NOT READY attempt is made to write upon a disk which has been formatted in a non-compnlibie format. (A utility routine is available to assist in converting from one format to
— another.) This message may also „ appear after power up.
An attempt has been made to access the Floppy Disk Drive without any diskette present.
—
183
~ n
H
-
SECTION 5 Introduction
TEDMON is a built-in machine language program which lets you easily write machine language programs. TEDMON includes a machine lan guage monitor, a mini assembler, and a disassembler.
Machine language programs written using TEDMON can run by them selves, or be used as very fast 'subroutines' for BASIC programs since
TEDMON has the ability to coexist peacefully with BASIC.
Tedmon a
Commands c
L
M
R
S
T
G
H
D
F
ASSEMBLE
COMPARE
Assemble a line of 6502 code
Compare two sections of memory and report differences.
DISASSEMBLE Disassemble a line of 6502 code.
FILL Fill memory with the specified byte.
GO
HUNT
Start execution at the specified address.
Hunt through memory for all occurrences of certain bytes.
LOAD
MEMORY
REGISTERS
SAVE
TRANSFER
Load a file from tape or disk.
Display the hexadecimal values of Memory locations.
Display the 6502 Registers.
Save to tape or disk.
Transfer code from one section of memory to another.
V
X
VERIFY
EXIT
Compare memory with tape or disk.
Exit TEDMON.
(period) Assembles a line of 6502 code
> (greater than) Modifies memory
(semi-colon) Modifies 6502 Register displays
Location $7F8 controls whether TEDMON looks at ROM or RAM above
$8000, If this location is set to 0, TEDMON displays BASIC and the
KERNAL when commanded to do a disassembly or memory dump
184 ^^^^^^^^^^^^^^^^^^^^^™
above $8000. If this location is set to $80 TEDMON displays the RAM under BASIC and the KERNAL. This is often convenient for machine language program development. Note that location $7F8 does not affect the GO command. The GO command starts execution in the current memory map (ROM on or RAM on) regardless of the setting of location $7F8.
Using
Tedmon
Enter TEDMON by typing:
MONITOR
TEDMON responds by displaying the 6502 registers and flashing the cursor. The cursor is your prompt that lets you know that TEDMON is waiting for your commands
Command command: a
Descriptions PURPOSE: Enter a line of assembly code.
SYNTAX: A <addres$> <opcode mnemonio <operand>
<addres$> A hexadecimal number indicating the location in memory to place the opcode.
<opcode mnemonio A standard MOS technology assembly lan guage mnemonic, e.g. LDA, STX, ROR, etc.
<operand> The operand, when required, can be of any of the legal addressing modes. (For zero-page modes a 2 digit hex number is re quired whose value is less than $100. For non-zero page addresses
4 digit hex numbers are required.)
A return is used to indicate the end of the assembly line. If there
are any errors on me ire. a question mark Is displayed to indicate an
error, and the cursor moves to the next line. The screen editor can be used to correct any errors on the line.
After a line of code is successfully assembled, the assembler prints a prompt containing the next legal memory location for an instruction, so
A and the line number do not have to be typed more than once when typing assembly language programs into the Plus/4.
185
n
—
—
EXAMPLE:
.A1200LDX#$00
.A 1202
NOTE A period (.) is equal to the ASSEMBLE command.
EXAMPLE:
. 2000 LDA #$23
COMMAND: C
PURPOSE Compare two areas of memory
SYNTAX: C oddress 1 > oddress 2> oddress 3>
<Address 1 > is a hexadecimal number indicating the start address of the area of memory to compare against.
<Address 2> is a hexadecimal number indicating the end address of the area of memory to compare against.
<Address 3> is a hexadecimal number indicating the start address of the other area of memory to compare with.
If the two areas of memory are the same, then TEDMON prints a
RETURN, indicating that the second area of memory is the same as the first. The addresses of any bytes in the two areas which are different are printed out on the screen.
COMMAND: D
PURPOSE Disassemole machine code into assembly language
mnemonics and operands.
SYNTAX: D [<address> | [oddress 2>\
<address > A hexadecimal number setting the address to start the disassembly.
<addres$ 2> An optional hexadecimal ending address of code to be disassembled.
The format of the disassembly is only slightly different than the input format of an assembly. The difference is that the first character of a
186
disassembly is a period rather than an A (for readability), and the
Hexadecimal of the code is listed as well.
A disassembly listing can be modified using the screen editor. Make any changes to the mnemonic or operand on the screen, then hit a carriage return. This enters the line and call the assembler (or further modifications
A disassembly can be paged. Typing a D causes the next page of dis assembly to scroll onto the screen
—
—-
EXAMPLE: D 3000 3004
3000 A900
3002 FF
3003 DO 2B
LDA#S00
TO.
BNE $3030 —
COMMAND: F (FILL)
PURPOSE. Fill a range of locations with a specified byte.
SYNTAX: F oddress 1> oddress 2> <byte> oddress 1 > The firs! location to fill with the <by!e> oddress 2> The last location to fill with the <byte>
<by(e valued A 1 or 2 digit hexadecimal number to be written
This command is useful for initializing data structures or any other
RAM area.
EXAMPLE F 0400 0518 EA
Fills memory locations from 50400 to S0518 with SEA (a NOP instruction )
COMMAND: G
PURPOSE Begin execution of a program at a specified address.
SYNTAX: G[ oddress >}
Oddress > An optional argument specifying the new value of the program counter and address where execution is to start When
<address> is left out. execution begins at the current PC. (The
current PC can be viewed using the R command.)
The GO command restores all registers {displayable by the R com mand) and begins execution at the specified starting address. Caution
__
_ i
187"
-
is recommended in using the GO command. To return to TEDMON
after executing a machine language program, use the BRK instruction.
EXAMPLE. G140C
Execution begins at location S140C.
COMMAND: H (HUNT)
PURPOSE. Hunt through memory within a specified range for all occurrences of a set of bytes.
SYNTAX: H <address 1> <address2> <data> oddress 1 > beginning address of hunt procedure oddress 2> ending address of hunt procedure
<data> data set to search for data may be hexadecimal or an
ASCII string. An ASCII is specified by preceding the first character with
a single quote, eg, 'STRING. Data may be single or multiple element argument. When multiple and in hexadecimal each number must be separated by a space.
EXAMPLE HCOOOFFFF'READ
HA000A101 A9FF4C
Search for
ASCII string
READing from
COOOtoFFFF
Search for data $A9,
Sff, S4C, fromA100 toA101
COMMAND: L (LOAD)
PURPOSE: Load a file from cassette or disk.
SYNTAX: L <"fi!ename">, <device>
■■.filename"-■ is any legal Plus/4 filename inside quotes.
<device> is a hexadecimal number indicating the device to load from.
1 is cassette
188
8 is disk {or 9, A, etc.)
The Load command causes a file to be loaded into memory. The start ing address is contained in the first two bytes of the file (a program file).
In other words, the LOAD command always loads a file into the same place it was saved from. This is very important in machine language work, since few programs are completely relocatable. The file is loaded into memory until the end of file (EOF) is found.
EXAMPLE: L "SCREEN", 1 reads a file from cassette.
L-TANK". 8 reads a file from disk.
COMMAND: M {MEMORY DISPLAY)
PURPOSE To display memory as a hexadecimal and ASCII dump within the specified address range.
SYNTAX: M [oddress l>]\<address>\
[oddress 1 >] First address of memory dump. Optional. If omitted, one page is displayed. The first byte is the last address specified.
[oddress 2>] Last address of memory dump. Optional. If omitted, one page is displayed. The first byte is the data of [oddress 1>].
Memory is displayed in the following format:
1E7 00AAAA00 98 56 45:A!.*..VE
Memory content may be edited using the screen editor. Move the cur sor to the data to be modified and type the desired correction and hit return. If there is a bad RAM location or an attempt to modify ROM has occurred, an error flag (?) is displayed.
An ASCII dump of the data is displayed in REVERSE (to contrast the dump with other data displayed on the screen) to the right of the hex data. When a character is not printable, it is displayed as a reversed period (.).
189 ...
—
—
—
—
As with the Disassembly command, you can page down by typing and RETURN.
EXAMPLE
Ml COO
■1COO
■1C08
■1C10
-1C18
■1C20
•1C28
■1C3O
■ -1C38
■1C40
■1C48
■1C50
>1C5S
41
41
41
41
41
41
41
41
41
41
41
41
00
00
00
00
00
00
00
00
00
00
00
00
E7
E7
E7
E7
E7
E7
E7
E7
E7
E7
E7
E7
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
00
00
00
00
00
00
00
00
00
00
00
00
56
56
56
56
56
56
56
56
56
56
56
56
98
98
98
98
98
98
98
98
98
98
98
98
45
45
45
45
4i)
45
45
45
45
45
45
45
:A!.*
:AI.*
:A!.*
:A!.*
..VE
..VE
..VE
..VE
:A!.*
:A!.'
:AL*
:A!.*
:AL*
:A!.'
:A!.*
:AL*
..VE
..VE
..VE
..VE
..VE
..VE
..VE
..VE
COMMAND: > (GREATER THAN sign)
PURPOSE Can be used to set 1 to 8 memory locations at a time.
SYNTAX: > address data byte 1 <data byte 2...8> address: First memory address to set data byte 1; Data to be put at address
<data byte 2 to data byte 8>: Data to be placed in the successive memory locations following the first address. Optional
EXAMPLE
>2000 08 places an 08 at location 2000
-3000 23 45 65 places a 23 at location 30C0, a
45 at 3001, and a 65 at 3002
190
COMMAND: R (REGISTER DISPLAY)
PURPOSE Show important 6502 registers. The program status regis ter, the program counter, the accumulator, the X and Y index registers and the stack pointer are displayed.
SYNTAX R
EXAMPLE:
;
R
PC SR AC XR YR SP
1002 01 02 03 04 F6
NOTE: ; (semi-colon) can be used to modify register displays in the same fashion as > can be used to modify memory registers.
COMMAND: S (SAVE);
__
PURPOSE: Save the contents of memory onto tape or disk.
SYNTAX: S<"filename ">.<device>.oddress 1>,<address2>
<"filename"> Any legal Plus/4 filename. To save the data, the filename must be enclosed in double quotes. Single quotes cannot be used.
—
<device> Two possible devices are cassette and disk. To save on cassette, use device 1: The device number of the Plus/4 disk drive is usually 8, However, this can be changed (for instance, when using more than one disk drive). See your Plus/4 DISK DRIVE MANUAL oddress 7 > Starting address of memory to be saved.
oddress 2> Ending address of memory to be saved + 1. All data up to but not including the byte of data at Ihis address is saved.
The file created by this command is a program file. The first two bytes contain the standing address <address 7 > of the data. The file may be recalled using the L command.
—
__
—
EXAMPLE S "GAME1', 8, 0400. 0BFF i_J
Saves memory from $0400 to SOBFF onto disk,
COMMAND: T (TRANSFER)
PURPOSE: Transfer segmenis of memory from one memory area to another
191 ,.
—
—
—
SYNTAX T oddress 1 > oddress 2> oddress 3> oddress 1 > Starting address of data to be moved
.' i /fess 2 > Ending address of data to be moved
<-address 3> Starting address of new location (where the data will go)
Data can be moved from low memory to high memory or vice-versa.
Additional memory segments of any length can be moved forward or backward any number of bytes (i e . shifted).
EXAMPLE T 1400 1600 1401
Shifts data from SI400 up to and including S1600 one byte higher in memory.
COMMAND V (VERIFY)
PURPOSE Verify a file on cassette or disk with the memory contents.
SYNTAX V <"filename'">, <devlce>
■ filename > is any legal Plus/4 filename.
■■-device > is a hexidecimal number indicating which device the tile is on; cassette is 1 or 01. disk is 8 or 08, 09, etc.
The Verify command compares a file to memory contents. The Plus/4 responds VERIFYING. If an error is found, the word ERROR is added; if the file is successfully verified, the flashing cursor reappears.
EXAMPLE V-WORKLOAD11. 8
COMMAND. X(eXit)
PURPOSE Exitto BASIC
SYNTAX X
When the X command is given, the machine stack pointer is set to the current stack pointer value (see the R command). If this is modified in any way. after exiting to BASIC use the BASIC CLR commanc to reset the pointers
_
SECTION 6
llowing chart lists atl of the characlers built into the Commodore character sets It shows which numbers should be POKEd into screen memory (locations 3072 to 4095) to get a desired characler. (Remem ber to set color memory - 2048 to 3071) Also shown is which char acter corresponds to a number PEEKed from the screen
Screen
Display
Codes
Two character sets are available, but only one set at a time. This means that you cannot have characters from one set on the screen at the same time you have characters from the other set displayed The
sets are switched by holding down the IBBBH and SHU keys
simultaneously.
_
From BASIC. PRINT CHRS(142) will switch to upper-case/grapnics mode and PRINT CHRS{14) switches to upper'lower-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.
_
193
SET1
■■
J
K
I
L
M
\
0
=
Q
R
S
(n
E
F
C
D
G
A
B n
0
■ i q e f c d i g h a b k
I
I m s
SET 2 POKE SET1 SET 2 POKE SET1 SET 2 POKE
T
U
V w
Z
£
[
X
Y
T
|
«-
SPACE
■■
!
V w
X y z t
U
#
$
%
&
10
11
8
9
12
13
14
2
3
4
5
0
1 e
7
15 li
17
18
19
25
26
27
20
21
22
23
24
28
29
30
31
32
33
34
35
36
37
38
39
)
(
;
+
-
7
8
9
5
6
3
4
1
2
/
0 48
49
50
43
44
45
46
47
40
41
■'.;> v
■■.;■'
53
54
■■S
56
57
58
59 n
194
Codes from 128-255 are reversed images of codes 0-127.
195
-
SECTION 7 This appendix shows you what characters will appear if you PRINT
CHRSfX), for all possible values of X. It will also show the values ob tained by typing PRINT ASC("X"), where.X is any character you can type. This is useful in evaluating the character received in a GET statement, converting upper/lower-case, and printing character based commands (like switch to upper/lower-case) that could not be enclosed in quotes.
ASCII and
CHRS
Codes
PRINTS
IVHT ■■
DISABLES
SHIFT £l
ENABLES
SHIFT £i
12
RETURN
13
SWITCH TO
LOWERCASE '''
.
■■■
9
10
11
6
7
8
4
-
CHRS
0
■
2
PRINTS
T
RVS
ON cut
HOME
1N5T
DEL
ESCAPE
RED
—-
CRN m u
SPACE
I
CHRS
17
'■
19
_!0
21
22
.>:\
24
25
,i
27
28
30
31
32
33
@
IIA-■
;>
7
A
B
C
PRINTS
3
4
5
-
7
B
9
CHRS
51
52
53
54
55
56
57
-
60
62
■•■■
.,.:
67
196
PRINTS
CODES
CODES
CODE
CHHS
184
185
192-223
224-254
255
PRINTS
□
CHRS
186
187
PRINTS CHRS
188
189
PRINTS CHRS
190
191
SAME AS
SAME AS
SAME AS
96-127
160-190
126
198
SECTION 8 Tne following chart lists which memory locations control placing
characters on the screen, and the locations used to change individual ■— character colors, as well as showing character color codes.
_
SCREEN MEMORY MAP
COLUMN
?0
• ■ ■
3111
0
___
Screen
And
Color
Memory
Maps
■=
■ "3"
1312
!352
ng?
13
■-■ ■
151?
<552
3S92
3632
3672
3712
1752
1792
3832
1872
1912
1952
19K
1 ■
—
_
ti
■
——.
199
COLOR MEMORY MAP
COLUMN
20 39
2087 pnpn
?i?n
?1BH
2208
2246
228B
2328
236B
2408
?44fl
^608
, :.-
■ H(
,>/28
-
-■
■
■
■>orifi I
The actual values to change a character's color are;
1 BLACK
2 WHITE
3 RED
4 CYAN
5 PURPLE
6 GREEN
7 BLUE
8 YELLOW
9 ORANGE
10 BROWN
11 YELLOW-GREEN
12PINK
13 BLUE-GREEN
14LIGHTBLUE
15 DARK BLUE
16 LIGHT GREEN
The luminance of the color is selected by multiplying the luminance value (0-7) by 16, and added to the number for the color. To make the character flash, increase the color value by 128.
200
SECTION 9
HI
■ ■■■■■
^S iiii
PLUS/4
Memory
Register
Map
-
23
24
25
26
27
.:■
29
■
31
62
■
REG
0
■
2
3
4
5
6
7
■
11
12
6
9
*
14
15
16
17
18
19
20
21
SFFOO
SFF01
SFF02
$FFQ3
SFFO.:
SFF05
SFF06
SFF07
$FF08
SFF09
SFFOA
SFFOB
SFFOC
IFFOD
IFFOE
JFFOF
$FF10
SFF11
SFF12
SFF13
SFF14
SFF15
SFF16
SFF17
.., ■..
SFF19
SFF1A
$FF1B
SFF1C
5FF1D
SFF1E
SFFlF
$FF3E
$FF3F
037
TEST
DB6
ECM
RVS OFF PAL'
3KGD0
BKGD1
BKGD2
BKGD3
BKDG4
VhM
NC
NC
NC
NC
IBQ
NC
RC7
NC
CUR7 i t:«
EI-T3
RCf
NC
CUR6
'.
i ■■ sndv;
SND2-7 SND2-6
NC NC
SND-FiEL NOISE
NC
C35
NC
CB-:
NC
NC
BRE7
NC
VL7
.*.'■
LUM2
LUMZ
LUM2
LUM2
LUM2
NC
BRE6
NC
VL6
H7
■■-.
NC BL3
!:■-: DB3
TIMER # 1 RELOAD VALUE. BITS O-T(LOW)
TIMER * 1 RELOADVALUE.BITS815(HIGHI ril/Efi * 2 RELOAD VALUE BITSO T.lOWi
DSi
TIMER* 2 RELOAD VALUE. BITS 8-15 (HIGH)
TIMER* 3 RELOAD VALUE. BITS 0-7 (L0W1
TIMER * 3 RELOAD VALUE BUS 8-15 (HIGH)
■■■■.■■/
FREEZE
BLANK
MCM
#ROWS
#COLS
Y2
X2 XI
NC
■■.:
■.;
CUR5
SNDT-5
SND2-5
N
..
■■■.■■■
2% ■
L_
KEYBOARD LATCI-
I-T2
E1-T2
I-Ti
El-Tl
PC-
\c
CURJ
SND1-J
= "
■J
CUR3
SND1-3
I-LP
EI-LP
RC2
NC
CUR2
SND1 2
SND2-1
NC
SND2-3
NC
SND3-2
VC
Vi-SEL
BMB1
:b;
.■■
V0L3
BVBO
CB1
VMO
.
RBANK
CBO
NC
_
I-RAS
L ■■ ■ ■
C9
CURi
SN01-1
■■,.■■
SND2-S
V0L1
S1-9
":_: :-
NC
■:■
LLJM1
LUMl
Ml
LUMO
.".■
COLOR
■_ .
i'
Ci L0=-
C0L0R2
C0L0R2
C0L0R2
COLOR2
COLOGl
COLO"I
COL0R1
COLO-1
Ml
NC
BRE5
NC
VL5
LUMO
■■'."
BRE4
NC color; color;
NC
BRE3
NC
VL.l
C0L0R2
NC
BRE2 f.(
.
COLO=1
BRE9
BRE1
■,
VL1
...
BL2
H5
BLl
H-l
-
H3
VSUB2
-_
V3UB1
P0\ 1 -El EC!
RAW SELECT
OBO
YO xo
NC
-
= :.
CURB
CURO
SNDIO
SND2 0
SND3-8
VOLO
S"-B
S'A^US
NC
COLOOO
1 1
COLOR!)
COLORO
COLORO
BRE8
BREG
VLB
VLO
_
—
n n
SFFFE-FFFF
SFFFC
SFFFA
SFF81-FFF5
SFF40-FFSO
SFFO0-FF3F
SFEOO-FEFF
SFDEO-FDEF
SFDDO-FDDF
SFD10-FD1F
SFDOO-FDOF
SFCDO-FCFF
-IRQ VECTOR
<RES VECTOR
<NMI VECTOR (NOT USED)
<KERNALJUMP TABLE
-'TED CHIP
<DMA DISK SYSTEM
<
<CARTR!DGE BANK PORT
<6529 PARALLEL POFIT
■--.ACIA
<
ROM BANK HIGH (com]
TEDCnipandL'O space appear in ad memoiy maps
ROM Banking routines
(appeal in an ROM maps)
SD800-FCFF
SDOOO-D7FF
SCOOO-D7FF
S8OO0-BFFF
S4000-FFFF
S2OOO-3FFF
<
CHARACTER ROM
< MORE BASIC
< BASIC c RAM ALSO START OF BASIC TEXT
■ AREA WHEN HIRES GRAPHICS ARE USED
■: BIT MAP SCF1EEN DATA
> *
> •
> '
S1CO0-1FFF
11800-1BFF
S10OO-
SOCOO-OFFF
S08O0-0BFF
SOOOO-CFFF
<HIRES SCREEN VIDEO MATRIX
« HIRES SCREEN ATTRIBUTE BYTES
- BASIC TEXT AREA (BIT MAP OFF)
< TEXT VIDEO MATRIX (SCREEN MEMORY)
< TEXT ATTRIBUTE BYTES (COLOR MEMORY)
• SYSTEM STORAGE
■NOTE In the 64K RAM system. RAM goes Irom SODOO-SFCFF, and IrornSFFdO-SFFFF
ROM SANK HIGH
ROM BANK LOW
202
_
SECTION 10 Functions that are not intrinsic to BASIC 3.5 may be calculated as
follows:
Deriving
Mathematical
Functions
FUNCTION
SECANT
COSECANT
COTANGENT
INVERSE SINE
INVERSE COSINE
INVERSE SECANT
INVERSE COSECANT
INVERSE COTANGENT
HYPERBOLIC SINE
HYPERBOLIC COSINE
HYPERBOLIC TANGENT
HYPERBOLIC SECANT
HYPERBOLIC COSECANT
HYPERBOLIC COTANGENT
INVERSE HYPERBOLIC SINE
INVERSE HYPERBOLIC COSINE
INVERSE HYPERBOLIC TANGENT
INVERSE HYPERBOLIC SECANT
INVERSE HYPERBOLIC COSECANT
INVERSE HYPERBOLIC COTANGENT
BASIC EQUIVALENT
SEC(X) = 1/COS(X)
CSC(X) = 1/SIN(X)
COT(X) = 1/TAN(X]
ARCSIN(X)-ATN(X/SQR( X"X + 1))
ARCCOS(X)= -ATN(X/SQR
ARCSEC(X) = ATN(X'SQR{X"X-1)|
ARCCSC(X)=ATN(X'SQR(X"X-1))
+(SGN(X)-fW2)
ARCOT(X}=ATN<XHt7/2
SINH(X) = (EXP(X)-EXPf-X})/2
COSH(X}=(EXP(X) = + EXP(-X))/2
TANH(X) = EXP(-X)/(EXP(x)+EXP
SECH(X)=2/(EXP(X) + EXP(-X))
CSCH(X)=2/(EXP(X)-EXP(-X))
COTH(X)=EXP(-X)/(EXP(X)
-EXP(-X))"2 + 1
ARCSINHtXj^LOGIX + SQRfX'X+i)]
ARCCOSH(X)=LOG(X + SQR(X*X-1)}
ARCTANH(X) = LOG((1-t-X)/(1-X))/2
ARCSECH(X) = LOG((SQR
ARCCSCH(X)-LOG((SGN(X)"SQR
(x x + 1 )/x))
ARCCOTH{X) = LOG((X+1 )/(x - 1 ))/2
_
L
_
_
_
203
_
"
Musical B
Note
Table
C
D
E
A
B
F
G
C
D
E
B
C
D
F
G
A
E
F
G
A
B
C
D
A ii.
F
G
NOTE SOUND REGISTER VALUE
854
864
881
897
911
917
739
770
798
810
834
929
939
944
953
7
118
169
262
345
383
453
516
571
596
643
685
704
ACTUAL FREQUENCY (HZ)
494.9
522.7
588.7
658
699
782.2
880.7
989.9
1045
1177
1316
1398
1575
110
123.5
130.8
146.8
164.7
174.5
195.9
220.2
246.9
261.4
293.6
330
349.6
392,5
440.4
The above table contains the sound register values of four octaves of notes. The sound register values are used as the second parameter of the SOUND command. To use the first note in the table (A—sound
204
register value 7) use the 7 as the second number after the SOUND command—SOUND 1,7.30.
Use the following formula to find the sound register values for frequen cies other than those in the table:
SOUND REGISTER VALUE - 1024—(111860.781/FREQUENCY)
Both the table of sound register values and the above formula are for
NTSC televisions. This is the television standard used throughout the
United States and all of 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—(111840.45/FREQUENCY)
205 —
"
SECTION 12 5 GRAPHIC 3, 1: GRAPHIC 0, 1
10 INPUT "SHOULD I CLEAN UP MY MESS"; A$
20 INPUT "SHOULD I ROTATE11; B$
TEV
U
Programs
To
Try
30 INPUT
40 INPUT
SHOULD I VARY MOTION"; C$
SHOULD I PICK THE START"; D$
50 IF A$ = Y" THEN DIM A (3,200)
60 DEF FNA (X) = INT(RND(1) * X)
70IFD$ = "Y"THENXl=FNA(80)+80:X2 =
Yl=FNA(100) + 100
75IFD$ = "Y"THENY2 = FNA(100) + 100
80IFD$o"Y" THENXl=80:X2 = 80: Yl = 100: Y2-100
90 GRAPHIC 3: FORL=1 TO 3: COLOR L, FNA{15) + 2, FNA(8):
NEXT
100 IF Cl< 1 THEN COLOR FNA(3) +1, FNA(15) +2, FNA(8):
Cl=FNA(40) + 20
110 IF C2O0 THEN 140: ELSE XA = FNA(ll)-5: XB=FNA(ll)-5:
YA=FNA{13)-6
115YB=FNA(13)-6
120 IF C$="Y" THEN C2 = FNA(10) + 5
130IFB$ = "Y"THENXB=-XA: YB=-YA
140IFC3-- 1THENC = FNA(3) + 1: C3 = FNA(10)
145 IF A$ = "Y" THEN DRAW 0, A(0,P), A(l,P) TO A(2,P), A{3,P)
150X1= XI+XA:X2=X2+XB: Yl = Y1+ YA: Y2= Y2+ YB
160IFX1<OORX1>159THENXA= -XA: X1-X1+XA
170 IF X2<0 ORX2>159 THEN XB = -XB: X2 = X2 + XB
180IFY1-:OORY1>199THENYA= -YA: Yl-Yl+YA
190 IF Y2<0 OR Y2 -199 THEN YB- -YB: Y2= Y2+YB
200 DRAW C, XI, Yl TO X2, Y2
210IFA$ = "Y"THENA(0,P)=Xl: A(1,P)=Y1: A(2,P)=X2:
A(3,P)=Y2:P=P + 1
215 IF A$ = "Y" THEN IFP>200THENP = 0
220 Cl= Cl-1: C2- C2-1: C3= C3-1: GOTO 100
Sound
Effects
Wolf Whistle
10VOL7
20 FORL = 400TO800STEP20
30SOUND1,L,3:NEXT
40 FORL -300TO600STEP40
50SOUND1,L,3:NEXT
60FORL = 600TO300STEP-40
70SOUND1,L,3:NEXT
206
Computer Maniac
10VOL7
20FORL = lTO100
30SOUNDl,INT(RND(0)i500)+400,4
40 NEXT
Telephone
10VOL7
20FORL = lTO5
30FORM = lTO60
40 SOUNDl.466,1
50 SOUND1,1020,1
60 NEXT
70FORZ = lTO2000:NEXT
80 NEXT
Busy Signal
10VOL7
20FORL = lTO15
40SOUND1,466,20
50 SOUNDU020.15
80 NEXT
Bubbles
10VOL7
20 GRAPHIC1.1
30FORM = lTO50
40 GOSUB80
50SOUND1,900-R>:20, (YR/2) + 50
60 CmCLEl,X,Y,R,YR
70 NEXT:GRAPHICO:END
80X = INT(RND(0)*280) + 20
90Y-INT{RND(0)*160) + 20
100R = INT(RND{0)i:40} + 5
110YR = R/1.3
120 RETURN
Zap Beam
10VOL7
20FORM = lTO20
30FORL = 900TO850STEP-10
40SOUND1,L,1
207
_.
_
—
50 NEXT
60 FORL = 850TO900STEP10
70SOUND1,L,1
80 NEXT
100NEX1
Music Lines
10VOL7
15X1=O:Y1 = O
20 GRAPHICl,1
30GETA$:IFA$-" "THENGRAPHICO:END
40 GOSUB80
45 FORL=1T0DSTEP2
50SOUND1,X"3,5
55SOUND2,Y'3,5
6ODRAW1,X,Y
70NEXT:GOTO30
8OX = X1:X1=INT(RND(O)*28O) + 2O
90Y = Y1:Y1=INT(RND(0)*160) + 20
1OOA=X1-X:B = Y1-Y:D=SQR{A*A+B*B)
110DX = A/D:DY =
120 RETURN
208
SECTION 13 Introduction
Your Commodore Plus/4 has a built in RS-232 interface for connection to any RS232 modem, printer, or other device. To connect a device to your Plus/4 requires a cable and some additional programming. The
Commodore modem connects directly.
RS-232
Interface
RS-232 on the Plus/4 is standard RS-232 format, bat the voltages are
TTL levels (0 to 5V) rather than the normal RS-232 -12 to 12 volt range.
The cable between the Commodore Plus/4 and the RS-232 device should accommodate the necessary voltage conversions. (The Com modore RS-232 interface cartridge handles this properly.)
The RS-232 interface software can be accessed from BASIC or from the KERNAL for machine language programming. This section addresses the use of RS-232 from BASIC. For more detailed information, and for use from machine language, consult the Commodore Pius<'4
Programmers Reference Guide. RS-232 from BASIC level uses the normal BASIC commands: OPEN, CLOSE, CMD, INPUT#. GET#,
PRINT#, and the reserved variable ST. INPUT# and GET# recall data from the receiving buffer, while PRINT# and CMD place data into the transmitter.
Opening
The
RS-232
Channel
—
—
Only one RS-232 channel should be open at any time; a second OPEN statement causes the receive buffer pointer to be reset, causing any characters in the buffer to be lost.
Up to 4 characters may be sent in the filename field. The first two are control and command register characters; the other two are reserved for future system options. Baud rate, parity, and other options can be selected through this feature.
Basic Syntax:
OPEN if. 2,0,<" >control register command register<">
—
—
—
EXAMPLE:
OPEN 2,2,0, CHR$(5)+ CHR$(15)
/f—Normal logical file id. (1 -255). If If > 127, then linefeed follows carriage return.
control register—Single byte character (see Figure 1) (required to specify baud rate) command register—Single byte character (see Figure 2)
—
209
Getting
Data
From
An
RS-232
Channel
When receiving data, the Commodore Plus/4 receiver buffer holds 127 characters before the buffer overflows. This is indicated by the RS-232 status word (ST from BASIC). All characters received when the buffer is full are lost. Obviously, it pays to keep the buffer as empty as possible.
Receiving RS-232 data at high speeds calls for use of machine lan guage, since the speed of BASIC is a limitation.
CONTROL REG . (E =
CONTHOL REGISTER
Trie Control Register is used to select [he desired mode lor itie 6551 The word length, number ot stop Oils, and clock conuolsare all aalHrrnined by Ida Control Register, wmch is aepicied in Figure l
STOP BITS -
■ =■; .-■■■■
1 =2&e pBits
1SW
-8
11*1
= 5 ptM us* obE
■■. ■
Word Lengm a Psniy* s d Wora Longtn a mo P»ay
WORD LENGTH
.
Bil
.
DATA WORD
LENGTH a
;
■
■ i
0
1 e
5
KECEIVEH CLOCK SOURCE
E-iemai Receiver Clock
< ETERNAL O.0CK
h-APOWARE RESET
PROGRAM RESET
-
0 £ ; s 3 0
Figure 1. Control Register Format
Basic Syntax:
Recommended: GET# If, <string variable>
NOT Recommended; INPUT# IS, <variable list>
210
_
COMMAND REGISTER
The Command Reffstei is used to comroi Specilic
TransmitfReceive lections and is shown m FiQure 2
PARIT\ CHECK CONTROLS
COMMAND HEGIS1ER
- U h I hFTT
I—DATAIERMlUAll
BilwiurtllOT
1 - EnUMH««
PJ= P.tii, En Roce.wxi
O30 PflrBy Receive? and Tian&mir
Parity CTiee* DsaDted
Space Parity B* Irans-miad p i ■. ."."■--- .
i:
■
■
■J
■
D
■
■ '■», '-■
INTERHUP'
: .I .■ ■ ii ■!■■■ !
lh'..ii Ik)
:■. ii!>:!
BECEIVEHlfJIEBRUPIErJSBLE of Slatut (Wflsiei - ino imwnux »«
-TRA'JSVrTEf>CONTTOi.S
HIS lEVEl
TRANSMITTER rtmh u»
Loa
Lw.
0" o
TranSr-it 0RK
_
_
HARDWARE RESE I
. ■■■!■■:■■ -.: t
7 6
I
5
■
1
J
.1
1
J (i
1
I
0
O D?s fust (m stf lo D
Figure 2. Command R*glil«r Format
NOTES
If the word length is less than 8 bits, all unused bit(s) are assigned a value of zero.
—
If a GET# does not find any data in the buffer, the character"" (a null) — is returned.
If INPUT# is used, then the system hangs until a non-null character and a following carriage return is received- Thus, if the CTS or DSR line(s) disappear during character INPUT#, the system hangs in a
RESET-oniy state. This is why the INPUT# and CHRIN routines are
NOT recommended.
211
Sending Data Basic Syntax:
To An RS-232 CMD If—acts same as in BASIC specifications
Channel PRINT# !f,<variablelist>
ClOSi np Closing an RS-232 file discards all data in the buffer at the time of
An execution, stops all RS-232 transmitting and receiving, and sets the no nnn RTS and Sout lines high.
Data Basic Syntax:
Channel close//
Table 1.
PIN
ID
RS-232 Port Lines
DESCRIPTION EIA ABV OUT
M
A
N
I
F
H
J
K
C
D
_
RECEIVED DATA
-=^UE5T~O SENC
DATA TERMINAL READY
RING INDICATOR
RECEIVED LINE SIGNAL
UNASSIGNED
CLEAR TO SEND
DATA SET READY
(BB)
(CA)
(CD)
(CE)
(CF)
( )
(CB)
(CC)
RECEIVED DATA
TRANSMITTED DATA
PROTECTIVE GROUND
SIGNAL GROUND
(BB)
(BA)
(AA)
(AB)
Sin
RTS
DTR
Rl
DCD
XXX
CTS
DSR
Sin
Sout
GND
GND
IN
If!
IN
IN
IN
OUT
OUT
IN
IN
OUT
212
MODES
I 7 | | 6 I 5 | | 4 I 2 (Machine lang —rsstat)
PARITY ERROR BIT
FRAMING ERROR BIT
RECEIVER BUFFER OVERRUN BIT
UNUSED BIT
CTS SIGNAL MISSING BIT
UNUSED BIT
DSR SIGNAL MISSING BIT
BREAK DETECTED BIT
_
Figure A-3 RS-232 Status Register
NOTES
If the B!T=0, then no error has been detected.
The RS-232 status register can be read from BASIC using the variable
ST.
If ST is read by BASIC or by using the KERNAL READST routine the
RS-232 status word is cleared upon exit. If multiple uses of the STATUS word are necessary, the ST should be assigned to another variable, i.e.
SR=ST: REM ASSIGNS ST TO SR
The RS-232 status is read {and cleared} only when the RS-232 channel was the last external I/O used.
__
213
-
SAMPLE
BASIC
PROGRAM
This program opens the telecommunications channel to allow you to communicate using a modem.
100 OPEN 5, 2, 2, CHR$(22) + CHR$(5): REM ALLOCATE BUFFER
AND OPEN CHANNEL
110DIMF%(255),T%(265)
120FORJ-32TO64: T%(J)=J:NEXT
130T%(13) = 13:T%(20) = 8:RV=18: CT^O
220FORJ = 65TO90: K=J + 32: T%(J)=K: NEXT
230FORJ = 91TO95:T%{J)=J:NEXT
240FORJ-193TO218: K = J-128: T%(J)=K: NEXT
250T%(146) = 16:T%(133) = 16
255T%(137)=3: T%(134) = 17: T%(138) = 19
260 FOR J=0 TO 255
270K = T%(J)
280 IF KO0 THEN F%(K)=J: F%(K + 128)-J
290 NEXT
300 PRINT" "CHR$(147)
310GET#5,A$
320rFA$^1M'THEN360
330 PRINT" "CHR${157);CHR$(F%(ASC(A$)));
340 IF F%{ASC(A$)) = 34 THEN PRINT CHR$(27)"O";
350 GOTO 310
360 PRINT CHR$(RV)" "CHR$(157);CHR$(146);: GETA$
370IFA$O""THENPRINT#5,CHR${T%(ASC(A$)));
380CT-CT + 1
390 IF CT = 8 THEN CT = 0: RV-164-RV
410 GOTO 310
214
SECTION 14 The following lists include a sampling of the computer and program
ming books available. The title of the book is listed first, followed by the — author and publisher.
Books
For
Commodore
Products
Commodore Books
VIC 20 Programmer's Reference Guide
Commodore 64 Programmer'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
Stimulating Simulations for the VIC, C.W. Engel
Introduction to BASIC, Part 1 and 2, Andrew Colin
Commodore Software Encyclopedia, Third Edition
BASIC Programming
Armchair BASIC: An Absolute Beginner's Guide to Programming in BASIC, Fox & Fox, Osborne/McGraw-Hill
BASIC Handbook, Second Edition, Lien, Compusoft
Basic Commodore 64 BASIC. Coan, Hayden
Elementary BASIC, Ledgard & Singer, SRA
How to Build a Program, Emmerichs, Dilithium Press
Instant Freeze-Dried Computer Programming in BASIC, Brown
My Computer Likes Me When I Speak in BASIC. Albrecht,
Dilithium Press
Nailing Jelly to a Tree. Willis & Danley, Dilithium Press
The Programmer's Book of Rules. Ledin & Ledin, Lifetime
Learning Publishers
Technical BASIC, Kassab, Prentice-Hall
Machine Language Programming
Machine Language for Beginners, Mansfield, COMPUTE! 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 6502 Software Gourmet Guide & Cookbook. Findlay, Hayden
—
—
—
—
215
INDEX a
Abbreviations for BASIC statements 169-171
Animation 87-89
Arrays 164
ASCII and CHRS codes 169,
196-198
Assigning data
DATA. . READ statements
74-75,133-134, 151, 170
INPUT 73. 141, 170
GET 138, 169
LET 142, 170
AUTOmatic renumbering 118. 169
B
BACKUPcommand 118, 169
BASIC abbreviations 169-171 commands 69-82. 118-129 converting to Commodore
BASIC 172,173 functions 28-31, 158-163 statements 69-82, 130-157
BOX statement 100-101, 130,
169
Built-in software 34
Calculations addition 59, 63 decimals 59 division 59, 63 execution order 62-63 exponentiation 65 fractions 59 mathematical operators 59,
167-168 multiplication 59, 63 parentheses 62-63
PRINT statement 61-62 relational operators 59,
167-168 scientific notation 60 subtraction 59, 63
Cartridges installing 35 loading 35
Cassette tapes recorder4. 19
LOADing 36
SAVEing37, 127 software 36-37
■CHAR statement 95-96, 130-131,
169
CHRS codes 169, 196-198
CHRS function 162, 196-198
Clearing 25-26
CLR command 25-26, 132, 169 graphics modes 28, 84-89 graphics screen 93, 169 memory 199-202 screen 193-195
CIRCLE statement 98-100,
131-132,169
CLOSE statement 132, 169
CLR statement 25-26, 132, 169
CMD statement 132-133, 169
COLLECT command 119, 169
Color areas 90-91 background 90-91 border 90-91 changing 27. 100-101
COLOR statement 90-91, 133,
169
filling areas 100-101
keys 27 luminance 90 memory map 199-202
PAINT 100-101, 145 screen 193-195
216
Commands (See BASIC commands)
Commas in PRINT statements 55-56 separating numbers 61 vs. semicolons 55-56
Commodore key 26
Conditional Statements
IF/THEN 79, 140-141, 170
Connecting the computer 8-18
CONT command 119, 169
Control (CTRL) key 26
Control Statements
GOTO 47, 76-77, 139
FOR/NEXT/STEP 77-78
Conversion programs 172-173
COPY command 119, 169
Copying diskettes 119
Cursor controlling movement 25-26 cursor keys 25-26 in PRINT statements 25, 49-51
DATA statements 74-75, 133-134
Debugging
CONT 119, 169
DSS41
STOP 155, 171
RESUME 152, 171
TRAP 155, 171
DEF FN statement 134,169
Defining functions keys 30-31
Defining functions in programs
30-31
DELete command 25, 120, 169 editing 25 files from a diskette 25 key 25 letters in a word 25, 49-51 lines in a program 25, 49-51,
120
DIMstatemenM34-135, 169
Dimensioning an array 134-135
Direct mode 70
DIRECTORY41. 120-121, 169
Diskettes
COPY statement 119, 169
DIRECTORY command 41,
120-121. 169 „ disk drives 4, 19,38 disk error messages 39, 174-
183
DLOAD command 30-31,
38-39, 121, 169
DSS41 duplicating 119 formatting 39-40
HEADER command 39-40,
122, 170 listing a directory 41. 120-121 loading 38-39, 121, 124-125
SAVEing 40-41. 127 table of contents 41
DLOAD 30-31, 121
DO/LOOP/WHfLE/UNTIL/EXIT
78. 135-136
DRAW 94-95, 136, 169
DSS41
DSAVE 30-31, 122. 169
Duplicating diskettes 119
Editing
INSertkey25
INSert mode 25. 28-29
DELete key 25
DELete command 25. 120,
169
RENUMBER command 70,
126-127, 171
~
_
-
217
Encyclopedia 115-214
END statement 136
Errors
Debugging statements
174-183
Disk errors 39, 174-183
Messages explained 39,
174-183
ESCape functions 28-29, 57
ESCape key 28-29
EXP function 158, 169
Flash mode
Flash on and off 27 keys 27 using in PRINT statements 27
FOR... TO... STEP 77-78.
136-137
Formatting diskettes 39-40
Formatting output
PRINT USING 145-150
PUDEF 150-151, 170 print zones 55-56 punctuation 55-56
Functions
Numeric 59-67, 158-162.203
String 162-163
Other 163
Function keys 30-31
GET statement 138.169
GETKEY statement 74, 138, 169
GET# 138-139,169
GOSUB80,139, 169
GOTO 47. 76-77, 139,169
Graphics
BOX 97-98, 100-101, 130. 169
CIRCLE 98-100. 131-132, 169 clearing 93, 169
218
COLOR 90-91, 169
DRAW 94-95, 136, 169
GRAPHIC command 92-93,
139-140, 157, 169 high resolution 92-93 keys 28-29 modes 28, 84-89 multicolor modes 102-103
PAINT 100-101, 145 printing graphic symbols
84-86 uppercase/graphic mode 24,
28
GSHAPE 153-154. 170
H
HEADER command 39-40, 122,
170
HELP key 30-32, 123
High resolution graphics 92-93
I
IF.. THEN... ELSE 79, 140-141,
170
Immediate mode 62, 70
INPUT # 141. 170
INPUT statement 73, 141, 170
Input'Output Statements
PRINT 71-73
INPUT 73, 141, 170
GETKEY 74, 138, 169
READ/DATA 74-75, 133-134,
151. 170
Insert editing 25 key 25 mode 25
Insert mode accessing 25. 28-29 key 25
Installing the computer 8-18
INSTR (unction 158-159, 170
INT function 66-67, 159, 170
Integer variables 64, 164
J
Joy sticks 5, 12, 159, 170
K
Key command 31, 123, 170
Key redefining 30-31
Keyboard color keys 27 cursor keys 25-26 graphic keys 28-31 help key 30-32 programmable (unction keys
30-31 special keys 24, 29
LeftS function 162, 170
LET statement 142, 170
LIST statement 30-31, 48-49,
124, 170
Loading cartridges 35 cassettes 36 diskettes 38-39, 121
DLOAD command 30-31,
38-39, 121. 169
LOAD command 124-125, 170
LOCATE statement 142, 170
Loops
DO... LOOP... WHILE/UNTIL
78. 135-136
GOSUB80, 139
GOTO 47, 76-77, 139
FOR... TO... STEP 77-78,
136-137
IF...THEN...ELSE79,
140-141, 170
ON...GOSUB/GOTO143.
170
Luminance 90
M
Machine Language Monitor
184-192' r
Mathematical (unctions 59-67,
158-162.203
Mathematical operators 59
Memory maps 199-202
MIDS function 16°, 170
Modems 214
Modes flash 27 graphics 84-89 insert 28-29 multi-color 102-103 reverse 45-46 uppercase/graphic 28, 84-86 upper/lowercase mode 28.
84-86
MONITOR 142, 170
Monitor connecting to computer 13-16 machine language 184-192
Multi-Color graphics 102-103
Music duration of notes 107
SOUND statement 106,
204-205 voices 106-107 volume 105, 156, 171
N
NEW command 51, 126. 170
NEXT statement 77-78, 143, 170
Numbers calculating 61-67, 72-73, 203
_
_
-
—
__
219
exponentiation 65 execution order in multiple calculations 62-63. 65-67 fractions 59-60 mathematical operators 59 pi 59, 163 relational operators 59,
167-168 scientific notation 60 signs ( + and -)59 variables 64, 170
Program flow control (See
Loops)
Programming
BASIC commands 69-82,
118-129
BASIC functions 30-31,
158-163
BASIC statements 69-82,
130-157 function keys 28-31. 123 machine language monitor
184-192 mode 70
PUDEF 150-151, 170
ON...GOSUB143, 170
ON... GOTO 143
OPEN command 144-145, 170
Operators 59, 167-168
PAINT 100-101, 145, 170
PEEK function 160, 170
Peripherals 19-21
Pi 59, 163
Pixel cursor in graphics modes 84-89
LOCATE statement 142, 170 positioning 25-26, 49-51
POKE statement 146. 170
Power supply 8, 12-13, 16-17
PRINT calculations 61-62, 72-73. 203 displaying messages 71-73 formatting output 145-150 in immediate mode 62, 70 in program mode 71-73 print zones 55-56 punctuation 55-56
PRINT# 147, 170
PRINT USING 145-150. 170
Print zones 55-56
Quote mode accessing 47. 56 keys 47 using in PRINT statements
47-48. 56
Random numbers 65-67, 171
READ statement 74-75, 151. 170
Relational operators 59, 167-168
REM statement 80-81, 151-152.
170
RENAME command 126,171
RENUMBERING program lines
70. 126-127
Reset button 10
RESTORE 152, 171
RESUME 152. 171
Resuming program display 152,
171
RETURN 152, 171
Reverse mode accessing 27, 45-46 kevs 27. 45
220
using in PRINT statements
45-46
RF cable 9, 11
RIGHTS function 163, 171
RND function 66-67, 160-161.
171
RS-232 Interface 209-213
RS-232port 12
RUN command 30-31, 70, 127,
171
SAVE command 127-128, 171
Saving programs cassettes 37 disk errors 41, 174-183 diskettes 40-41, 127-128
DSAVE 30-31, 40, 127
SAVE 127-128, 171
SCALE 152-153, 171
Scientific Notation 60
SCNCLR statement 93,153, 171
SCRATCH command 128, 171
Screen clearing 25-26, 132, 169 clearing graphic modes 93.
169 display codes 26, 52, 193-195
LIST command 30-31. 48-49,
170 memory map 199-202 program display 193-195 resuming display 152 size 57, 86 slowing display 26 windowing 57
Screen area numbers chart 90
Semicolons in PRINT statements 55-56 vs. commas 55-56
Setting up the computer 8-18
Slowing program display 26
Software built-in 34 cartridges 35 cassettes 36-37 diskettes 38-41
LOADing 35-36, 38-dO saving your own 37, 40-41,
127-128
Sound effects 108, 206-208
SOUND statement 106, 153,
171,204-205
SPC function 163, 171
SSHAPE 153-154, 171
STOP statement 155, 171
Stopping program display 24,
52
String functions 162-163, 171
Subroutines 80
SYS statement 34, 155,171
TAB function 88, 163. 171
TEDMON 184-192
TEXT in graphics 92-93 in PRINT statements 71 -73 string functions 70-73,
162-163
TIS function 164, 171
TRAP statement 155. 171
TROFF156, 171
TRON 155, 171
Troubleshooting chart 17-18
TV antenna types 13, 17 channel selection 11, 15-17 hookup 13-18 switch box9, 11. 13, 15-17
221.
—
u
Uppercase/graphics modes accessing 24, 26, 28 printing graphics 84-89
SHIFT key 24. 28
Upper/lowercase graphics accessing 24, 26, 28 printina graphics 84-89
SHIFT key 24, 28
Variables floating point 64, 164 integer 64, 164 reserved names 116-117,
165-166 text string 64, 73, 164 types 64, 164-166 see also Assigning data
VERIFY command 70, 128-129,
171, 192
Voices 106-107
VOLume105, 156, 171 w
WAIT statement 156, 171
Windowing 57. 86
222
_
223
_
_
D n n n n
n
n n n
About the Commodore PLUS/4™User's Manual...
The Commodore Plus/4, the "productivity machine," is perfect for finances, accounting or any small business application. As a home computer, the Commodore Plus/4 has 64K of memory, with advanced color, graphic, sound and BASIC programming capabilities. This easy-to-read User's Manual gives you all the information you need to set up your equipment, use software and learn about computing with your new Commodore Plus/4.
Even if you've never used a computer before, you can follow the step-by-step instructions and explanations to get into com puting right away. For those already familiar with computing, the
Commodore Plus/4 Encyclopedia contains a volume of useful information about the Commodore Plus/4 including a complete review of every command in the BASIC language built into the com puter. This manual also contains explanations of the advanced features of the Commodore Plus/4 and tells you how to get the most out of these expanded capabilities.
You can learn how to use the Commodore Plus/4's built-in integrated software packages—the spreadsheet, graphics, word processing and file manager—by reviewing the Commodore
Plus/4 Integrated Software User's Manual, also included with your new computer.
v COMPUTERS
Commodore Business Machines, Inc.—Computer Systems Division
1200 Wilson Drive, West Chester, PA 19380
ISBN 0-88731-021-4
ডাউনলোড
বিজ্ঞাপন