background image

29

BASIC

  is basic; however there are differences in the language based on the computer that

uses it in much the same way that English is different depending on which country it is
spoken in(Great Britain or the United States) or which part of the country the language
is spoken in(East Coast, Midwest, South or the West Coast).

The differences in the language will depend on the computer that is being used and on
the computer that produced the language for the computer manufacturer.  Microsoft BASIC,
so-called because it was developed by the Microsoft Corporation of Belleview, Washington,
is found on Apple II+, IBM PC and PC jr., Laser Computers, Commodore VIC20 and
Commodore 64 and others.  Other computers such as the Timex Sinclair ZX80 and the
Texas Instruments 99/4 use versions of BASIC similar to MS-BASIC.

WHAT IS A PROGRAM?

A  computer program is a series of instructions that tells a computer what tasks you want
it to perform.  Computer programs are written in a programming language.  

BASIC

  is one

of the languages that a human and a computer can understand, so 

BASIC

  can be used

to write a program that a computer can carry out for you.

WHY SHOULD I LEARN TO USE A COMPUTER?

Computers are going to be part of the future.  Computers can do many things if they are
given instructions.  For a particular job to be done, by a person or a machine, we must
specify the steps which must be done to do the job.  The computer becomes an extension
of our capabilities.  To do this requires us to learn how to talk to our computer.

This chapter will help you to get started.   All you need is your 

PRECOMPUTER PRESTIGE

TM

learning unit

 

and some time.

WHAT IS THIS CHAPTER FOR?

This chapter is a step-by-step guide for understanding programs and learning to use the
computer language called BASIC.

WHO IS THIS CHAPTER FOR?

This guide is written for students and adults who have little or no programming experience.
With a little time and effort you will discover that there is nothing difficult about learning
to talk to a computer.

WHAT IF I MAKE A MISTAKE?

Don’t worry about making a mistake.  The more mistakes you make the more you will learn.
This is called discovery!  The computer doesn’t care how many mistakes you make.  There
is nothing you can do to damage the computer - except smashing it. Experimenting is a
very good way to make your programs do exactly what you want.

Содержание PreComputer Prestige

Страница 1: ...COURSE BOOK...

Страница 2: ...R 3 THE KEYBOARD 5 9 CHAPTER 4 ACTIVITIES AND FUNCTIONS 9 24 CHAPTER 5 WORD PROCESSING 24 27 CHAPTER 6 BASIC 28 83 CHAPTER 7 CALCULATOR 84 86 CHAPTER 8 TIME LIMITS 87 CHAPTER 9 SCORING 88 89 CHAPTER 1...

Страница 3: ...en and a standard sized computer style keyboard that gives the user the look and the feel of a real laptop computer PRECOMPUTER PRESTIGE TM offers 42 activities that include tenses antonyms synonyms g...

Страница 4: ...move exhausted or new batteries from equipment when you are not going to use it for a long time Do not dispose of batteries in fire Do not attempt to recharge ordinary batteries The supply terminals a...

Страница 5: ...on Turn the unit off and unplug the adapter from the unit for 15 seconds Next plug the adapter back in and turn the unit on If the problem persists it may be the result of the adapter s wiring or the...

Страница 6: ...OLUME SWITCH Adjust the volume by sliding the Volume Switch toward the right hand side to increase the volume and toward the left hand side to decrease the volume MOUSE CONNECTION 1 Make sure the unit...

Страница 7: ...nctions described below Enter SPECIAL KEYS Enter Key Enter Press this key after typing or choosing an answer to confirm your selection Shift Key Press this key to type capital letters or the symbols s...

Страница 8: ...ly apply for some activities only Answer Key Press this key to see the correct answer to any question Left Player Right Player Keys Press these keys in games with a 2 player mode The first person to h...

Страница 9: ...want to interrupt a program in BASIC while it is running Alt key Press this key and one of the assigned keys to activate the shortcut key function in Word Processing Repeat Key Press this key when yo...

Страница 10: ...he right cursor button in WORD PUZZLE to close the clue window ACTIVITY SELECTOR There are 42 activities in the PRECOMPUTER PRESTIGE TM unit and they are divided into 5 activity groups Press any one o...

Страница 11: ...OSING HIGHLIGHTING During the course of entering the activities and during game play you will be asked to select choose or highlight an object a number a letter or a word This can be done in three dif...

Страница 12: ...ll have to scroll through the activity list by using the UP or DOWN arrow icons located on the right side of the screen Or you can use the UP or DOWN arrow keys on the keyboard Press the Enter key to...

Страница 13: ...ivities GENERAL DISPLAY In most of the activities you will see a display with status information handy icons and a working window The status information will include the player s name the number of li...

Страница 14: ...GE TM learning toy supports the following printers VTECH VT 25 EPSON LQ X70 EPSON 24 PIN EPSON 9 PIN EPSON STYLUS CANON BJ30 CANON BJ300 330 HP LASER IVL HP DESKJET After setting up the printer type y...

Страница 15: ...this the PRECOMPUTER PRESTIGE TM learning unit lets you set the date format that you are comfortable with There are two types of formats and they are American and British American January 1 1996 Brit...

Страница 16: ...appear on the screen Type in the missing form of that verb and press the Enter key to confirm your answer GRAMMAR QUIZ A sentence will appear on the screen with one grammatical error Choose the incor...

Страница 17: ...remaining are indicated on the right hand side NOTE The length of a word is indicated by the length of the flashing bar TEST TRAINER Test Trainer allows you to input information and have the unit test...

Страница 18: ...If the unit locates the record it will display it on the screen If the record cannot be found the first record of the list will display Editing Records Choose the icon when you want to edit a record...

Страница 19: ...ving on to the next line To do this enter your answer for the first line of the problem and press Enter to confirm The unit will automatically take you to the next line Continue to enter your answers...

Страница 20: ...n screen number keyboard Input the answer by choosing the numbers on the keyboard and select the icon to confirm your answer PERCENTAGES An equation which involves a fraction and a percentage will app...

Страница 21: ...the correct answer If you need help in 1 player mode press the Help key or click the icon to display the multiple choice options Using the Help will result in losing one chance DIVERSE DATES When you...

Страница 22: ...Icon using the tiles You can construct the path by swapping 2 tiles at a time If you want to swap tiles select the first tile you want to swap and then click on the second tile The two tiles will trad...

Страница 23: ...ctice session of Step By Step 1 You are allowed to draw whatever you like on the drawing board SECRET SEQUENCES The goal of this game is to guess the Secret Sequence The number of patterns you need to...

Страница 24: ...uage Don t worry about messing up the programs The original version will always be available to start over again These simple practice programs are listed in the APPENDIX of Chapter 6 of this manual B...

Страница 25: ...cessing document TELEPHONE DIRECTORY The PRECOMPUTER PRESTIGE TM learning toy comes with a built in Telephone and Address Directory You can enter the names phone numbers and addresses of your friends...

Страница 26: ...E TM will respond with Correct If the word is not in the dictionary it will respond with Cannot find the word You can click the icon to get suggestions with a list of possible words CHAPTER 5 WORD PRO...

Страница 27: ...select Save from the FILE menu icon and it will prompt you with the filename Press Enter to save the file or revise the name and save the file with a different name before pressing Enter to confirm Pl...

Страница 28: ...four block editing tools cut block copy block paste block or clear block CUT BLOCK To cut a block of text first define the block of text and select Cut from the EDIT menu The block will be removed fr...

Страница 29: ...nu icon to get a list of characters and symbols for input Press and keys to locate a symbol and press Enter to confirm Click the ESC icon on the symbol s pop up window to close the window SHORTCUT KEY...

Страница 30: ...ters used in businesses which are larger and require more space to operate People today generally work with a very small version of a computer called a microcomputer A microcomputer is a computing dev...

Страница 31: ...e used to write a program that a computer can carry out for you WHY SHOULD I LEARN TO USE A COMPUTER Computers are going to be part of the future Computers can do many things if they are given instruc...

Страница 32: ...key is used to delete one character at a time The Del key will shift all characters to the right of the cursor one position to the left thereby erasing the character under the cursor 7 Before anythin...

Страница 33: ...PRESTIGETM unit stores the line with the other lines into memory Later you can execute the program by typing the command RUN Don t forget to press the Enter key after typing RUN The program that you h...

Страница 34: ...s in any order The PRECOMPUTER PRESTIGETM will sort them out for you and LIST them or RUN starting with the lowest numbered statement to the highest numbered statement It is a good idea to number your...

Страница 35: ...IC you write a series of line numbered statements that tell the PRECOMPUTER PRESTIGE TM unit what to do The first statement numbered 10 tells the computer to work out the sum of three numbers and then...

Страница 36: ...same as 10 6 In subtraction the order is important 10 6 is not the same as 6 10 So the order that you write numbers and do arithmetic operations is important In BASIC operations are from left to righ...

Страница 37: ...simply evaluated from left to right It is necessary to have an exact set of rules to follow Here they are Functions Order in which they are performed things is parentheses brackets 1st raising to a p...

Страница 38: ...in it it doesn t make another box called B with a value of 15 in it The number 10 is just replaced with the number 15 Now type 40 LET C A B press Enter This statement is a bit more complicated Here s...

Страница 39: ...at the print statements on lines 50 through 70 The words in quotes are called a STRING or a LITERAL Whatever you put between a set of quotation marks will appear on the display exactly the way you ty...

Страница 40: ...ber The number 9E 12 is a very large negative number while the number 9E 12 is a very small negative number 4 STRING VARIABLES String variables are similar to the numeric variables that we have been w...

Страница 41: ...name The number 6 is a constant so is 4 567 or 28967 35 QUICK BROWN FOX is a string constant You can store constants to a variable That s usually done to start out a program later the contents of the...

Страница 42: ...10 LET N 10 20 LET A4 NANCY LIKES CHOCOLATE CUPCAKES Another way to supply data is by using an INPUT statement Try this out by typing NEW 10 INPUT GIVE ME A NUMBER N 20 PRINT YOUR NUMBER IS N The comp...

Страница 43: ...that it has to make a decision It does this by comparing two numbers arithmetic expressions or string variables It uses special symbols to represent a condition The symbol means greater than The symb...

Страница 44: ...a condition The PRINT YOU ARE SMART is the thing it does for the true condition In the above example let s give A the value 80 Would the message be printed No it would not be printed because the condi...

Страница 45: ...he value typed in is a Y Here s another one Type NEW 10 INPUT GIVE ME A NUMBER A 20 INPUT AND ANOTHER B 30 PRINT ADD SUBTRACT MULTIPLY OR DIVIDE 40 PRINT TYPE IN THE FIRST LETTER OF THE 50 PRINT ARITH...

Страница 46: ...ement tells the computer the number of the next statement to do Line 140 is an error trap It tells you that you have not followed instructions You can experiment some more with this program and put in...

Страница 47: ...NEXT statements These statements surround the instructions that you want to repeat For example type the following NEW 10 FOR N 1 TO 10 20 PRINT HELLO 30 NEXT N RUN How many times does the word HELLO g...

Страница 48: ...gram looks like this NEW 10 FOR N 1 TO 10 STEP 2 20 PRINT N IS N 30 NEXT N RUN The STEP 2 part changes the meaning hidden in the NEXT N statement to be N N 2 or any other number that gets put in the S...

Страница 49: ...es to the line number that you specify in the statements that will be executed sequentially until a RETURN statement is encountered At that point the program will resume at the next statement followin...

Страница 50: ...e computer will assume the number of bytes of memory for strings to be 50 The use of the CLEAR command only will reserve the same number of bytes as the default value However if a value follows the CL...

Страница 51: ...Example 10 DIM FRIEND 50 10 DIM PRICE 19 EDIT Use the EDIT command when you want to change a statement that has been typed into memory without re typing the entire line Just type EDIT and the line nu...

Страница 52: ...specified point to be shown X represents a value of horizontal position Y represents a value of vertical position Example 10 CLS 20 PSET 100 8 The result a screen pixel at coordinate 100 8 will be tur...

Страница 53: ...R DELAY 1 TO 70 50 NEXT DELAY 60 PRESET X 8 70 NEXT X 80 END VOICE This is a command to generate voice VOICE X X is the voice number A LIST OF AVAILABLE VOICE Voice Num X Voice 0 zero 1 one 2 two 3 th...

Страница 54: ...7 G 18 H 19 I 20 J 21 K 22 L 23 M 24 N 25 O 26 P 27 Q 28 R 29 S 30 T 31 U 32 V 33 W 34 X 35 Y 36 Z Zed 37 Z Zee FOR TO STEP NEXT Line FOR variable initial value TO final value STEP step size optional...

Страница 55: ...FOR ITEMS 1 TO 20 70 INPUT PRICE 80 SUM PRICE SUM 90 NEXT ITEMS FUNCTIONS A function is a mathematical procedure which when applied to a certain value will give a new value We call the value in brack...

Страница 56: ...Gives you the value ex i e the natural antilogarithm of X INT X Gives the greatest integer which is less than or equal to X RND X Gives a random whole number between 1 and X If X equals zero RND X re...

Страница 57: ...he absolute value of the result returned by INT will be greater than that of the argument Example PRINT INT 6 7 press Enter 7 RND X This will produce a random number between 1 and X if X is positive E...

Страница 58: ...ue of characters Thus if you put in spaces J O H N it comes out as 7 characters STR The STR function changes a number argument into a string Let us take a look at the following example and see how it...

Страница 59: ...Y turns the pixel status ON 0 the current coordinates X Y turns the pixel status OFF SUBSTRINGS It is also possible to get substrings of strings A substring is as you might guess a part of a string F...

Страница 60: ...6 30 PRINT B RUN ABCDEF RIGHT A N This will return a substring but starting from the Nth character from the end and running to the last one the right most character in the string A Example 10 A WHY 2...

Страница 61: ...ust enclose the string specified Refer to the appendix for the ASCII code table For example the ASCII decimal value of X is 88 If A XAB then ASC A 88 Example 10 X ASC ROY 20 PRINT X RUN 82 CHR N This...

Страница 62: ...and tells the computer to GOTO another line number After the process has been completed a RETURN statement is used to send the computer back to the line immediately after the GOSUB These statements ar...

Страница 63: ...ONAL BRANCHING It uses the general form IF condition THEN action clause A condition is made up of an expression a relation and an expression Any BASIC expression either numeric or string may be used b...

Страница 64: ...ater than 25 then the computer simply carries on with the normal line number order in the program Notice that it is not necessary to use the ELSE part of the command here as this is optional Example 1...

Страница 65: ...rs IF THEN ELSE and such statements are used where a condition is used to determine subsequent operations within the user program The logical operators are AND OR and NOT For the purpose of this discu...

Страница 66: ...TH TABLE FOR AND FUNCTION A B A AND B T T T T F F F T F F F F TRUTH TABLE TABLE FOR OR FUNCTION A B A OR B T T T T F T F T T F F F Note that T TRUE and F FALSE Example 10 INPUT A B C 20 IF A B AND B C...

Страница 67: ...3 15 6 binary 00000110 and 13 binary 00001101 so with reference to the OR truth table 6 OR 13 15 binary 00001111 iii 6 AND 13 4 6 binary 00000110 and 13 binary 00001101 so with reference to the AND tr...

Страница 68: ...line onward If the line is longer than 20 characters you must use picture of the Right key to move to the right To continue the LISTING press the Enter key To discontinue the LISTING press the Shift a...

Страница 69: ...th commas between each variable The DATA statement consists of a list of expressions separated by commas These expressions can be either numeric or strings The READ statement makes the computer look u...

Страница 70: ...END RUN 1 3 8 1 3 The RESTORE command makes subsequent READ statements get their values from the start of the first DATA statement Now see if you can work out what is happening here Example 10 REM FIN...

Страница 71: ...UESSING GAME 20 REM TEST OF SORTING RUN RUN tells the computer to begin to perform your program beginning with the lowest statement number STOP CONT Line STOP CONT The STOP command halts the RUNNING o...

Страница 72: ...To edit a file LLIST To print out the program in the RAM buffer NEW To initialize a BASIC program and delete the program in the RAM buffer CHR To display a symbol from the character table APPENDIX EX...

Страница 73: ...T CHR 92 _ 80 END 90 PRINT 100 PRINT 110 PRINT 120 PRINT CHR 92 130 END 3 AGECHECK 0 REM Just Right 10 INPUT What is your age AGE 20 PRINT Oh You are AGE years old 30 IF AGE 9 THEN GOTO 70 40 IF AGE 1...

Страница 74: ...his the first time you will 50 INPUT learn about programming Y N ANSWER 60 IF ANSWER Y OR ANSWER y THEN GOTO 200 70 IF ANSWER N OR ANSWER n THEN GOTO 300 80 PRINT I don t know what you mean 90 PRINT P...

Страница 75: ...50 PRINT Then your full name is SUM letters long 60 END 6 ADDMINUS 0 REM CALCULATE 10 INPUT Please input the first number A 11 INPUT And the second number B 20 PRINT Do you want to find their 30 INPUT...

Страница 76: ...ND 100 20 PRINT Hi I ve got a secret number 30 PRINT between 1 and 100 40 INPUT Guess it by typing a number ANSWER 50 IF ANSWER NO THEN GOTO 200 60 IF ANSWER NO THEN GOTO 100 70 PRINT No The secret nu...

Страница 77: ...PUT then what is the value of SUM ANS 50 IF ANS X Y THEN PRINT Yes you re right END 60 PRINT Oh no The answer is X Y 70 END 9 HANGMAN 0 REM HANGMAN 10 X RND 5 20 LIVE 5 30 FOR I 1 TO X 40 READ SECRET...

Страница 78: ...UT Make a guess G 140 T 150 GOSUB 3000 160 FOR I 1 TO L 170 IF G MID SECRET I 1 THEN 200 180 T T MID D I 1 190 GOTO 210 200 T T G 210 NEXT I 220 IF T SECRET THEN GOTO 4000 230 IF T D THEN 1000 240 IF...

Страница 79: ...T 2010 END 3000 G LEFT G 1 3010 A ASC G 3020 IF A 96 AND A 123 THEN A A 32 3030 G CHR A 3040 RETURN 4000 PRINT You are right 4010 PRINT the answer is SECRET 4020 END 10 BIRTHDAY 0 REM Birthday 10 PRIN...

Страница 80: ...MON 130 DATA January Wolfgang Amadeus Mozart 140 DATA February Charles Dickens 150 DATA March Michelangelo 160 DATA April Charlie Chaplin 170 DATA May Florence Nightengale 180 DATA June Bjorn Borg 19...

Страница 81: ...0 d 37 69 E 101 e 38 70 F 102 f 39 71 G 103 g 40 72 H 104 h 41 73 I 105 i 42 74 J 106 j 43 75 K 107 k 44 76 L 108 l 45 77 M 109 m 46 78 N 110 n 47 79 O 111 o 48 0 80 P 112 p 49 1 81 Q 113 q 50 2 82 R...

Страница 82: ...204 141 173 i 205 142 174 206 e 143 175 207 144 176 IJ 208 145 177 ij 209 146 178 210 147 179 I 211 148 180 212 149 181 213 150 182 214 151 183 215 152 184 216 153 185 o 217 154 186 218 155 187 219 15...

Страница 83: ...CANNOT CONTINUE An attempt is made to continue a program that 1 has halted due to an error 2 has been modified during a break in execution or 3 does not exist DIVISION BY ZERO A division by zero is e...

Страница 84: ...statement variable OUT OF DATA A READ statement is executed when there are no DATA statements with unread data remaining in the program OUT OF MEMORY A program is too large had too many FOR loops or...

Страница 85: ...mpt is made to create a string more than 255 characters long SUBSCRIPT OUT OF RANGE An array element is referenced either with a subscript that is outside the dimensions of the array or with the wrong...

Страница 86: ...rows of the keyboard are used in the Calculator activity To clear the screen use the key at the bottom of the keyboard BASIC CALCULATOR OPERATIONS The basic calculator operations are Addition or Shif...

Страница 87: ...ocated on the second and third rows of the keyboard Always press the function key first when using it in a problem and then enter the numbers it is to operate on AIM Operation Display Square root of a...

Страница 88: ...ee sign after inputting the number Function Operation Display SINE 60 sin 60 Enter 0 30481 SINE 60 sin 60 Enter 0 866025 COSINE 60 cos 60 Enter 0 952413 COSINE 60 cos 60 Enter 0 5 TANGENT 60 tan 60 En...

Страница 89: ...e the answer must be inputted within one minute In two player mode the two players must press their respective player s button in 30 seconds to get to answer first When it is your turn you have only 3...

Страница 90: ...Key in the Answer 1 Multiple Choice 3 Logic Games None Business Basics All Business Basics None except Typing Game Typing Game 4 SCORING CODE 1 One Player Mode Questions per round 5 Correct answer on...

Страница 91: ...e Questions per round 5 Starting Score 100 Correct answer 1st player 20 2nd player 10 Wrong answer 1st player 20 2nd player 10 4 For each word that is correctly typed 1 point is given When a word reac...

Страница 92: ...2010 in the US 01235 555545 in the UK or 1 800 267 7377 in Canada A service representative will be happy to help you Item No 80 1410 SUPER SCIENCETM Item No 80 1533 FAMOUS THINGS PLACESTM Item No 80 0...

Страница 93: ...in the US 01235 555545 in the UK or 1 800 267 7377 in Canada with any problems and or suggestions that you might have A service representative will be happy to help you Note This equipment generates a...

Отзывы: