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

  1. 3000    ' tutor 5        Ver 2.0        01AUG83
  2. 3010    GOSUB 37100
  3. 3020    T5$ = SPACE$(5) : T10$ = SPACE$(10) : T15$ = SPACE$(15) :VT$ = CHR$(11)
  4. 3030    PRINT T10$;"I'm back again. Glad you're still here. Let's see........"
  5. 3040    PRINT CRLF$;T10$;"the program as it now stands says:";CRLF$
  6. 3050    PRINT "11 READ X Y Z"
  7. 3060    PRINT "12 DATA 3,4,12,8,15,11"
  8. 3070    PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
  9. 3080    PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
  10. 3090    PRINT "35 GOTO 9"
  11. 3100    PRINT "40 END";CRLF$
  12. 3110    PRINT T10$;"Remember we deleted the old lines 9 and 10."
  13. 3120    PRINT T10$;"Let's use the 'GOTO' statement already in the program, but"
  14. 3130    PRINT T10$;"change it to either  'GOTO 11'  or else to  'GOTO 12'.  Only"
  15. 3140    PRINT T10$;"one of these is correct.";CRLF$ 
  16. 3150    PRINT T10$;"Do you think it is '11' or '12'? ";
  17. 3160    GOSUB 40900 : V$ = CVTSTR$
  18. 3170    PRINT
  19. 3180    IF V$ = "11" THEN 3220
  20. 3190    IF V$ = "12" THEN 3220
  21. 3200    PRINT T10$;"Your answer HAS to be either 11 or 12. Which is it! ";
  22.         VT$;VT$;CR$;ELR$;
  23. 3210    GOTO 3150
  24.  
  25. 3220    GOSUB 37100
  26. 3230    PRINT T10$;"'11' is correct, because it is 'READ' which we want done twice."
  27. 3240    PRINT T10$;"'DATA' is not a sequentially executed instruction - it"
  28. 3250    PRINT T10$;"simply provides information to be operated on by"
  29. 3260    PRINT T10$;"the machine. Incidentally, the 'DATA' statement may be placed"
  30. 3270    PRINT T10$;"anywhere in the program preceding 'END'. To illustrate this,"
  31. 3280    PRINT T10$;"let's move it from line 12 to line 38.";CRLF$
  32. 3290    PRINT T10$;"The program will now be:";CRLF$
  33. 3300    PRINT "11 READ X Y Z"
  34. 3310    PRINT "20 LET R=SQR(X^2 + Y^2 + Z^2)"
  35. 3320    PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
  36. 3330    PRINT "35 GOTO 11"
  37. 3340    PRINT "38 DATA 3,4,12,8,15,11"
  38. 3350    PRINT "40 END";CRLF$
  39. 3360    PRINT T10$;"   To see how the computer will respond when 'RUN'"
  40. 3370    PRINT T10$;"is typed by the user, press any key: "; : GOSUB 40800
  41.  
  42. 3380    GOSUB 37100
  43. 3390    PRINT "The radius vector equals 13"
  44. 3400    PRINT "The radius vector equals 20.2485"
  45. 3410    PRINT "Out of DATA in 11";CRLF$;CRLF$
  46. 3420    PRINT T10$;"This is fine, but the computer doesn't say what set of values we"
  47. 3430    PRINT T10$;"used for each one. (It also gives an error message of 'Out of Data',"
  48. 3432    PRINT T10$;"which we'll cover later). So we can add a second print statement:"
  49. 3440    PRINT
  50. 3450    PRINT "25 PRINT "; CHR$(34); "X, Y, and Z values are, respectively:";
  51.         CHR$(34); ";X, Y, Z";CRLF$
  52. 3460    PRINT T10$;"The line number should be between 20 and 30 so it will precede"
  53. 3470    PRINT T10$;"the 'PRINT' on line 30. so now our program might well be:"
  54. 3480    GOSUB 37000
  55.  
  56. 3490    GOSUB 37100
  57. 3500    PRINT "11 READ X,Y,Z"
  58. 3510    PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
  59. 3520    PRINT "25 PRINT"; CHR$(34); "X, Y, and Z values are, respectively:";
  60.          CHR$(34); ";X, Y, Z"
  61. 3530    PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
  62. 3540    PRINT "35 GOTO 11"
  63. 3550    PRINT "38 DATA 3,4,12,8,15,11"
  64. 3560    PRINT "40 END";CRLF$;CRLF$
  65. 3570    PRINT T10$;"Press any key to see the computer response:"; :GOSUB 40800
  66.  
  67. 3580    GOSUB 37100
  68. 3590    PRINT "X, Y, and Z values are, respectively: 3, 4, 12"
  69. 3600    PRINT "The radius vector equals 13"
  70. 3610    PRINT "X, Y, and Z values are, respectively: 8, 15, 11"
  71. 3620    PRINT "The radius vector equals 20.2485"
  72. 3630    PRINT "Out of DATA in 11"
  73. 3640    PRINT
  74. 3650    PRINT T10$; "   This provides the necessary information. If the quantity of"
  75. 3660    PRINT T10$;"data exceeds the available line space in the 'DATA' statement,"
  76. 3670    PRINT T10$;"additional 'DATA' statements can be used, so long as they are"
  77. 3680    PRINT T10$;"numbered such that the data values are sequenced properly."
  78. 3690    PRINT
  79. 3700    PRINT T10$;"   Notice that the input values in each set must have different"
  80. 3710    PRINT T10$;"names (i.e., X, Y, and Z). We could call them all by the same"
  81. 3720    PRINT T10$;"name by using subscripts. The computer does this by parentheses."
  82. 3730    PRINT T10$;"So instead of X, Y, and Z, we could use, say, W(1), W(2), and"
  83. 3740    PRINT T10$;"W(3) - then change program statements accordingly."
  84. 3750    GOSUB 37000
  85.  
  86. 3760    GOSUB 37100
  87. 3770    PRINT "11 READ X,Y,Z"
  88. 3780    PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
  89. 3790    PRINT "25 PRINT"; CHR$(34); "X, Y, and Z values are, respectively:";
  90.          CHR$(34); ";X, Y, Z"
  91. 3800    PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
  92. 3810    PRINT "35 GOTO 11"
  93. 3820    PRINT "38 DATA 3,4,12,8,15,11"
  94. 3830    PRINT "40 END";CRLF$;CRLF$
  95. 3840    PRINT T10$;"   If we wanted to use subscripted variables in this program,"
  96. 3850    PRINT T10$;"which is the first line number in which we must make a change?"
  97. 3860    PRINT T10$;"(naturally, line numbers would not change)";CRLF$
  98. 3870    PRINT T10$;"The line number of the first statement to change would be? ";
  99. 3880    GOSUB 40900 : U$ = CVTSTR$
  100. 3890    IF U$ = "11" THEN 3920
  101. 3900    PRINT : PRINT CRLF$;T10$;"Look at the program more carefully.  Try again.";
  102.         VT$;vt$;VT$;CR$;
  103. 3910    GOTO 3870
  104. 3920    PRINT
  105. 3928    PRINT T10$;"Right! And how many statements would not have to be changed? ";ees$; :
  106.     GOTO 3940
  107. 3930    PRINT vt$;T10$;"How many statements would not have to be changed? ";elr$;
  108. 3940    GOSUB 40900 : S$ = CVTSTR$
  109. 3950    IF S$ = "4" THEN 3980
  110. 3960    PRINT : PRINT CRLF$;T10$;"Look real close!"; VT$;VT$;CR$;
  111. 3970    GOTO 3930
  112.  
  113. 3980    GOSUB 37100
  114. 3990    PRINT T10$;"That's the idea. but with subscripts, the computer must be"
  115. 4000    PRINT T10$;"'WARNED' to reserve sufficient memory space for the values. "
  116. 4010    PRINT T10$;"The term for this is the word 'DIMENSION'. Which of the below"
  117. 4020    PRINT T10$;"instructions do you think might 'RESERVE STORAGE'?";CRLF$
  118. 4030    PRINT T10$;"     GET          (type '1' for this choice)"
  119. 4040    PRINT T10$;"     SAVE         (type '2' for this choice)"
  120. 4050    PRINT T10$;"     DIM W(3)     (type '3' for this choice)";CRLF$
  121. 4060    PRINT FNCENTER$("Your choice: "); : GOSUB 40900
  122. 4070    Q$ = CVTSTR$
  123. 4080    PRINT
  124. 4090    IF LEFT$(Q$,1) = "3" THEN 4160
  125. 4100    IF LEFT$(Q$,1) < "3" AND LEFT$(Q$,1) > "0" THEN 4130
  126. 4110    PRINT EES$;T10$;"No such choice. again......";VT$;VT$;CR$;
  127. 4120    GOTO 4060
  128. 4130    PRINT T10$;"No, but we'll take up that instruction in a future lesson."
  129. 4140    PRINT T10$;"Take another guess......";VT$;VT$;VT$;CR$;
  130. 4150    GOTO 4060
  131. 4160    GOSUB 37100
  132.  
  133. 4170    PRINT FNPOSCUR$(8,1);
  134. 4180    PRINT T10$;"   Right. 'DIM' stands for 'dimension', 'W' is the name, and"
  135. 4190    PRINT T10$;"'(3)' is the number of locations needed. (You may reserve more"
  136. 4200    PRINT T10$;"than you expect to use, if you wish). Let's assume we have only one"
  137. 4210    PRINT T10$;"set of values for our three W's (We'll take a closer look at"
  138. 4220    PRINT T10$;"the use of subscripts in a future lesson). So we can eliminate"
  139. 4230    PRINT T10$;"the 'GOTO' instruction, and that leaves us a program with the"
  140. 4240    PRINT T10$;"'DIM' statement but no 'go to' statement.";CRLF$
  141. 4250    PRINT T15$;"Press any key to see an example:"; : GOSUB 40800
  142.  
  143. 4260    GOSUB 37100
  144. 4270    PRINT "8  DIM W(3)"
  145. 4280    PRINT "11 READ W(1), W(2), W(3)"
  146. 4290    PRINT "20 LET R=SQR(W(1)^2+W(2)^2+W(3)^2)"
  147. 4300    PRINT "25 PRINT "; CHR$(34); "W(1), W(2), and W(3) are:"; CHR$(34); ";W(1), W(2), W(3)"
  148. 4310    PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
  149. 4320    PRINT "38 DATA 3,4,12"
  150. 4330    PRINT "40 END"
  151. 4340    PRINT
  152. 4350    PRINT T10$;"   Note that 'DIM' should be put first. This is so it will"
  153. 4360    PRINT T10$;"'set up' the computer's memory for the problem."
  154. 4370    PRINT
  155. 4380    PRINT T10$;"Well, you've completed another lesson.  Be sure to try your"
  156. 4390    PRINT T10$;"problems on the computer every chance you get. See you soon."
  157. 4400    PRINT CRLF$
  158. 4410    PRINT FNCENTER$("Press any key for menu");
  159. 4420    FOR CT = 1 TO 22 : PRINT CHR$(8); : NEXT CT :GOSUB 40800
  160. 4430    GOTO 39999
  161.  
  162. 37000    'press any key pause
  163. 37010    PRINT CRLF$;CRLF$;FNCENTER$("press any key to continue");
  164. 37020    FOR CT= 1 TO 25 : PRINT CHR$(8); : NEXT CT
  165. 37030    GOSUB 40800
  166. 37099    RETURN
  167.  
  168. 37100    ' heading
  169. 37110    PRINT CLS$;FNPOSCUR$(4,1);FNCENTER$("Tutor -- Lesson 5");CRLF$
  170. 37199    RETURN
  171.  
  172. 38000    ' version 2.0  released to nls 1 aug 83
  173. 38010    ' converted for Non-linear Systems, Kaypro Educational Division
  174. 38020    ' by t.crew , Simple Software, San Diego CA
  175. 38030    ' has to be run with mentutr to get all variables
  176.  
  177. 39999    RUN "MENU" 'end of overlay
  178.  
  179.