home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a079 / 1.img / FPDG.LZH / VOL2NUM0 / CALC / CALC.APP (.txt) next >
Encoding:
MS Visual FoxPro App  |  1993-02-01  |  16.8 KB  |  333 lines

  1. TALKz
  2. COMPATIBLEz
  3. Scientific Calculator
  4. Memory
  5. @*HN   \<0
  6. @*HN   \<1
  7. @*HN   \<2
  8. @*HN   \<3
  9. @*HN   \<4
  10. @*HN   \<5
  11. @*HN   \<6
  12. @*HN   \<7
  13. @*HN   \<8
  14. @*HN   \<9
  15. @*HN   \<.
  16. @*HN   \<=
  17. @*HN   \<C
  18. @*HN  \<AC
  19. @*HN   \<+
  20. @*HN   \<-
  21. @*HN   \<*
  22. @*HN   \</
  23. @*HN   1/x
  24. @*HN   +/-
  25. @*HN X
  26. @*HN   MC
  27. @*HN   MR
  28. @*HN   M+
  29. @*HN   M-
  30. @*HN   Int
  31. @*HN   X!
  32. @*HN   Sin 
  33. @*HN   Cos 
  34. @*HN   Acos
  35. @*HN   Tan 
  36. @*HN   Atan
  37. @*HN   PI 
  38. @*HN  Log10
  39. log10
  40. @*HN   Exp 
  41. @*HN    ln 
  42. @*HN   Sqrt
  43. @*HN   Rand
  44. @*HN   \<Quit
  45. TALKSTAT
  46. COMPSTAT
  47. SNUMLOCK
  48. MEMORY
  49. RESULTS
  50. OLDOP
  51. DECIMAL
  52. SHOWCALC
  53. VNUMBER
  54. .VDECIMAL
  55. EQUALS
  56. VEQUAL
  57. CLEAR
  58. VCLEAR
  59. ACLEAR
  60. VACLEAR
  61. MINUS
  62. MULTIPLY
  63. DIVIDE
  64. INVERT
  65. VINVERT
  66. PLUSMINUS
  67. VREVERSE
  68. XASIN
  69. VXPOSE
  70. MPLUS
  71. VFUNC
  72. XFACTOR
  73. VFACT
  74. XACOS
  75. XATAN
  76. XLOG10
  77. XSQRT
  78. XRAND
  79. VRAND
  80. VQUIT
  81. Clear
  82. VACLEAR
  83. RESULTS
  84. OLDOP
  85. SHOWCALC
  86. DECIMAL
  87. SHOWCALC
  88. NUMBER
  89. DECIMAL
  90. SHOWCALC
  91. SHOWCALC
  92. DECIMAL
  93. RESULTS
  94. SHOWCALC
  95. Memory 
  96. Results
  97. MEMORY
  98. SHOWCALC
  99. MEMORY
  100. SHOWCALC
  101. MEMORY
  102. SHOWCALC
  103. SHOWCALC
  104. log10
  105. Zero accumulator is not allowed for log function
  106. (ACC)
  107. FUNCTION
  108. RESULTS
  109. VACLEAR
  110. SHOWCALC
  111. Results 
  112. CTION
  113. RESULTS
  114. OLDOP
  115. SHOWCALC
  116. VACLEAR
  117. Error!
  118. MESSAGE
  119. RESULTS
  120. VACLEAR
  121. SHOWCALC
  122. SHOWCALC
  123. OLDOP
  124. SHOWCALC
  125. OLDOP
  126. SHOWCALC
  127.  Results 
  128. RESULTS
  129. OLDOP
  130. VACLEAR
  131. SHOWCALC
  132. @Z 99999999999.9999
  133. @Z 99999999999.9999
  134. @Z 99999999999.9999
  135. COMMENT
  136. RESULTS
  137. MEMORY
  138. VCLEAR
  139. VACLEAR
  140. VNUMBER
  141. VDECIMAL
  142. VXPOSE
  143. VREVERSE
  144. VQUIT
  145. VFUNC
  146. VFACT
  147. VRAND
  148. VINVERT
  149. VEQUAL
  150. SHOWCALC
  151. TALKz
  152. COMPATIBLEz
  153. Scientific Calculator
  154. Memory
  155. @*HN   \<0
  156. @*HN   \<1
  157. @*HN   \<2
  158. @*HN   \<3
  159. @*HN   \<4
  160. @*HN   \<5
  161. @*HN   \<6
  162. @*HN   \<7
  163. @*HN   \<8
  164. @*HN   \<9
  165. @*HN   \<.
  166. @*HN   \<=
  167. @*HN   \<C
  168. @*HN  \<AC
  169. @*HN   \<+
  170. @*HN   \<-
  171. @*HN   \<*
  172. @*HN   \</
  173. @*HN   1/x
  174. @*HN   +/-
  175. @*HN X
  176. @*HN   MC
  177. @*HN   MR
  178. @*HN   M+
  179. @*HN   M-
  180. @*HN   Int
  181. @*HN   X!
  182. @*HN   Sin 
  183. @*HN   Cos 
  184. @*HN   Acos
  185. @*HN   Tan 
  186. @*HN   Atan
  187. @*HN   PI 
  188. @*HN  Log10
  189. log10
  190. @*HN   Exp 
  191. @*HN    ln 
  192. @*HN   Sqrt
  193. @*HN   Rand
  194. @*HN   \<Quit
  195. TALKSTAT
  196. COMPSTAT
  197. ESNUMLOCK
  198. CCALC
  199.  ResulMEMORY
  200. ARESULTS
  201. FOLDOP
  202. DECIMAL
  203. SHOWCALC
  204. VNUMBER
  205. OLDOP
  206. VDECIMAL
  207. 9EQUALS
  208. 9.9VEQUAL
  209. CLEAR
  210. VCLEAR
  211. ACLEAR
  212. VACLEAR
  213. 99PLUS
  214. MINUS
  215. MULTIPLY
  216. DIVIDE
  217. @ZINVERT
  218. 999VINVERT
  219. PLUSMINUS
  220. VREVERSE
  221. XASIN
  222. VXPOSE
  223. sREVMR
  224. rMEMMPLUS
  225. VCLEVMEM
  226. VFUNC
  227. MBERXFACTOR
  228. DEVFACT
  229. XACOS
  230. VMXTAN
  231. XATAN
  232. REVEVPI
  233. VXLOG10
  234. 1XEXP
  235. XSQRT
  236. XRAND
  237. VRAND
  238. VPIVQUIT
  239. Clear
  240. VACLEAR
  241. RESULTS
  242. EOLDOP
  243. CSHOWCALC
  244. EDECIMAL
  245. CSHOWCALC
  246. NUMBER
  247. DECIMAL
  248. CSHOWCALC
  249. SHOWCALC
  250. DECIMAL
  251. RESULTS
  252. CSHOWCALC
  253. Memory 
  254. Results
  255. MEMORY
  256. ESHOWCALC
  257. MEMORY
  258. ESHOWCALC
  259. MEMORY
  260. SHOWCALC
  261. SHOWCALC
  262. (ACC)
  263. FUNCTION
  264. RESULTS
  265. EVACLEAR
  266. CSHOWCALC
  267. Results 
  268. CTION
  269. RESULTS
  270. EOLDOP
  271. CSHOWCALC
  272. VACLEAR
  273. Error!
  274. MESSAGE
  275. ERESULTS
  276. CTEMP
  277. VACLEAR
  278. lSHOWCALC
  279. SHOWCALC
  280. EOLDOP
  281. SHOWCALC
  282. EOLDOP
  283. SHOWCALC
  284.  Results 
  285. RESULTS
  286. OLDOP
  287. EVACLEAR
  288. CSHOWCALC
  289. @Z 99999999999.9999
  290. @Z 99999999999.9999
  291. @Z 99999999999.9999
  292. COMMENT
  293. ERESULTS
  294. CMEMORY
  295. VCLEAR
  296. VACLEAR
  297. VNUMBER
  298. VDECIMAL
  299. VXPOSE
  300. VREVERSE
  301. VQUIT
  302. VFUNC
  303. VFACT
  304. VRAND
  305.  Tan 
  306. VINVERT
  307. VEQUAL
  308. SHOWCALC
  309. 0123456789ABCDEF
  310. STRING
  311.    NUMBER
  312.         C
  313.         K
  314. The CALC.PRG program simulates a simple scientific calculator. It illustrates the use of the built-in FoxPro 2.5 functions. Figure 5.2 in the book shows the calculator. You can use either the mouse or the keyboard to enter numbers and choose operations.
  315. The FoxPro Screen Designer, MODIFY SCREEN created the screen for CALC.PRG. The Scientific Calculator displays in a window and uses "push buttons" for the numbers and functions. CALC.PRG displays the push buttons using a special form of the @ ... GET command, which is discussed in Chapter 16, "Menus, Popup Menus, and Dialog Boxes."
  316. Here is what CALC.PRG does. First, CALC.PRG saves some environmental parameters, defines the window, initializes some constants, and displays the screen image. It then executes the READ CYCLE command until you press the Quit push button to exit the program. Whenever you "push" a push button to enter a number or operation, a corresponding @ ... GET command VALID clause executes. The VALID clause consists of a call to a user-defined function (UDF). For example, when you press the number 1, in the following statement
  317. @ 9,5 GET i1 ;
  318.      PICTURE "@*HN   \<1" ;
  319.      SIZE 1,5,1 ;
  320.      DEFAULT 1  ;
  321.      VALID VNUMBER( 1 )
  322. the program calls the VNUMBER() UDF to process the number 1. The two characters (\<) preceding the 1 in the PICTURE clause make the number 1 a hot key. When you press a hot key, the push button activates. Of course, you can also activate the push button with a mouse click or by pressing Enter. The numlock() function turns on the Num Lock mode so that the user can use the number and +, -, *, and / keys on the numeric keypad. The Num Lock status returns to its original state when the program exits.
  323. VNUMBER() emulates the way you enter a number in a calculator. The number is entered from right to left. Another UDF, VOP(), is called when you push an operator button (+, -, *, or /). It creates in a character string containing an expression that consists of the previously entered operator and operands. It then calls the EVALUATE() function. EVALUATE evaluates the expression and returns the answer. When you push a function button (sin, cos, rand, and so forth), the VFUNC() UDF is called, which uses the same technique used by the VOP() UDF to calculate the results. The ShowCalc procedure displays the results.
  324. CALC.PRG
  325. h:\foxprow\
  326. CALC.FXP
  327. e:\jebwin\calc\calc1.prg
  328. CALC1.FXP
  329. e:\jebwin\calc\hex.prg
  330. HEX.FXP
  331. f:\jebwin\vol2num0\calc\
  332. CALC.ART
  333.