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

  1. 3000    ' tutor 9
  2. 3010    GOSUB 37100
  3. 3020    T5$ = SPACE$(5) : T10$ = SPACE$(10) : T15$ = SPACE$(15) :VT$ = CHR$(11)
  4. 3040    PRINT FNCENTER$("Welcome to Lesson 9.");CRLF$
  5. 3050    PRINT T10$;"   This lesson will cover 'functions.' -- What are functions?"
  6. 3060    PRINT T10$;"Well we have used one in a previous lesson ...";CRLF$
  7. 3070    PRINT T10$;"   As an example: 'SQR' always means 'find the square root'. We"
  8. 3080    PRINT T10$;"refer to such an operation as a 'function'."
  9. 3090    PRINT
  10. 3100    PRINT T10$;"   There are many 'standard' or predefined functions, which have a"
  11. 3110    PRINT T10$;"set meaning. 'SQR' is one; 'LOG' is another. This one refers to"
  12. 3120    PRINT T10$;"numbers found in a table of logarithms."
  13. 3130    PRINT T10$;"Here are some examples of functions:";CRLF$
  14. 3140    PRINT T10$;"     (1) TAN     (2) TRA     (3) ADV     (4) ABS"
  15. 3150    PRINT T10$;"     (5) COS     (6) PAC     (7) MON     (8) SIN"
  16. 3160    PRINT
  17. 3170    PRINT T10$;"   Four of them are standard functions; four are not. Please"
  18. 3180    PRINT T10$;"select one that is a function: ";
  19. 3190    GOSUB 40900 : A$ = CVTSTR$
  20. 3200    PRINT
  21. 3210    IF A$ = "1" OR (LEN(A$) > 1 AND LEFT$(A$,2) = "TA") THEN 3270
  22. 3220    IF A$ = "4" OR (LEN(A$) > 1 AND LEFT$(A$,2) = "AB") THEN 3270
  23. 3230    IF A$ = "5" OR (LEN(A$) > 1 AND LEFT$(A$,2) = "CO") THEN 3270
  24. 3240    IF A$ = "8" OR (LEN(A$) > 1 AND LEFT$(A$,2) = "SI")THEN 3270
  25. 3250    PRINT T10$;"You didn't pick one of them that time. Try once more.";
  26.         vt$;VT$;CR$;
  27. 3260    GOTO 3180
  28. 3270    GOSUB 37100
  29. 3280    PRINT T10$;"     (1) TAN     (2) TRA     (3) ADV     (4) ABS"
  30. 3290    PRINT T10$;"     (5) COS     (6) PAC     (7) MON     (8) SIN"
  31. 3300    PRINT
  32. 3310    PRINT T10$;"   That is one of them. Three are trigonometric functions: 'TAN'"
  33. 3320    PRINT T10$;"means 'tangent', 'SIN' means 'sine', and 'COS' means 'cosine'."
  34. 3330    PRINT T10$;"one ('ABS') means to use the positive value for whatever is"
  35. 3340    PRINT T10$;"being considered. This is the 'absolute value' - often required."
  36. 3350    PRINT
  37. 3360    PRINT T10$;"   Each function is followed by an expression in parentheses, known"
  38. 3370    PRINT T10$;"as the 'argument'; it is what the function operates on. Example:"
  39. 3380    PRINT T10$;"'ABS(Y)' means 'Y' is to be made positive regardless of sign, or"
  40. 3390    PRINT T10$;"its 'absolute value' is to be used. Here 'Y' is the argument."
  41. 3400    GOSUB 37000 : GOSUB 37100
  42. 3410    PRINT T10$;"   We have mentioned 4 standard functions; basic has others"
  43. 3420    PRINT T10$;"available to the user, among which are:"
  44. 3430    PRINT
  45. 3440    PRINT T10$;"  (1) ATN(U)    (2) EXP(U)    (3) INT(U)    (4) RND(U)"
  46. 3450    PRINT T10$;"  (5) FIX(U)    (6) FRE(U)    (7) SGN(U)    (8) RND"
  47. 3460    PRINT
  48. 3470    PRINT T10$;"   Here the 'U' simply represents the argument. One of the above is"
  49. 3480    PRINT T10$;"for taking only the whole number part of a decimal number. Which"
  50. 3490    PRINT T10$;"do you think this one might be? ";
  51. 3500    GOSUB 40900 : W$ = CVTSTR$
  52. 3510    PRINT
  53. 3520    IF W$ = "3" OR (LEN(W$) > 1 AND LEFT$(W$,2)= "IN") OR 
  54.       W$ = "5" OR (LEN(W$) > 1 AND LEFT$(W$,2) = "FI") THEN 3550
  55. 3530    PRINT T10$;"   No, it could be 'INT' or 'FIX'.  'INT' stands for 'integer'"
  56. 3540    GOTO 3560
  57. 3550    PRINT T10$;"That's right!  It could be 'INT' or 'FIX'. 'INT' stands for 'integer'"
  58. 3560    PRINT T10$;"which returns the largest integer in U.  'FIX' returns the integer"
  59. 3570    PRINT T10$;"part of U only.  For example:"
  60. 3580    PRINT T10$;"       INT(-2.7) = -3"
  61. 3590    PRINT T10$;"       FIX(-2.7) = -2"
  62. 3600    PRINT T10$;"       INT(34.8) = 34"
  63. 3610    GOSUB 37000
  64. 3620    PRINT FNPOSCUR$(12,1);EES$;
  65. 3630    PRINT vt$;ELR$;T10$;"   Which do you suppose is used to generate random numbers? ";
  66. 3640    GOSUB 40900 : R$ = CVTSTR$
  67. 3650    PRINT
  68. 3660    IF R$ = "4" OR R$ = "8" OR (LEN(R$) > 1 AND LEFT$(R$,2) = "RN") THEN 3690
  69. 3670    PRINT T10$;"   You need another guess. LOOK at the letter combinations.";
  70.         VT$;CR$;
  71. 3680    GOTO 3630
  72. 3690    PRINT T10$;"   Good! Also, 'ATN' means 'arctangent', a trigonometric function,"
  73. 3700    PRINT T10$;"and 'EXP' means 'exponential', which is the antilog function."
  74. 3710    PRINT T10$;"If you use a trigonometric function, please note:  they involve"
  75. 3720    PRINT T10$;"RADIANS, not degrees.  Also, the 'LOG' function is based on"
  76. 3730    PRINT T10$;"natural logarithms. The 'SGN' function returns the integer 1"
  77. 3740    PRINT T10$;"preceeded by the sign of the argument.  For example:"
  78. 3750    PRINT : PRINT T15$;"  SGN(-4.2) = -1" : PRINT T15$;"  SGN(273.51) = 1" : PRINT
  79. 3760    GOSUB 37000 : PRINT FNPOSCUR$(10,1);EES$;
  80. 3770    PRINT T10$;"   Note that 'RND' is equivalent to 'RND(U)' -- U > 0; each"
  81. 3780    PRINT T10$;"returns a new random number. 'RND(U)' -- U < 0 seeds a new sequence."
  82. 3790    PRINT T10$;"'RND(U)' -- U = 0 returns the previously generated number."
  83. 3800    GOSUB 37000 : GOSUB 37100
  84. 3810    PRINT T10$;"  TUTR.11 provides more discussion about standard and"
  85. 3820    PRINT T10$;"'trig' functions. TUTR.12 concerns non-standard functions."
  86. 3830    PRINT : PRINT FNCENTER$("press any key for menu");
  87. 3840    FOR CT = 1 TO 22 : PRINT CHR$(8); : NEXT CT : GOSUB 40800
  88. 3850    GOTO 39999
  89.  
  90. 37000    'press any key pause
  91. 37010    PRINT T10$;CRLF$;CRLF$;FNCENTER$("press any key to continue");
  92. 37020    FOR CT= 1 TO 25 : PRINT CHR$(8); : NEXT CT
  93. 37030    GOSUB 40800
  94. 37099    RETURN
  95.  
  96. 37100    ' heading
  97. 37110    PRINT CLS$;FNPOSCUR$(4,1);FNCENTER$("Tutor -- Lesson 9");CRLF$
  98. 37199    RETURN
  99.  
  100. 38000    ' converted for Non-linear Systems, Kaypro Educational Division
  101. 38010    ' by t.crew , Simple Software, San Diego CA
  102. 38020    ' has to be run with mentutr to get all variables
  103. 38030    ' tutor lesson 9 version 2.0  released to nls 1 aug 83
  104.  
  105. 39999    RUN "MENU" 'end of overlay
  106.  
  107.