home *** CD-ROM | disk | FTP | other *** search
- 3000 ' tutor 5 Ver 2.0 01AUG83
- 3010 GOSUB 37100
- 3020 T5$ = SPACE$(5) : T10$ = SPACE$(10) : T15$ = SPACE$(15) :VT$ = CHR$(11)
- 3030 PRINT T10$;"I'm back again. Glad you're still here. Let's see........"
- 3040 PRINT CRLF$;T10$;"the program as it now stands says:";CRLF$
- 3050 PRINT "11 READ X Y Z"
- 3060 PRINT "12 DATA 3,4,12,8,15,11"
- 3070 PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
- 3080 PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
- 3090 PRINT "35 GOTO 9"
- 3100 PRINT "40 END";CRLF$
- 3110 PRINT T10$;"Remember we deleted the old lines 9 and 10."
- 3120 PRINT T10$;"Let's use the 'GOTO' statement already in the program, but"
- 3130 PRINT T10$;"change it to either 'GOTO 11' or else to 'GOTO 12'. Only"
- 3140 PRINT T10$;"one of these is correct.";CRLF$
- 3150 PRINT T10$;"Do you think it is '11' or '12'? ";
- 3160 GOSUB 40900 : V$ = CVTSTR$
- 3170 PRINT
- 3180 IF V$ = "11" THEN 3220
- 3190 IF V$ = "12" THEN 3220
- 3200 PRINT T10$;"Your answer HAS to be either 11 or 12. Which is it! ";
- VT$;VT$;CR$;ELR$;
- 3210 GOTO 3150
-
- 3220 GOSUB 37100
- 3230 PRINT T10$;"'11' is correct, because it is 'READ' which we want done twice."
- 3240 PRINT T10$;"'DATA' is not a sequentially executed instruction - it"
- 3250 PRINT T10$;"simply provides information to be operated on by"
- 3260 PRINT T10$;"the machine. Incidentally, the 'DATA' statement may be placed"
- 3270 PRINT T10$;"anywhere in the program preceding 'END'. To illustrate this,"
- 3280 PRINT T10$;"let's move it from line 12 to line 38.";CRLF$
- 3290 PRINT T10$;"The program will now be:";CRLF$
- 3300 PRINT "11 READ X Y Z"
- 3310 PRINT "20 LET R=SQR(X^2 + Y^2 + Z^2)"
- 3320 PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
- 3330 PRINT "35 GOTO 11"
- 3340 PRINT "38 DATA 3,4,12,8,15,11"
- 3350 PRINT "40 END";CRLF$
- 3360 PRINT T10$;" To see how the computer will respond when 'RUN'"
- 3370 PRINT T10$;"is typed by the user, press any key: "; : GOSUB 40800
-
- 3380 GOSUB 37100
- 3390 PRINT "The radius vector equals 13"
- 3400 PRINT "The radius vector equals 20.2485"
- 3410 PRINT "Out of DATA in 11";CRLF$;CRLF$
- 3420 PRINT T10$;"This is fine, but the computer doesn't say what set of values we"
- 3430 PRINT T10$;"used for each one. (It also gives an error message of 'Out of Data',"
- 3432 PRINT T10$;"which we'll cover later). So we can add a second print statement:"
- 3440 PRINT
- 3450 PRINT "25 PRINT "; CHR$(34); "X, Y, and Z values are, respectively:";
- CHR$(34); ";X, Y, Z";CRLF$
- 3460 PRINT T10$;"The line number should be between 20 and 30 so it will precede"
- 3470 PRINT T10$;"the 'PRINT' on line 30. so now our program might well be:"
- 3480 GOSUB 37000
-
- 3490 GOSUB 37100
- 3500 PRINT "11 READ X,Y,Z"
- 3510 PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
- 3520 PRINT "25 PRINT"; CHR$(34); "X, Y, and Z values are, respectively:";
- CHR$(34); ";X, Y, Z"
- 3530 PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
- 3540 PRINT "35 GOTO 11"
- 3550 PRINT "38 DATA 3,4,12,8,15,11"
- 3560 PRINT "40 END";CRLF$;CRLF$
- 3570 PRINT T10$;"Press any key to see the computer response:"; :GOSUB 40800
-
- 3580 GOSUB 37100
- 3590 PRINT "X, Y, and Z values are, respectively: 3, 4, 12"
- 3600 PRINT "The radius vector equals 13"
- 3610 PRINT "X, Y, and Z values are, respectively: 8, 15, 11"
- 3620 PRINT "The radius vector equals 20.2485"
- 3630 PRINT "Out of DATA in 11"
- 3640 PRINT
- 3650 PRINT T10$; " This provides the necessary information. If the quantity of"
- 3660 PRINT T10$;"data exceeds the available line space in the 'DATA' statement,"
- 3670 PRINT T10$;"additional 'DATA' statements can be used, so long as they are"
- 3680 PRINT T10$;"numbered such that the data values are sequenced properly."
- 3690 PRINT
- 3700 PRINT T10$;" Notice that the input values in each set must have different"
- 3710 PRINT T10$;"names (i.e., X, Y, and Z). We could call them all by the same"
- 3720 PRINT T10$;"name by using subscripts. The computer does this by parentheses."
- 3730 PRINT T10$;"So instead of X, Y, and Z, we could use, say, W(1), W(2), and"
- 3740 PRINT T10$;"W(3) - then change program statements accordingly."
- 3750 GOSUB 37000
-
- 3760 GOSUB 37100
- 3770 PRINT "11 READ X,Y,Z"
- 3780 PRINT "20 LET R = SQR(X^2 + Y^2 + Z^2)"
- 3790 PRINT "25 PRINT"; CHR$(34); "X, Y, and Z values are, respectively:";
- CHR$(34); ";X, Y, Z"
- 3800 PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
- 3810 PRINT "35 GOTO 11"
- 3820 PRINT "38 DATA 3,4,12,8,15,11"
- 3830 PRINT "40 END";CRLF$;CRLF$
- 3840 PRINT T10$;" If we wanted to use subscripted variables in this program,"
- 3850 PRINT T10$;"which is the first line number in which we must make a change?"
- 3860 PRINT T10$;"(naturally, line numbers would not change)";CRLF$
- 3870 PRINT T10$;"The line number of the first statement to change would be? ";
- 3880 GOSUB 40900 : U$ = CVTSTR$
- 3890 IF U$ = "11" THEN 3920
- 3900 PRINT : PRINT CRLF$;T10$;"Look at the program more carefully. Try again.";
- VT$;vt$;VT$;CR$;
- 3910 GOTO 3870
- 3920 PRINT
- 3928 PRINT T10$;"Right! And how many statements would not have to be changed? ";ees$; :
- GOTO 3940
- 3930 PRINT vt$;T10$;"How many statements would not have to be changed? ";elr$;
- 3940 GOSUB 40900 : S$ = CVTSTR$
- 3950 IF S$ = "4" THEN 3980
- 3960 PRINT : PRINT CRLF$;T10$;"Look real close!"; VT$;VT$;CR$;
- 3970 GOTO 3930
-
- 3980 GOSUB 37100
- 3990 PRINT T10$;"That's the idea. but with subscripts, the computer must be"
- 4000 PRINT T10$;"'WARNED' to reserve sufficient memory space for the values. "
- 4010 PRINT T10$;"The term for this is the word 'DIMENSION'. Which of the below"
- 4020 PRINT T10$;"instructions do you think might 'RESERVE STORAGE'?";CRLF$
- 4030 PRINT T10$;" GET (type '1' for this choice)"
- 4040 PRINT T10$;" SAVE (type '2' for this choice)"
- 4050 PRINT T10$;" DIM W(3) (type '3' for this choice)";CRLF$
- 4060 PRINT FNCENTER$("Your choice: "); : GOSUB 40900
- 4070 Q$ = CVTSTR$
- 4080 PRINT
- 4090 IF LEFT$(Q$,1) = "3" THEN 4160
- 4100 IF LEFT$(Q$,1) < "3" AND LEFT$(Q$,1) > "0" THEN 4130
- 4110 PRINT EES$;T10$;"No such choice. again......";VT$;VT$;CR$;
- 4120 GOTO 4060
- 4130 PRINT T10$;"No, but we'll take up that instruction in a future lesson."
- 4140 PRINT T10$;"Take another guess......";VT$;VT$;VT$;CR$;
- 4150 GOTO 4060
- 4160 GOSUB 37100
-
- 4170 PRINT FNPOSCUR$(8,1);
- 4180 PRINT T10$;" Right. 'DIM' stands for 'dimension', 'W' is the name, and"
- 4190 PRINT T10$;"'(3)' is the number of locations needed. (You may reserve more"
- 4200 PRINT T10$;"than you expect to use, if you wish). Let's assume we have only one"
- 4210 PRINT T10$;"set of values for our three W's (We'll take a closer look at"
- 4220 PRINT T10$;"the use of subscripts in a future lesson). So we can eliminate"
- 4230 PRINT T10$;"the 'GOTO' instruction, and that leaves us a program with the"
- 4240 PRINT T10$;"'DIM' statement but no 'go to' statement.";CRLF$
- 4250 PRINT T15$;"Press any key to see an example:"; : GOSUB 40800
-
- 4260 GOSUB 37100
- 4270 PRINT "8 DIM W(3)"
- 4280 PRINT "11 READ W(1), W(2), W(3)"
- 4290 PRINT "20 LET R=SQR(W(1)^2+W(2)^2+W(3)^2)"
- 4300 PRINT "25 PRINT "; CHR$(34); "W(1), W(2), and W(3) are:"; CHR$(34); ";W(1), W(2), W(3)"
- 4310 PRINT "30 PRINT "; CHR$(34); "The radius vector equals"; CHR$(34); ";R"
- 4320 PRINT "38 DATA 3,4,12"
- 4330 PRINT "40 END"
- 4340 PRINT
- 4350 PRINT T10$;" Note that 'DIM' should be put first. This is so it will"
- 4360 PRINT T10$;"'set up' the computer's memory for the problem."
- 4370 PRINT
- 4380 PRINT T10$;"Well, you've completed another lesson. Be sure to try your"
- 4390 PRINT T10$;"problems on the computer every chance you get. See you soon."
- 4400 PRINT CRLF$
- 4410 PRINT FNCENTER$("Press any key for menu");
- 4420 FOR CT = 1 TO 22 : PRINT CHR$(8); : NEXT CT :GOSUB 40800
- 4430 GOTO 39999
-
- 37000 'press any key pause
- 37010 PRINT CRLF$;CRLF$;FNCENTER$("press any key to continue");
- 37020 FOR CT= 1 TO 25 : PRINT CHR$(8); : NEXT CT
- 37030 GOSUB 40800
- 37099 RETURN
-
- 37100 ' heading
- 37110 PRINT CLS$;FNPOSCUR$(4,1);FNCENTER$("Tutor -- Lesson 5");CRLF$
- 37199 RETURN
-
- 38000 ' version 2.0 released to nls 1 aug 83
- 38010 ' converted for Non-linear Systems, Kaypro Educational Division
- 38020 ' by t.crew , Simple Software, San Diego CA
- 38030 ' has to be run with mentutr to get all variables
-
- 39999 RUN "MENU" 'end of overlay
-