home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DIVERSEN / TIPI2A / HELPSTAK.TPI < prev    next >
Text File  |  1994-09-14  |  4KB  |  227 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. |   ║ S T A C K    I N S T R U C T I O N S ║
  26. |   ╠═════════════╦═══════════╦════════════╣
  27. |   ║             ║           ║            ║
  28. |   ║ [A] DEPTH   ║ [G] OVER  ║ [M] ROT    ║
  29. |   ║             ║           ║            ║
  30. |   ║ [B] DEPTH$  ║ [H] OVER$ ║ [N] ROT$   ║
  31. |   ║             ║           ║            ║
  32. |   ║ [C] DROP    ║ [I] PICK  ║ [O] SWAP   ║
  33. |   ║             ║           ║            ║
  34. |   ║ [D] DROP$   ║ [J] PICK$ ║ [P] SWAP$  ║
  35. |   ║             ║           ║            ║
  36. |   ║ [E] DUP     ║ [K] POP   ║            ║
  37. |   ║             ║           ║            ║
  38. |   ║ [F] DUP$    ║ [L] PUSH  ║            ║
  39. |   ╚═════════════╩═══════════╩════════════╝
  40.  "abcdefghijklmnop" menu dup cls
  41.  case 0 of endof
  42.       1 of
  43. |
  44. |   DEPTH
  45. |   
  46. |   Data Stack:             -- N
  47. |   String Stack:           --
  48. |   
  49. |   Places N on the data stack, where N is the
  50. |   depth of the data stack.
  51. |
  52.         wait
  53.         endof
  54.       2 of
  55. |
  56. |   DEPTH$
  57. |   
  58. |   Data Stack:             -- N
  59. |   String Stack:           -- 
  60. |   
  61. |   Places N on the data stack, where N is the
  62. |   depth of the string stack.
  63. |
  64.         wait
  65.         endof
  66.       3 of
  67. |
  68. |   DROP
  69. |   
  70. |   Data Stack:            N --
  71. |   String Stack:            --
  72. |   
  73. |   Removes the top value from the data stack.
  74. |
  75.         wait
  76.         endof
  77.       4 of
  78. |
  79. |   DROP$
  80. |   
  81. |   Data Stack:              --
  82. |   String Stack:         A$ --
  83. |   
  84. |   Removes the top value from the string stack.
  85. |
  86.         wait
  87.         endof
  88.       5 of
  89. |
  90. |   DUP
  91. |   
  92. |   Data Stack:            N -- N N
  93. |   String Stack:            --
  94. |   
  95. |   Duplicates the top value on the data stack.
  96. |
  97.         wait
  98.         endof
  99.       6 of
  100. |
  101. |   DUP$
  102. |   
  103. |   Data Stack:              --
  104. |   String Stack:         A$ -- A$ A$
  105. |   
  106. |   Duplicates the top value on the string stack.
  107. |
  108.         wait
  109.         endof
  110.       7 of
  111. |
  112. |   OVER
  113. |   
  114. |   Data Stack:          a b -- a b a
  115. |   String Stack:            --
  116. |   
  117. |   Copies the second item on the data stack to the
  118. |   top.
  119. |
  120.         wait
  121.         endof
  122.       8 of
  123. |
  124. |   OVER$
  125. |   
  126. |   Data Stack:                  --
  127. |   String Stack:          a$ b$ -- a$ b$ a$
  128. |   
  129. |   Copies the second item on the string stack to
  130. |   the top.
  131. |
  132.         wait
  133.         endof
  134.       9 of
  135. |
  136. |   PICK
  137. |   
  138. |   Data Stack:                n -- m
  139. |   String Stack:                --
  140. |   
  141. |   Places a copy of the data stack's nth item on the
  142. |   top of the data stack.
  143. |
  144.         wait
  145.         endof
  146.      10 of
  147. |
  148. |   PICK$
  149. |   
  150. |   Data Stack:                n --
  151. |   String Stack:                -- m$
  152. |   
  153. |   Places a copy of the string stack's nth item on
  154. |   the top of the string stack.
  155. |
  156.         wait
  157.         endof
  158.      11 of
  159. |
  160. |   POP
  161. |   
  162. |   Data Stack:                  -- n
  163. |   String Stack:                --
  164. |   
  165. |   Pops a value off the return stack.
  166. |
  167.         wait
  168.         endof
  169.      12 of
  170. |
  171. |   PUSH
  172. |   
  173. |   Data Stack:                n --
  174. |   String Stack:                --
  175. |   
  176. |   Pushes a value to the return stack.
  177. |
  178.         wait
  179.         endof
  180.      13 of
  181. |
  182. |   ROT
  183. |   
  184. |   Data Stack:             a b c -- b c a
  185. |   String Stack:                 --
  186. |   
  187. |   Rotates the top three values on the data stack.
  188. |
  189.         wait
  190.         endof
  191.      14 of
  192. |
  193. |   ROT$
  194. |   
  195. |   Data Stack:                       --
  196. |   String Stack:            a$ b$ c$ -- b$ c$ a$
  197. |   
  198. |   Rotates the top three values on the string
  199. |   stack.
  200. |
  201.         wait
  202.         endof
  203.      15 of
  204. |
  205. |   SWAP
  206. |   
  207. |   Data Stack:              a b -- b a
  208. |   String Stack:                --
  209. |   
  210. |   Swaps the top two values on the data stack.
  211. |
  212.         wait
  213.         endof
  214.      16 of
  215. |
  216. |   SWAP$
  217. |   
  218. |   Data Stack:                   --
  219. |   String Stack:           a$ b$ -- b$ a$
  220. |   
  221. |   Swaps the top two values on the string stack.
  222. |
  223.         wait
  224.         endof
  225.   endcase
  226.  not until
  227.