home *** CD-ROM | disk | FTP | other *** search
- 3000 ' tutor 14
- 3010 GOSUB 37100
- 3020 T5$ = SPACE$(5) : T10$ = SPACE$(10) : T15$ = SPACE$(15) :VT$ = CHR$(11)
- 3030 PRINT T10$;" Glad to see you again. I hope you have been practicing"
- 3040 PRINT T10$;"the instructions as you learn them. Learning how to program"
- 3050 PRINT T10$;"well is like mastering a foreign language. Only repeated"
- 3060 PRINT T10$;"exercise can make you proficient."
- 3070 W = 0
- 3080 PRINT
- 3090 PRINT T10$;" Before we undertake any new work, let's first review some"
- 3100 PRINT T10$;"of the basic statements to which you have previously been intro-"
- 3110 PRINT T10$;"duced."
- 3120 GOSUB 37000 : GOSUB 37100
- 3130 PRINT T10$;" An arithmetic function may be used to avoid writing an "
- 3140 PRINT T10$;"identical statement repetitiously. For example, your"
- 3150 PRINT T10$;"program may require the following statements;"
- 3160 PRINT
- 3170 PRINT "120 let u=(c1*x^2 + c2*x + c3) * sin(x)"
- 3180 PRINT " ."
- 3190 PRINT " ."
- 3200 PRINT "280 let v=(c1*y^2 + c2*y + c3)^2"
- 3210 PRINT " ."
- 3220 PRINT " ."
- 3230 PRINT "370 let w=c1*z^2 + c2*z + c3"
- 3240 PRINT " ."
- 3250 PRINT T10$;" An easier way to do this would be to use the function state-"
- 3260 PRINT T10$;"ment. Which of the following statements would be involved? "
- 3270 PRINT
- 3280 PRINT T10$;" (1) go to (2) rem (3) def (4) if...then..."
- 3290 PRINT CRLF$;FNCENTER$("Your choice? ");
- 3300 GOSUB 40900 : Z$ = CVTSTR$
- 3310 PRINT
- 3320 IF Z$ = "3" OR Z$ = "DEF" THEN 3370
- 3330 W = W + 1
- 3340 PRINT T10$;" You're putting me on. A function definition must be preceded by the"
- 3350 PRINT T10$;"symbol 'def', an abbreviation of the word 'define'."
- 3360 GOSUB 37000 : GOSUB 37100 : GOTO 3380
- 3370 PRINT T10$;"RIGHT!" : GOTO 3360
- 3380 PRINT T10$;" For example, you could write:"
- 3390 GOSUB 5000
- 3400 PRINT T10$;" Remember - a function, like the parents of a teenager,"
- 3410 PRINT T10$;"always requires an argument. In the defining statement (90)"
- 3420 PRINT T10$;"the argument is q. When used in the body of the program, the"
- 3430 PRINT T10$;"called for argument replaces the 'dummy' argument q."
- 3440 GOSUB 37000 : GOSUB 37100 : GOSUB 5000
- 3450 PRINT T10$;" For example, if c1 = 1 , c2 = 3, and c3 = 6,"
- 3460 PRINT T10$;"what is the value of fnr(3)? ";
- 3470 GOSUB 40900 : Z$ = CVTSTR$
- 3480 PRINT
- 3490 IF Z$ = "24" THEN 3530
- 3500 W = W + 1
- 3510 PRINT T10$;"No. Would you believe 24? (1*9 + 3*3 + 6)"
- 3520 GOTO 3540
- 3530 PRINT T10$;"Very good. "
- 3540 PRINT
- 3550 PRINT T10$;" Did you understand the difference between a function and a"
- 3560 PRINT T10$;"subroutine? A subroutine is used to avoid writing identical"
- 3570 PRINT T10$;"groups of instructions, whereas a function treats only a single"
- 3580 PRINT T10$;"line."
- 3590 GOSUB 37000 : GOSUB 37100
- 3600 PRINT T15$;"(1) goto (2) return (3) next (4) gosub (5) end";CRLF$
- 3610 PRINT T10$;" Which two of the above symbols do you associate with the"
- 3620 PRINT T10$;"use of a subroutine (1st choice, 2nd choice)? ";
- 3630 GOSUB 40900 : GOSUB 40400 : Z$ = CVTSTR$
- 3640 PRINT CRLF$;CRLF$
- 3650 IF Z$ = "2,4" OR Z$ = "4,2" OR Z$ = "RETURN,GOSUB" OR
- Z$ = "GOSUB,RETURN" THEN 3720
- 3660 W = W + 1
- 3670 IF W = 1 THEN 3700
- 3680 PRINT T10$;"X@)@zG!@;=8&C>:@< (the computer equivalent of tsk, tsk)"
- 3690 GOTO 3730
- 3700 PRINT T10$;"Since this your first mistake, I won't reprimand you."
- 3710 GOTO 3730
- 3720 PRINT T10$;"Right."
- 3730 PRINT
- 3740 PRINT T10$;" GOSUB xxx is an abbreviated way of indicating 'go to the"
- 3750 PRINT T10$;"subroutine which starts at line number xxx'. The 'RETURN'"
- 3760 PRINT T10$;"statement, which should be the last statement in the subroutine,"
- 3770 PRINT T10$;"is a signal that when the subroutine has been executed, control"
- 3780 PRINT T10$;"will be sent back to the instruction following the gosub."
- 3790 PRINT
- 3800 PRINT T10$;" The function and subroutine calls are very powerful instruc-"
- 3810 PRINT T10$;"tions and should be mastered."
- 3820 GOSUB 37000 : GOSUB 37100
- 3830 IF W < 2 THEN 3860
- 3840 PRINT T10$;" Since you missed "; W; "of the above questions, perhaps"
- 3850 PRINT T10$;"you should review 'TUTR09' when you are through here."
- 3860 PRINT
- 3870 PRINT
- 3880 PRINT T10$;" You probably noticed that blanks were inserted between some"
- 3890 PRINT T10$;"of the words used in the statements above to improve legibility."
- 3900 PRINT T10$;"Blanks may be used almost at will in all basic statements without"
- 3910 PRINT T10$;"affecting the intent of the statement in any way. But there"
- 3920 PRINT T10$;"are exceptions. Blanks(spaces) cannot be embedded within command"
- 3930 PRINT T10$;"words, standard function names, operator names or your own"
- 3940 PRINT T10$;"variables. ( CORRECT$ not COR RECT $ )."
- 3950 PRINT T10$;"(i.e. ";CHR$(34);">=";CHR$(34);" not ";CHR$(34);"> =";CHR$(34);")"
- 3960 GOSUB 37000 : GOSUB 37100
- 3970 PRINT T10$;" In printing alphabetic messages, a blank is treated as"
- 3980 PRINT T10$;"any other character. This allows you to space the message"
- 3990 PRINT T10$;"as you like. (Beware of 'TABS' (ctrl I) in PRINT"
- 4000 PRINT T10$;"statements!!) Spaces (blanks) should be used to improve"
- 4010 PRINT T10$;"the legibilty of your program."
- 4020 PRINT
- 4030 PRINT T10$;" Remember to use the 'REM'(') or remark statement to make"
- 4040 PRINT T10$;"notes in your programs. The slight cost in disk and memory"
- 4050 PRINT T10$;"space is rewarded whenever you or someone else needs to"
- 4060 PRINT T10$;"modify your work.";CRLF$
- 4070 PRINT T10$;" See you in lesson 15.";CRLF$;CRLF$
- 4080 PRINT FNCENTER$("press any key for menu");
- 4090 FOR CT = 1 TO 22 : PRINT CHR$(8); : NEXT CT : GOSUB 40800
- 4100 GOTO 39999
-
- 5000 PRINT
- 5020 PRINT "90 def fnr(q) = c1 * q^2 + c2 * q + c3"
- 5030 PRINT " ."
- 5040 PRINT " ."
- 5050 PRINT "120 let u = fnr(x) * sin(x)"
- 5060 PRINT " ."
- 5070 PRINT " ."
- 5080 PRINT "280 let v = fnr(y)^2"
- 5090 PRINT " ."
- 5100 PRINT " ."
- 5110 PRINT "370 let w = fnr(z)"
- 5120 PRINT
- 5199 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 14");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 14 version 2.0 released to nls 1 aug 83
-
- 39999 RUN "MENU" 'end of overlay
-