home *** CD-ROM | disk | FTP | other *** search
/ Lion Share / lionsharecd.iso / dos_misc / qcalc113.zip / WELCOME.QC < prev   
Text File  |  1991-10-30  |  6KB  |  209 lines

  1.  
  2. ;
  3. ; WELCOME.QC -- An Introduction to the Fundamentals of QCALC
  4. ;
  5.  
  6. ;
  7. ; To run this script, type:     QCALC @WELCOME
  8. ;
  9.  
  10. #
  11. #Welcome to QCALC!  This script file will guide you through the
  12. #fundamentals of QCALC.  At anytime you wish to abort this script,
  13. #hit ESCAPE.
  14. #
  15. #This tutorial will pause frequently to wait for you to finish reading
  16. #the information it is telling you -- when you are finished waiting, hit
  17. #any key (the spacebar, for instance).
  18. #
  19. #In places that you see "<- YOU TYPE" on the right side of a line, that
  20. #line is an example of what you can type on a command line on your own.
  21. #
  22. #Ready to Start?  (Hit a key!)
  23.  
  24. ~   ; Pause
  25.  
  26. #
  27. #
  28. #                            What is QCALC?
  29. #
  30. #
  31. #QCALC is a command line calculator.  That is, you tell it information
  32. #by putting it on the command line.  For example, let's say you want to
  33. #add a few numbers (ten, twenty, thirty, and forty) together.  This is
  34. #how to tell QCALC to add some numbers:
  35. #
  36. #QCALC 10+20+30+40                                      <- YOU TYPE
  37. #
  38. #QCALC will add the four numbers together, and give you the following
  39. #result:  (Hit a key when ready.)
  40.  
  41. ~
  42.  
  43. #
  44. 10+20+30+40
  45. #
  46. #And there's your answer.  QCALC can calculate many different kinds
  47. #of expressions.  All you have to do is, at the DOS prompt, type
  48. #the program name (QCALC) a space, and then your expression.  Hit
  49. #enter, and voila, your answer.
  50. #
  51. #Let's take a look at the different kinds of operators one can use
  52. #in a QCALC expression.                                (Hit a key)
  53.  
  54. ~
  55. #
  56. #   Addition:
  57. #QCALC 3+2                                              <- YOU TYPE
  58. 3+2
  59. #
  60. #   Subtraction:
  61. #QCALC 3-2                                              <- YOU TYPE
  62. 3-2
  63. #
  64. #   Multiplication:
  65. #QCALC 3*2                                              <- YOU TYPE
  66. 3*2
  67. #
  68. #   Division:
  69. #QCALC 3/2                                              <- YOU TYPE
  70. 3/2
  71. #
  72. #   Modulus:
  73. #QCALC 3%2                                              <- YOU TYPE
  74. 3%2
  75. #
  76. #   Power:
  77. #QCALC 3^2                                              <- YOU TYPE
  78. 3^2
  79.  
  80. ~
  81.  
  82. #
  83. #You can have more than one expression on a command line, just by
  84. #separating them with a space.
  85. #
  86. #QCALC 3+2 3-2 3*2 3/2 3%2 3^2                          <- YOU TYPE
  87. #
  88. 3+2 3-2 3*2 3/2 3%2 3^2
  89.  
  90. ~
  91.  
  92. #
  93. #Operators have different "precedences."  That is, the multiplication
  94. #operator (*) has a higher precedence than the addition operator (+)
  95. #-- it is evaluated first.  Consider the following expression:
  96. #
  97. #QCALC 2+3*4                                            <- YOU TYPE
  98. #
  99. #What do you think the answer will be?  2+3 is 5, and 5*4 is 20.
  100. #However, take a look at QCALC's answer:
  101. #
  102.  
  103. ~
  104.  
  105. 2+3*4
  106. #
  107. #The answer is not 20, because multiplication is evaluated before
  108. #addition.  3*4 is evaluated first (to 12), and then 2 is added to it.
  109. #
  110. #(Read the section of the QCALC.DOC manual "Precedence and Operators"
  111. #for more information.)
  112. #
  113. #So, what does one do when one wants to ADD before MULTIPLYING?  Use
  114. #parethenses.
  115. #
  116. #QCALC (2+3)*4                                          <- YOU TYPE
  117. #
  118.  
  119. ~
  120.  
  121. (2+3)*4
  122. #
  123. #The parenthesis have the highest precedence, and override all others.
  124. #This forces QCALC to evalute the addition operator before the
  125. #multiplication operator, and thus produces the answer 20.
  126. #
  127. #Now we can get into the fun stuff:  Variables.  You can take the answer
  128. #of an expression, and put it "aside" for later use.  That is, you
  129. #can use it later on the command line.  Consider the following:
  130. #
  131. #QCALC 3*(2^8) 4*(2^8) 5*(2^8)                          <- YOU TYPE
  132. #
  133. #What a pain to retype (2^8).  Using variables, you can do this:
  134. #
  135. #QCALC myvar:2^8 3*myvar 4*myvar 5*myvar                <- YOU TYPE
  136. #
  137.  
  138. ~
  139.  
  140. myvar:2^8 3*myvar 4*myvar 5*myvar
  141. #
  142. #This assigns the result of the expression "2^8" to a variable named
  143. #"myvar", and reuses myvar several times in the next expressions.
  144. #The greatness of variables comes through when you use "on the fly"
  145. #variables.
  146. #
  147. #QCALC !myvar 3*myvar 4*myvar 5*myvar                   <- YOU TYPE
  148. #
  149. #               Type in a number (or valid expression):
  150. !myvar
  151. #
  152. #Now, we can the result of the expression you entered in our
  153. #following expressions.  Watch this again:
  154. #
  155.  
  156. ~
  157.  
  158. 3*myvar 4*myvar 5*myvar
  159. #
  160. #Variables can make things easier.  A few variables are already defined
  161. #by QCALC.  (For example, "pi".)  Variables can be redefined later on
  162. #the command line.
  163. #
  164. #The last fundamental for QCALC are functions.  QCALC has over 45
  165. #mathmatical functions for you to use.  Let's examine a few.
  166. #First, let's take a look at "min".  MIN takes two parameters, and
  167. #returns the smaller of the two.  Watch:
  168. #
  169. #QCALC min(5*5,1e+2)                                    <- YOU TYPE
  170. #
  171.  
  172. ~
  173.  
  174. min(5*5,1e+2)
  175. #
  176. #Here's MAX, which reports the largest of its two parameters:
  177. #
  178. #QCALC max(5*5,1e+2)                                    <- YOU TYPE
  179. #
  180.  
  181. ~
  182.  
  183. max(5*5,1e+2)
  184. #
  185. #For list of QCALC's functions, you can use QCALC's "/L" switch:
  186. #
  187. #QCALC /L                                               <- YOU TYPE
  188. #
  189. #QCALC supports most basic math functions.  For a better description
  190. #of functions, read QCALC.DOC's section on "Functions".
  191. ~
  192. #
  193. #That ends our Getting Started tour of QCALC.  You were taught by
  194. #a script file, which (as you saw with the !myvar example) can be
  195. #helpful as an interactive mathematical tool, especially when the
  196. #variables are dynamic and the model is (more or less) static.
  197. #QCALC can do a lot more than you've seen.
  198. #
  199. #Take a look at the other QCALC scripts (they all end with a .QC
  200. #extension) and read the manual (QCALC.DOC) for more help.  Also,
  201. #experiment with the many switches and options QCALC offers.
  202. ~
  203. #
  204. #This tutorial was thrown together at the last moment by the author.
  205. #If you can design better script files/tutorials, I would be happy
  206. #to include them in QCALC's next release.
  207. #
  208. #Enjoy QCALC!
  209.