Here - 1000 BiT
Here - 1000 BiT Here - 1000 BiT
INSTRUCTOR NOTES 8 THE GOTO COMMAND AND THE STOP KEY uThe GOTO command allows "dumb" loops which go on forever. It also helps in flow of O1command in later programs, after the IF is introduced. It provides a slow and easyentrance for the student into the idea that the flow of command need not just go downthe list of numbered lines. , ,^For now its main use is to let programs run on for a reasonable length of time. In each \^jloop through, something can be modified.The problem is how to stop it. The STOP key does this nicely. For cases where you havemessed up the computer quite completely, pressing the STOP key may not in fact stopthe program. For example, if the program reached an INPUT command (and shows the , ,"?" and flashing cursor), pressing STOP does not stop the program. Try this. Hold STOPdown and then press the RESTORE key once or twice.t^jo^GOTO allows the bad habit of "spaghetti" programming to grow. Examples of spaghettiare shown to the students. Although some fun is had with them, make the studentconscious of the mess which undisciplined use of GOTO can make.O1^We now have three of the four major elements which lead to "real" programming. Theyare PRINT, INPUT and GOTO. Lacking is the IF, which will change the computer from \^jsome sort of a record player into a machine which can evaluate situations and makedecisions accordingly. O1QUESTIONS:W1. In this little program:10 PRINT "HI"20 GOTO 40 ^J30 PRINT "BIG"40 PRINT "DADDY" ^what.will appear in the screen when it is run?2. And this one:10 PRINT "APPLE"20 PRINT "PIE"; W30 GOTO 20 ^j3. How do you stop the program in question 2? ^J4. Write a short program which asks you your favorite movie star's name, and thenPRINTS it over and over again.48
LESSON 8THE GOTO COMMAND AND THE STOP KEYJUMPING AROUND INYOUR PROGRAMnTry this program: 10 PRINT "clr"20 PRINT "YOUR NAME?"25 INPUT N$30 PRINT N$35 PRINT40 GOTO 30RUN this program. It never stops by itself!eyes, press theTo stop your name from whizzing past yourSTOP key.nLine 40 uses the GOTO command. It is like "GO TO JAIL" in a game of Monopoly. Everytime the computer reaches line 40, it has to go back to line 30 and print your name again.We will use GOTO in a lot of programs.nMORE JUMPINGnEnter20 PRINT "SAY SOMETHING"30 INPUT S$X/ 40PRINTI'DIDYOUSAY"';S$;"1?"( 45 PRINT^ 50 GOTO 30Run the program. Type an answer every time you see the "?" and the flashing cursor.Press the STOP key to end the program.nNotice the arrow from line 50 to line 30. It shows what the GOTO does. You may want todraw such arrows in your program listings.49
- Page 3 and 4: KIDSAND THECOMMODORE 64
- Page 5 and 6: KIDSAND THECOMMODORE 64neoartment o
- Page 7 and 8: nTABLE OF CONTENTSAcknowledgements
- Page 9 and 10: nACKNOWLEDGEMENTS^My sincere thanks
- Page 11 and 12: nTO THE PARENTSThis book is designe
- Page 13 and 14: n~ ABOUT PROGRAMMINGThere is a comm
- Page 15 and 16: nn INSTRUCTOR NOTES 1 NEW, PRINT, R
- Page 17 and 18: COMMAND THE COMPUTERTry this. Type
- Page 19 and 20: THE NUMBER ZERO AND THE LETTER "O"T
- Page 21 and 22: nINSTRUCTOR NOTES 2COLOR AND THE KE
- Page 23 and 24: There are eight colors on the numbe
- Page 25 and 26: OTHER COMMANDS IN PRINT STATEMENTSJ
- Page 27 and 28: LESSON 3 LIST, BOXES IN MEMORYClear
- Page 29: ADDING A LINEYou can add a new line
- Page 35 and 36: THE DELETE KEYThe DEL key is your "
- Page 37 and 38: INSTRUCTOR NOTES 5 TRICKS WITH PRIN
- Page 39 and 40: RULE: The semicolon makes the invis
- Page 41 and 42: Assignment 5:1- Write a program whi
- Page 43 and 44: LESSON 6THE INPUT COMMANDUse INPUT
- Page 45 and 46: YOU WEAR TWO HATS, USER AND PROGRAM
- Page 47 and 48: LESSON 7THE LET COMMAND, GLUING STR
- Page 49: GLUING THE STRINGSHere is how to st
- Page 53 and 54: A CAN OF SPAGHETTILook at this: 10
- Page 55 and 56: Assignment 8:1. Just for practice i
- Page 57 and 58: LESSON 9 THE IF COMMANDClear the me
- Page 59 and 60: JtTHE "NOT EQUAL" SIGNTwo signs:= m
- Page 61 and 62: INSTRUCTOR NOTES 10 INTRODUCING NUM
- Page 63 and 64: The thing which is put into the box
- Page 65 and 66: MIXTURES IN PRINTYou can print numb
- Page 67 and 68: INSTRUCTOR NOTES 11TAB AND DELAY LO
- Page 69 and 70: HOW BIG A SPACE CAN TAB( ) MAKE?The
- Page 71 and 72: INSTRUCTOR NOTES 12 THE IF COMMAND
- Page 73 and 74: AN IF INSIDE AN IFThe "teenager" pr
- Page 75 and 76: 2. Here is another program. What wi
- Page 77 and 78: LESSON 13RANDOM NUMBERS AND THE INT
- Page 79 and 80: ROUNDING OFF NUMBERSPerhaps you kno
- Page 81 and 82: INSTRUCTOR NOTES 14SAVING TO TAPEWe
- 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
LESSON 8THE GOTO COMMAND AND THE STOP KEYJUMPING AROUND INYOUR PROGRAMnTry this program: 10 PRINT "clr"20 PRINT "YOUR NAME?"25 INPUT N$30 PRINT N$35 PRINT40 GOTO 30RUN this program. It never stops by itself!eyes, press theTo stop your name from whizzing past yourSTOP key.nLine 40 uses the GOTO command. It is like "GO TO JAIL" in a game of Monopoly. Everytime the computer reaches line 40, it has to go back to line 30 and print your name again.We will use GOTO in a lot of programs.nMORE JUMPINGnEnter20 PRINT "SAY SOMETHING"30 INPUT S$X/ 40PRINTI'DIDYOUSAY"';S$;"1?"( 45 PRINT^ 50 GOTO 30Run the program. Type an answer every time you see the "?" and the flashing cursor.Press the STOP key to end the program.nNotice the arrow from line 50 to line 30. It shows what the GOTO does. You may want todraw such arrows in your program listings.49