home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DIVERSEN / TIPI2A / HELPMATH.TPI < prev    next >
Text File  |  1994-09-13  |  3KB  |  163 lines

  1. define menu
  2. # ( -- choice)
  3. # ( valid$ -- )
  4. # Returns the chosen key or 0 if the user escapes from this menu
  5.  0 cursor
  6.  ucase$
  7.  27 chr$ swap$ +$
  8.  begin
  9.   inkey$ ucase$ # valid$ key$
  10.   len instr *
  11.   dup
  12.   if dup drop$ endif drop$
  13.  until
  14.  1 -
  15.  1 cursor
  16. enddef
  17.  
  18. define wait
  19.  begin key until cls
  20. enddef
  21.  
  22.  begin cls
  23. |
  24. |   ╔═══════════════════════════════════╗
  25. |   ║ M A T H   I N S T R U C T I O N S ║
  26. |   ╠═════════╦═══════════════╦═════════╣
  27. |   ║         ║               ║         ║
  28. |   ║ [A] ABS ║  [*] *        ║ [<] <   ║
  29. |   ║         ║               ║         ║
  30. |   ║ [B] MAX ║  [+] +        ║ [=] =   ║
  31. |   ║         ║               ║         ║
  32. |   ║ [C] MIN ║  [-] -        ║ [>] >   ║
  33. |   ║         ║               ║         ║
  34. |   ║ [D] MOD ║  [/] /        ║         ║
  35. |   ╚═════════╩═══════════════╩═════════╝
  36.  "abcd*+-/<=>" menu dup cls
  37.  case 0 of endof
  38.       1 of
  39. |
  40. |   ABS
  41. |   
  42. |   Data Stack:          n -- N
  43. |   String Stack:          --
  44. |   
  45. |   Replaces the top value on the data stack with its
  46. |   absolute value.
  47. |
  48.         wait
  49.         endof
  50.       2 of
  51. |
  52. |   MAX
  53. |   
  54. |   Data Stack:         A B -- MAX
  55. |   String Stack:           --
  56. |   
  57. |   Places the greater of A or B on the data stack.
  58. |
  59.         wait
  60.         endof
  61.       3 of
  62. |
  63. |   MIN
  64. |   
  65. |   Data Stack:         A B -- MIN
  66. |   String Stack:           --
  67. |   
  68. |   Places the lesser of A or B on the data stack.
  69. |
  70.         wait
  71.         endof
  72.       4 of
  73. |
  74. |   MOD
  75. |   
  76. |   Data Stack:         A B -- C
  77. |   String Stack:           --
  78. |   
  79. |   Returns A modulo B.
  80. |
  81.         wait
  82.         endof
  83.       5 of
  84. |
  85. |     *
  86. |
  87. |   Data Stack:         A B -- C
  88. |   String Stack:           --
  89. |   
  90. |   Multiplies A times B.
  91. |
  92.         wait
  93.         endof
  94.       6 of
  95. |
  96. |     +
  97. |   
  98. |   Data Stack:         A B -- C
  99. |   String Stack:           --
  100. |   
  101. |   Adds A and B.
  102. |
  103.         wait
  104.         endof
  105.       7 of
  106. |
  107. |     -
  108. |   
  109. |   Data Stack:         A B -- C
  110. |   String Stack:           --
  111. |
  112. |   Subtracts B from A.
  113. |
  114.         wait
  115.         endof
  116.       8 of
  117. |
  118. |     /
  119. |   
  120. |   Data Stack:         A B -- C
  121. |   String Stack:           --
  122. |   
  123. |   Divides A by B.
  124. |
  125.         wait
  126.         endof
  127.       9 of
  128. |
  129. |     <
  130. |   
  131. |   Data Stack:         A B -- C
  132. |   String Stack:           --
  133. |   
  134. |    C is TRUE if A is less than B, FALSE otherwise.
  135. |
  136.         wait
  137.         endof
  138.      10 of
  139. |
  140. |     =
  141. |
  142. |   Data Stack:          A B -- C
  143. |   String Stack:            --
  144. |   
  145. |   C is TRUE if A equals B, FALSE otherwise.
  146. |
  147.         wait
  148.         endof
  149.      11 of
  150. |
  151. |     >
  152. |   
  153. |   Data Stack:           A B -- C
  154. |   String Stack:             --
  155. |   
  156. |   C is TRUE if A is greater than B, FALSE
  157. |   otherwise.
  158. |
  159.         wait
  160.         endof
  161.   endcase
  162.  not until
  163.