Here - 1000 BiT
Here - 1000 BiT Here - 1000 BiT
THE GET COMMAND FOR NUMBERSThe GET command can be used to input numbers. If no key has been pressed/thenumber will be zero. Try this:Enter and run 10 GET N:IF N=0THEN 1015 PRINT N20 GOTO 10Press number keys. Now press a letter key. You see9SYNTAX ERRORwhen you try to GET a letter character in a numeric variable.Assignment 23:1. Write a program which has a "menu" for the user to choose from. The user makes herchoice by typing a single letter. Use GET to get the letter. Example:PRINT "WHICH COLOR? "The program changes the border color to the user's choice.2. Write a sentence making game. Each sentence has a noun subject, a verb and anobject. The first player types a noun (like "The donkey"). The second player types averb (like "sings"). The third player types another noun (like "the toothpick."). UseGET so no player can see the words of the others. You may expand the game byhaving adjectives before the nouns.134
^ INSTRUCTOR NOTES 24 PRETTY PROGRAMS, GOSUB, RETURN, END^ This lesson covers subroutines. The END command is also treated here because theprogram will usually have its subroutines at high line numbers and so must END in themiddle line numbers.Like GOTO, GOSUB causes a jump to another line number. The only difference is that inr^ GOSUB, control returns to the calling line after the subroutine is finished executing. Thisis accomplished by storing the line number following the GOSUB line on a stack. WhenO the computer encounters a RETURN statement, it pops the line number off the stack andreturns control to that line.^ Subroutines are useful not only in long programs but also in short ones where "chunking"the task into sections leads to clarity.One of the hardest habits to form in some students (and even some professionals) is to^ impose structure on the program. Structuring has gone by many names such as"structured programming" and "top down programming" and uses various techniques toDdiscipline the programmer.Call the student's attention to ways in which structuring can be done, and the advantagesr*\ in clarity of thought and ease of programming which result. In this book, writing goodREM statements and using modular construction in the program are the main techniques^offered.^QUESTIONS:O 1. What happens when the command END is executed?^ 2. How is GOSUB different from GOTO?3. What happens when RETURN is executed?o ■ ■■ -■■■■ •4. If RETURN is executed before GOSUB, what happens?n ■ ■ . ■ " '-■ " ■■■', '.5. What does "call the subroutine" mean?^ 6. How many END commands are you allowed to put into one program?^ 7. Why do you want to have subroutines in your programs?nnn135
- Page 83 and 84: The computer automatically turned o
- Page 85 and 86: nnr^nnnnnr^nnLOADING A PROGRAM FROM
- Page 87 and 88: 5. We are ready to put in the next
- Page 89 and 90: n INSTRUCTOR NOTES 15 SOME SHORTCUT
- Page 91 and 92: AN INPUT SHORTCUTInstead of10 PRINT
- Page 93 and 94: WHEN TO USE THE COLON SHORTCUTUse t
- Page 95 and 96: But if we write this line in a prog
- Page 97 and 98: LESSON 16 MOVING PICTURESMOVING THE
- Page 99 and 100: Line 40 waits for you to see this b
- Page 101 and 102: LESSON 17FOR-NEXT LOOPSRemember the
- Page 103 and 104: LOOP VARIABLESTo make sure that eac
- Page 105 and 106: ^ INSTRUCTOR NOTES 18 DATA, READ, R
- Page 107 and 108: STRANGE RULES1. It doesn't matter w
- Page 109 and 110: MIXTURES OF DATAThe DATA statement
- Page 111 and 112: LESSON 19SOUND EFFECTSTurn up the s
- Page 113 and 114: TONES BY THE BUSHELEnter: 10 REM **
- Page 115 and 116: "TM" stands for "timbre." Timbre is
- Page 117 and 118: INSTRUCTOR NOTES 20NAMES, CLOCKS AN
- Page 119 and 120: cAnytimeyou type, the characters ar
- Page 121 and 122: LESSON 21COLOR GRAPHICSADJUST YOUR
- Page 123 and 124: Add these lines to the above progra
- Page 125 and 126: INSTRUCTOR NOTES 22POKEing GRAPHICS
- Page 127 and 128: Try this: Change the number 83 to a
- Page 129 and 130: We can number the streets and house
- Page 131 and 132: n INSTRUCTOR NOTES 23 SECRET WRITIN
- Page 133: THE COMPUTER ISIMPATIENTThe compute
- Page 137 and 138: Assignment 24A:1. The delay loop is
- Page 139 and 140: Assignment 24B:1. Write a short pro
- Page 141 and 142: LESSON 25 LOGIC: AND, OR, NOTANOTHE
- Page 143 and 144: THE IF COMMAND TELLS LITTLE WHITE L
- Page 145 and 146: THE LOGIC SIGNSYou can use these si
- Page 147 and 148: LESSON 26 SNIPPING STRINGS: LEFTS,
- Page 149 and 150: CUTTING A PIECE OUT OF THE MIDDLETh
- Page 151 and 152: nnO INSTRUCTOR NOTES 27 SWITCHING N
- Page 153 and 154: MAKING NUMBERS INTO STRINGSRun10 RE
- Page 155 and 156: Assignment 27:1. Write a program wh
- Page 157 and 158: LESSON 28ACTION GAMES AND THE FUNCT
- Page 159 and 160: LOOKING IN THE KEYBOARD'S BOXHere i
- Page 161 and 162: Run it. It puts a white diamond on
- Page 163 and 164: cTHETARGETS ARE HEARTSAdd these lin
- Page 165 and 166: LESSON 29MUSICGo back and review th
- Page 167 and 168: REGISTER ADDRESSES Base address is
- Page 169 and 170: D^ INSTRUCTOR NOTES 30 ARRAYS AND T
- Page 171 and 172: The DIM... command tells the comput
- Page 173 and 174: 1 REM *** EIGHT QUEENS ***2 GOTO 10
- Page 175 and 176: Assignment 30:1. Write a program wh
- Page 177 and 178: LESSON 31SPRITES FOR ACTION GRAPHIC
- Page 179 and 180: Then use the CRSR keys to move the
- Page 181 and 182: MANY SPRITES AT ONCEHere are the bo
- Page 183 and 184: WATCH OUT, TWO SPRITES ARE GOING TO
THE GET COMMAND FOR NUMBERSThe GET command can be used to input numbers. If no key has been pressed/thenumber will be zero. Try this:Enter and run 10 GET N:IF N=0THEN 1015 PRINT N20 GOTO 10Press number keys. Now press a letter key. You see9SYNTAX ERRORwhen you try to GET a letter character in a numeric variable.Assignment 23:1. Write a program which has a "menu" for the user to choose from. The user makes herchoice by typing a single letter. Use GET to get the letter. Example:PRINT "WHICH COLOR? "The program changes the border color to the user's choice.2. Write a sentence making game. Each sentence has a noun subject, a verb and anobject. The first player types a noun (like "The donkey"). The second player types averb (like "sings"). The third player types another noun (like "the toothpick."). UseGET so no player can see the words of the others. You may expand the game byhaving adjectives before the nouns.134