home *** CD-ROM | disk | FTP | other *** search
- 3000 ' tutor 7
- 3010 GOSUB 37100
- 3020 T5$ = SPACE$(5) : T10$ = SPACE$(10) : T15$ = SPACE$(15) :VT$ = CHR$(11)
- 3030 GOTO 3070
- 3040 PRINT ELR$;T10$;"No such choice! Let's try again.";VT$;VT$;CR$;
- 3050 RETURN
-
-
- 3060 GOSUB 37100
- 3070 PRINT T10$;" For a loop, we need special machine instructions. What form"
- 3080 PRINT T10$;"these take depends on how the computer is told the number of"
- 3090 PRINT T10$;"necessary iterations. It may be asked to decide this, which"
- 3100 PRINT T10$;"means that 'decision-making' can enter into the loop process."
- 3110 PRINT
- 3120 PRINT T10$;" In the program for computing radius vectors, the computer"
- 3130 PRINT T10$;"made a decision as to how many radius vectors to compute, based"
- 3140 PRINT T10$;"on the amount of data provided. There are many reasons why such"
- 3150 PRINT T10$;"a means of decision-making is impractical for ordinary purposes."
- 3160 PRINT T10$;"For one thing, you may not want to use all of the data for a"
- 3170 PRINT T10$;"particular 'run'. Other reasons will suggest themselves."
- 3180 PRINT
- 3190 PRINT T10$;" Ordinary decision-making is done by means of one of these"
- 3200 PRINT T10$;"four code words: (1) 'NEXT' (2) 'THEN' (3) 'IF' or (4) 'FOR'"
- 3210 PRINT T10$;"Which do you think it might be (use the number of the choice,"
- 3220 PRINT T10$;"following my question mark)..? ";
- 3230 GOSUB 40900 : Q$ = CVTSTR$
- 3240 PRINT
- 3250 IF Q$ <= "4" AND Q$ > "0" THEN 3280
- 3260 GOSUB 3040
- 3270 GOTO 3220
- 3280 IF Q$ = "3" THEN 3310
- 3290 PRINT ELR$;T10$;"This is used for something else. Try again.";VT$;VT$;CR$;
- 3300 GOTO 3220
- 3310 GOSUB 37100
- 3320 PRINT T15$;" (1) 'NEXT' (2) 'THEN' (3) 'IF' or (4) 'FOR'";CRLF$
- 3330 PRINT T10$;" You're right. 'IF' warns the computer that it is to make"
- 3340 PRINT T10$;"a choice, based on a given condition. Of course since a computer"
- 3350 PRINT T10$;"can't actually think (almost but not quite), it needs another"
- 3360 PRINT T10$;"code word to tell it what to do based on the choice. That other"
- 3370 PRINT T10$;"word is also one of those four listed above. Which do you"
- 3380 PRINT T10$;"suggest it might be? ";
- 3390 GOSUB 40900 : J$ = CVTSTR$
- 3400 PRINT
- 3410 IF J$ = "2" THEN 3440
- 3420 PRINT T10$;"You should have typed '2', because 'THEN' is the word that"
- 3430 GOTO 3450
- 3440 PRINT T10$;" Very Good! And to explain: the word 'THEN' is the one that"
- 3450 PRINT T10$;"conditionally (i.e., depending on some condition) 'clues' the"
- 3460 PRINT T10$;"machine as to just what statement (identified by line number)"
- 3470 PRINT T10$;"is to be used next in the program. 'IF' and 'THEN' are combined"
- 3480 PRINT T10$;"in a particular way. One of the following is the correct form:"
- 3490 PRINT
- 3500 PRINT T10$;" (1) IF X = 4 THEN 355 (3) IF X EQUALS 4 THEN 355"
- 3510 PRINT T10$;" (2) IF X THEN 355 (4) IF X IS 4 THEN 355"
- 3520 PRINT
- 3530 PRINT T10$;"Pick the one (number of choice) which seems correct: ";
- 3540 GOSUB 40900 : L$ = CVTSTR$
- 3550 PRINT
- 3560 IF L$ = "1" THEN 3660
- 3570 IF L$ = "2" THEN 3660
- 3580 IF L$ = "3" THEN 3620
- 3590 IF L$ = "4" THEN 3620
- 3600 GOSUB 3040
- 3610 GOTO 3530
- 3620 PRINT ELR$;T10$;"No, but you have the right idea. Try again.";
-
- VT$;VT$;CR$;
- 3630 GOTO 3530
- 3640 PRINT T10$;"This doesn't actually put any condition on 'X'. Guess again!";
-
- VT$;VT$;CR$;
- 3650 GOTO 3530
- 3660 GOSUB 37100
- 3670 PRINT T10$;" You figured that one out. Either '1' or '2' can be used, but"
- 3672 print t10$;"for different purposes. The '=' symbol in number '1' (rather "
- 3680 PRINT T10$;"than the word 'EQUALS' in 'X = 4') creates a condition of 'true' "
- 3682 print t10$;"if X = 4, or 'false' if X <> 4. In '2', a condition of 'true' "
- 3684 print t10$;"is created if there is ANYTHING in X and a condition of 'false' "
- 3690 PRINT T10$;"is created if X is 0. The '355' is a legitimate line number, "
- 3700 PRINT T10$;"since any number through 65529 is acceptable. In the case of 1, "
- 3710 PRINT T10$;"the computer will transfer control to line 355 only if 'X' is "
- 3720 PRINT T10$;"exactly 4; otherwise, it will ignore the instruction and continue "
- 3722 print t10$;"with the next one."
- 3730 PRINT : PRINT T10$;" Actually, after the word 'THEN' you can either put a "
- 3740 PRINT T10$;"line number or any valid basic statement. For example:";CRLF$
- 3750 PRINT TAB(20);"IF A < 0 THEN LET A = A + 1";CRLF$
- 3760 PRINT T10$;" In this case, if A is negative, the new value of A is one"
- 3770 PRINT T10$;"greater than the old value of A."
- 3780 GOSUB 37000 : GOSUB 37100
- 3790 PRINT T10$;"Let's play a matching game with the following:";CRLF$
- 3800 GOSUB 5000
- 3810 PRINT T10$;"The three symbols '=', '<', and '>', shown alone and in various"
- 3820 PRINT T10$;"combinations in the choices (1) through (9), give conditional"
- 3830 PRINT T10$;"control to the 'IF' statement. Six of the choices have meanings"
- 3840 PRINT T10$;"given by the letter-identified list (a) through (f). Now"
- 3850 PRINT T10$;"see if you can match the symbols with the meanings."
- 3860 PRINT CRLF$;FNCENTER$("press any key for the drill"); :
-
- FOR CT = 1 TO 27 :PRINT CHR$(8); : NEXT CT : GOSUB 40800
- 3870 GOSUB 37100 : GOSUB 5000
- 3880 PRINT T10$;" Decide what sequence of number choices agree with the letter"
- 3890 PRINT T10$;"sequence, and type those six numbers separated by commas (for"
- 3900 PRINT T10$;"instance, if you were to select the first 6 in order, you would"
- 3910 PRINT T10$;"type them as: 1,2,3,4,5,6)."
- 3920 PRINT CRLF$;ELR$;T10$;"What's your answer? ";
- 3930 LINE INPUT A$ :CVTSTR$ = A$ :GOSUB 40400 : A$ = CVTSTR$ 'INPUT "",A$, B$, C$, D$, E$, F$
- 3940 PRINT EES$;
- 3950 TST = INSTR(A$,"@") : IF TST > 0 THEN SYSTEM
- 3960 IF NOT A$ = "5,6,8,1,4,7" THEN 3990
- 3970 PRINT CRLF$;T10$;"Nice going - you got it completely right. So now remember that"
- 3980 print t10$; : GOTO 4070
- 3990 PRINT EES$;CRLF$;T10$;" Won't work. If you want me to tell you, type 'yes' - if you"
- 4000 PRINT T10$;"want to try again, type anything else.";
- 4010 GOSUB 40900 : G$ = CVTSTR$
- 4020 PRINT
- 4030 IF LEFT$(G$,1) = "Y" THEN 4060
- 4040 PRINT VT$;VT$;VT$;VT$;VT$;VT$;VT$;CR$;
- 4050 GOTO 3910
- 4060 PRINT VT$;VT$;VT$;ELR$;T10$;" Well, you should have had 5,6,8,1,4,7 in that order. "
- 4062 print t10$;"You see, ";
- 4070 PRINT "'=' means 'is equal to', '<>' means 'is not equal to', '<'"
- 4080 PRINT T10$;"means 'is less than', '>' means 'is greater than', '<=' means"
- 4090 PRINT T10$;"'is less than or equal to', and '>=' means 'is greater than or"
- 4100 PRINT T10$;"equal to'. The symbols not used above are invalid."
- 4110 GOSUB 37000 : GOSUB 37100 : PRINT FNPOSCUR$(8,1);
- 4120 PRINT T10$;" Now that you understand 'IF' and 'THEN', let's see how we can"
- 4130 PRINT T10$;"use them to control iterations. This will be an 'If' loop, and"
- 4140 PRINT T10$;"the computer will decide the number of times we go through it."
- 4150 PRINT T10$;"We'll take a look at an example of this and work out a usable"
- 4160 PRINT T10$;"solution, but first we'll need to call in (TUTR.08) from the menu.";CRLF$
- 4180 PRINT FNCENTER$("press any key for menu"); :
- 4190 FOR CT = 1 TO 22 : PRINT CHR$(8); : NEXT CT : GOSUB 40800
- 4200 GOTO 39999
-
-
- 5000 PRINT T15$;"(a) 'is equal to' (1) > (6) <>"
- 5010 PRINT T15$;"(b) 'is not equal to' (2) => (7) >="
- 5020 PRINT T15$;"(c) 'is less than' (3) >< (8) <"
- 5030 PRINT T15$;"(d) 'is greater than' (4) <= (9) =<"
- 5040 PRINT T15$;"(e) 'is less than or equal to' (5) ="
- 5050 PRINT T15$;"(f) 'is greater than or equal to'";CRLF$
- 5099 RETURN
-
-
- 5100 GOSUB 40200 : GOSUB 40300 : RETURN
- 37000 'press any key pause
- 37010 PRINT T10$;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 7");CRLF$
- 37199 RETURN
-
-
- 38000 ' converted for Non-linear Systems, Kaypro Educational Division
- 38010 ' by t.crew , Simple Software, San Diego CA
- 38020 ' has to be run with mentutr to get all variables
- 38030 ' tutor lesson 7 version 2.0 released to nls 1 aug 83
-
-
- 39999 RUN "MENU" 'end of overlay
-
-