home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / basic / basictut.ark / TUTR.04 < prev    next >
Encoding:
Text File  |  1985-02-10  |  6.6 KB  |  156 lines

  1. 3000    REM   TUT4
  2. 3010    QUOTE$ = CHR$(34)
  3. 3020 GOTO  3050
  4. 3030 PRINT "No such choice. Try again. Which";
  5. 3040 RETURN
  6. 3050 PRINT CLS$;FNPOSCUR$(10,1);"Hello again. Let's have a quick review. Using this code:"
  7. 3060 PRINT 
  8. 3070 PRINT "     1 = PRINT ; 2 = INPUT ; 3 = LET; 4 = GOTO; 5 = END"
  9. 3080 PRINT 
  10. 3090 PRINT "Which of the above is used for arithmetic operations";
  11. 3100 INPUT L
  12. 3110 PRINT 
  13. 3120 IF L = 3 THEN 3160
  14. 3130 IF L < = 5 THEN 3180
  15. 3140 GOSUB 3030
  16. 3150 GOTO 3100
  17. 3160 PRINT "Very good. Which one (almost) always produces a question mark";
  18. 3170 GOTO 3200
  19. 3180 PRINT "Good try......But it isn't right. Once more....";
  20. 3190 GOTO 3100
  21. 3200 INPUT M
  22. 3210 PRINT 
  23. 3220 IF M = 2 THEN 3280
  24. 3230 IF M < = 5 THEN 3260
  25. 3240 GOSUB 3030
  26. 3250 GOTO 3200
  27. 3260 PRINT "Take a 5-second break and try again. It should be...";
  28. 3270 GOTO 3200
  29. 3280 PRINT CLS$;FNPOSCUR$(4,1);"Excellent. If you use a comma with the INPUT statement, though,"
  30. 3290 PRINT "you can suppress the question mark.  If your statement looks"
  31. 3300 PRINT "something like this:"
  32. 3310 PRINT : PRINT "10    INPUT ";QUOTE$;"Enter a value, please. ";QUOTE$",X"
  33. 3320 PRINT : PRINT "The screen will then show this:"
  34. 3330 PRINT : PRINT "Enter a value, please. "
  35. 3332 print : print "Note that there is no question mark."
  36. 3340 GOSUB 4480
  37. 3350 PRINT "Well, now, you seem to know them. Let us look at some"
  38. 3360 PRINT "other kinds of statements. We'll be using 'READ' and 'DATA',"
  39. 3370 PRINT "both of which must be used if either one is used."
  40. 3380 PRINT 
  41. 3390 PRINT "Just judging from the sound of the word,"
  42. 3400 PRINT "'READ' sounds like it should resemble which one of these;"
  43. 3410 PRINT : PRINT "     (USE 1 = LET, 2 = INPUT , 3 = GOTO, OR 4 = PRINT )"
  44. 3420 PRINT : PRINT FNCENTER$("");
  45. 3430 INPUT R
  46. 3440 PRINT 
  47. 3450 IF R <  = 4 THEN 3480
  48. 3460 GOSUB 3030
  49. 3470 GOTO 3430
  50. 3480 IF R = 2 THEN 3510
  51. 3490 PRINT "Wrong choice. Try again. Which one";
  52. 3500 GOTO 3430
  53. 3510 PRINT CLS$;FNPOSCUR$(4,1);"That's correct. In both cases, information is being put into"
  54. 3520 PRINT "the computer. The difference (note this) is WHEN it is to be"
  55. 3530 PRINT "entered. For the 'INPUT' statement, the computer receives"
  56. 3540 PRINT "information while the program is being executed; the "
  57. 3550 PRINT "terminal is used and it waits for the data entry. However,"
  58. 3560 PRINT "the 'READ' statement requires that the information (DATA)"
  59. 3570 PRINT "be already available in the computer's memory.  Now you"
  60. 3580 PRINT "see where the 'DATA' statement comes in."
  61. 3590 GOSUB 4480
  62. 3600 PRINT "When the computer is instructed to 'READ', it immediately"
  63. 3610 PRINT "looks for the 'DATA' statement.  The word 'READ' must be"
  64. 3620 PRINT "followed by the name or names of where the computer is to put the 
  65. 3630 PRINT "'DATA' it is to 'READ'."
  66. 3640 PRINT "The actual numerical or letter values will be found after the word"
  67. 3650 PRINT "'DATA', so of course you must be sure that the values are there."
  68. 3660 GOSUB 4480
  69. 3670 PRINT "Now, let's return to our radius vector problem..."
  70. 3680 PRINT "First, let's delete lines 9 and 10.  This is easily done by"
  71. 3690 PRINT "typing the line number followed by the return key. This would"
  72. 3700 PRINT "look as follows on the terminal:"
  73. 3710 PRINT : PRINT "9": PRINT "10": PRINT 
  74. 3720 GOSUB 4480
  75. 3730 PRINT "Instead of using statements 9 and 10, let's say:"
  76. 3740 PRINT 
  77. 3750 PRINT "     11 READ X, Y, Z"
  78. 3760 PRINT 
  79. 3770 PRINT "     12 DATA 3, 4, 12"
  80. 3780 PRINT 
  81. 3790 PRINT "Study the above two statements carefully.  Notice where the"
  82. 3800 PRINT "COMMAS are (COMMAS are very important in computer directions."
  83. 3810 PRINT "You must never leave one out or put one in where it does not"
  84. 3820 PRINT "belong). What do you think the value of 'X' is";
  85. 3830 INPUT X
  86. 3840 PRINT 
  87. 3850 IF X = 3 THEN 3940
  88. 3860 IF X = 4 THEN 3910
  89. 3870 IF X = 12 THEN 3910
  90. 3880 PRINT "No - You see, it has to be one of the numbers following the"
  91. 3890 PRINT "word 'DATA'. Try again, now.  How much is X";
  92. 3900 GOTO  3830
  93. 3910 PRINT "That's a good try.  You chose one of the numbers following"
  94. 3920 PRINT "'DATA', but not the right one.  Once more: X = ";
  95. 3930 GOTO  3830
  96. 3940 PRINT "A perfect choice. And what is Z";
  97. 3950 INPUT Z
  98. 3960 PRINT 
  99. 3970 IF Z = 12 THEN 4010
  100. 3980 PRINT "No, that's not correct. Study the statements again along with"
  101. 3990 PRINT "your previous answer concerning X and try again. Z = ";
  102. 4000 GOTO  3950
  103. 4010 PRINT "Right again, and you now have mastered the fundamentals of"
  104. 4020 PRINT "these two types of statements."
  105. 4030 GOSUB 4480
  106. 4040 PRINT "Let us consider one more thing about 'DATA' - You are allowed to"
  107. 4050 PRINT "have more than one data 'SET' with the 'DATA' statement. "
  108. 4060 PRINT "For instance, if we wanted to determine two radius vectors"
  109. 4070 PRINT "instead of one, we could replace statement 12 with:"
  110. 4080 PRINT 
  111. 4090 PRINT "     12 DATA 3, 4, 12, 8, 15, 11"
  112. 4100 PRINT " "
  113. 4110 PRINT "This statement contains two X's, two Y's, and two Z's.  One of"
  114. 4120 PRINT "each of these has been included in statement 12 above.  Which"
  115. 4130 PRINT "do you think is the second Y: the '8', the '15', or the '11'";
  116. 4140 INPUT Y
  117. 4150 PRINT 
  118. 4160 IF Y = 15 THEN 4240
  119. 4170 IF Y = 8 THEN 4210
  120. 4180 IF Y = 11 THEN 4210
  121. 4190 GOSUB 3030
  122. 4200 GOTO  4140
  123. 4210 PRINT "No; Take another look at the first set of data. Now, which"
  124. 4220 PRINT "one do you think it is";
  125. 4230 GOTO  4140
  126. 4240 PRINT CLS$;FNPOSCUR$(4,1);"That is correct. Also, the second X is 8 and the second Z"
  127. 4250 PRINT "is 11. So far, so good."
  128. 4260 PRINT 
  129. 4270 PRINT "However, the computer won't automatically 'READ' both sets,"
  130. 4280 PRINT "unless it is somehow directed to use the 'READ' statement twice."
  131. 4290 PRINT
  132. 4300 PRINT "Use 1 = PRINT , 2 = GOTO, 3 = LET, and 4 = INPUT , and decide which of"
  133. 4310 PRINT "these could make it 'READ' more than one set of 'DATA'. Which";
  134. 4320 INPUT K
  135. 4330 PRINT 
  136. 4340 IF K <  = 4 THEN 4370
  137. 4350 GOSUB 3030
  138. 4360 GOTO 4320
  139. 4370 IF K = 2 THEN 4420
  140. 4380 PRINT "No, not that one. Again, which";
  141. 4390 GOTO  4320
  142. 4400 PRINT "That's not a permissible choice. Try again: which of"
  143. 4410 GOTO  4310
  144. 4420 PRINT CLS$;FNPOSCUR$(4,1);"You're doing fine. This ends the 'TUTR04' part of your"
  145. 4430 PRINT "lesson. Now call the program 'TUTR05' (use the same method"
  146. 4440 PRINT "you used to call 'TUTR04') and continue your study."
  147. 4450 PRINT "Good luck!"
  148. 4460 GOSUB 4480
  149. 4470 run "MENU"
  150. 4480    REM >>    NON-STANDARD ROUTINES
  151. 4490   ' Here we give a message and wait for an input to continue
  152. 4500   PRINT FNPOSCUR$(24,1);TAB(20);"Hit any key to continue ... ";
  153. 4510   GOSUB 40800
  154. 4520   PRINT CLS$;FNPOSCUR$(4,1);
  155. 4530   RETURN
  156.