EXPLORING BASIC Exercise 10 - Printing on the screen Exercise I1 - Using the built-in clock www.commodore.ca Exercise 12 - Setting the clock Exercise 13 - Solving mathematical problems Free for personal use but you must have written permission to reproduce...
And examine carefully y our P17 f or any concealed dam age. If there is any , report this IM M EDIA T EL Y t o bot h ('commodore (or your dealer) and to the shipping agent. Remove your PET from its protective shipping carton, and place it on the counter, desk or other suitable surface, then plug it into any standard, grounded electrical outlet.
which memory option of PET you are using. It tells you how much memory space is free for you to use. 4k power-on display 8k power -on display (A byte is the fundamental data element of the PET computer and corresponds roughly to one letter or digit of information. Figure 1.
PET can act on it. The important thing about this exercise is to get the following dis- play on the screen after you've done: www.commodore.ca Free for personal use but you must have written permission to reproduce...
NOTE: Shaded keys are keys that must be accompanied by points. Practice until you are confident you can put the cursor where pressing the key. SHIFT you want it on the screen. www.commodore.ca Free for personal use but you must have written permission to reproduce...
So let's turn each line of the picture into a program step and see what happens. The importance of a program to a computer can be likened to the importance of a driver to a car. The car does nothing with- out a driver and the computer does nothing without a program.
Exercise 5 - Listing and running your cursor moving to a lower line. PET cannot scroll the other way, however. Information that scrolls off the top of the screen is lost. program We can use this scrolling effect to our advantage to produce an ani- Clear the screen and type: mation in which it appears as though a stream of rockets are blasting off from the bottom of the screen and are streaking off the top.
PET will execute You can change a single character or you can add characters to lines you Now type RUN. As soon as you press already have. You can see exactly what you are changing because the your program. changes are visible as you enter them. Let's try it.
Now let's insert the missing HOW. You'll read: Now position the cursor over the in ARE by pressing several times. Interesting? Think of the applications. If you want to repeat a com- plex statement several tines in the same program ... or if you want to change just a part of a statement on one line and enter that amended statement on another line.
Exercise 9 - Programming cursor movement Editing: a Review Cursor control characters may be programmed into PRINT state- When you press one of the PET's cursor control keys, you may be in one ments. It is often desirable to clear the PET display under program of two editing modes, as you have already seen.
function to open up spaces into which he can then type INSERT the appropriate control character. The user can, of course, close the quotes, and thereby signal PET that he is through with the literal message. However, once the second quote mark has been typed, PET will no longer recognize cursor movement as a part of created code, and the cursor will move accord- ing to the Function represented by the key pressed.
TIME tells PET to print the time in hours/minutes/ BASIC is essentially an algebraic language which means that you www.commodore.ca can use your PET much as you would a pocket calculator. Though it Free for personal use but you must have written permission to reproduce...
Page 14
1 2Q of the program. The brief description of the function, along with actually trying it yourself, will show you how to use it. PET says: 460.666667 Type: ?(9*8+7*6-5)*(4/3*2) PET says: 290.666667 www.commodore.ca Free for personal use but you must have written permission to reproduce...
Page 15
Try using the string functions, too. You'll need a new program to do You, as the programmer, can put any number you like in statements that (be sure to type in NEW first): 1 10 and 120. You don't have to use 5 and 10. It would be cumbersome to have to retype lines 1 10 and 130 every time you wanted to change the numbers.
Page 16
And PET will do as much as you ask to each pair of numbers before going after the NEXT pair. Note that your PET automatically places the line numbers in ascending www.commodore.ca order, too. Using INPUT makes it easier to check the numbers, doesn't it'? Now Free for personal use but you must have written permission to reproduce you just type RUN, and each time you do so.
Exercise 14 - Animating your PET It's easy to move an object smoothly across the CRT, thanks to PET's programmable cursor controls. The listings below give you the fun- damental right-left-up-down motions. Later we will show you how to program an unidentified flying object. Move a ball right &...
BASIC programs, either created by you or purchased and another program on the same tape PET won't know "ROCKET". from the extensive COMMODORE library. which is which, and will load the first program with the letters ROCK its name.
Page 19
Disclaimer on Software: The complex and extensive software of the PET computer has been thoroughly tested and is believed to be quite reliable. However, no responsibility is assumed by Commodore or your sales agent for inaccuracies. Pressing the and the...
SQR(-4) e. At B if A is a negative value and B is not an integer. (It works if a constant is used instead of a variable, i.e., www.commodore.ca -4t B, because exponentiation is performed before unary minus.) Free for personal use but you must have written permission to reproduce f.
Page 21
Check device numbers (2nd parameter in the OPEN statement) given a numeric one or vice versa. and he sure the device is assigned and connected properly and turned on. www.commodore.ca Free for personal use but you must have written permission to reproduce...
2 . B a s i c c o m m a n d s Basic Commands and Statements (Continued) COMMAND/ Basic Commands and Statements PURPOSE S T A T E M E N T E X A M P L E COMMAND/ S T A T E M E N T E X A M P L E...
Basic Commands and Statements (Continued) Basic Commands and Statements (Continued) C O M M A N D ? COMMAND;' S T A T E M E N T PURPOSE E X A M P L E S T A T E M E N T E X A M P L E PURPOSE LOAD...
String Functions (Continued) Arithmetic Operators FUNCTION EXAMPLE PURPOSE PURPOSE S Y M B O L EXAMPLE MID$ 10 ?MID$(X$,A,B) 10 A=B Assigns a value to a variable. Returns B characters from string, starting with the Ath character. 20 LET A=B Let is optional.
Resets reverse field printing to normal printing. as the keytops. Inserts a space immediately in cursor position. All www.commodore.ca characters to right of inserted space are moved one space to right. Stops when 80th character is Free for personal use but you must have written permission to reproduce...
5. Cleaning and demagnetizing de-activate field until demagnetizer is at least two feet away from your tape deck head heads. To be performed every 50-100 hours of tape running time or when Tape head cleaning and demagnetizer procedure is now complete. cassette unit tails to read tapes reliably.
Page 27
Create PET programs for fun and profit ... But make sure you deal with Commodore directly. We at Commodore encourage you, the PET user, to submit programs to us. These programs, when accepted us, will earn royalties for you on each program sold.
Page 28
B l o c k C , 1 1 t h f l o o r H o n g K o n g , H o n g K o n g Copyright 1978 by Commodore Business Machines Inc.. Part No. 320165...
Need help?
Do you have a question about the PET 2001 Series and is the answer not in the manual?
Questions and answers