home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DIVERSEN / TIPI2A / TIPIGUI.TPI < prev    next >
Text File  |  1994-11-27  |  5KB  |  226 lines

  1. # TIPIGUI.TPI by Kent Peterson 11/7/94
  2.  
  3. defstr p$ # The name of the program
  4.  
  5. # If this isn't an HP hundred series palmtop, gracefully abort
  6. machine? 2 <
  7. if
  8.  | Sorry, this program only runs on an HP hundred series palmtop.
  9.  | Run CHARTIPI to switch to the charater version of the workbench.
  10.  bye
  11. endif
  12.  
  13. define timebar
  14.  date$ "  " +$ time$ +$
  15.  0 59 locate print$
  16. enddef
  17.  
  18. define getkey
  19.  begin
  20.   key dup if dup endif
  21.   timebar
  22.  until
  23. enddef
  24.  
  25. define cline$ ( -- )
  26.               ( -- command$ )
  27.  "R" "command.lin" 1 open
  28.  1 isinput
  29.  get$ console isinput
  30.  1 close
  31. enddef
  32.  
  33. deftable rows
  34.  25 85
  35. endtable
  36.  
  37. deftable cols
  38.  60 200 380 540
  39. endtable
  40.  
  41. deftable icons
  42.  "doc.icn"
  43.  "t.icn"
  44.  "command.icn"
  45.  "run.icn"
  46.  "factory.icn"
  47.  "lookup.icn"
  48.  "dos.icn"
  49. endtable
  50.  
  51. deftable text$
  52.  "Edit"
  53.  "Change Program"
  54.  "Set Command Line"
  55.  "Run Program"
  56.  "Make EXE"
  57.  "Lookup"
  58.  "DOS Command"
  59. endtable
  60.  
  61. define iconcoords ( n -- row col )
  62. # returns the row and column at which to draw an icon
  63.  1 - dup 4 / 1 + rows swap
  64.  4 mod 1 + cols
  65. enddef
  66.  
  67. define textcoords ( n  -- row col )
  68.                   ( t$ -- t$      )
  69. # returns the row and column at which to draw text
  70.  1 - dup 4 / 1 + rows 35 + swap
  71.  4 mod 1 + cols 15 + len 4 * -
  72. enddef
  73.  
  74. define drawcursor ( n -- )
  75. # draws a box cursor at location n
  76.    1 setpencolor
  77.    3 setreprule
  78.    iconcoords over over
  79.    6 - swap 3 - swap
  80.    over over
  81.    movepen 54 + swap 36 + swap 0 rot rot
  82.    drawrect
  83.    5 - swap 2 - swap
  84.    over over
  85.    movepen 52 + swap 34 + swap 0 rot rot
  86.    drawrect
  87. enddef
  88.  
  89. define restartline
  90.  "t " print$ p$ fetch print$ " " print$ print cr lf
  91. enddef
  92.  
  93.  
  94. define makecmd
  95.  0 screen
  96.  "O" "runfile.bat" 2 open
  97.  2 isoutput dup
  98.  case 0 of # Quit
  99.         endof
  100.       1 of # Edit
  101.          "e " print$
  102.          p$ fetch print$ cr lf
  103.          restartline
  104.         endof
  105.       2 of # Change Program
  106.          | t
  107.         endof
  108.       3 of # Set Command Line
  109.          "O" "command.lin" 1 open
  110.          console isoutput
  111.          "Command Line: " print$ get$
  112.          1 isoutput print$ cr lf
  113.          1 close
  114.          2 isoutput
  115.          restartline
  116.         endof
  117.       4 of # Run Program
  118.          "tipi " print$
  119.          p$ fetch print$ " " print$
  120.          cline$ print$ cr lf
  121.          restartline
  122.         endof
  123.       5 of # Make EXE
  124.          console isoutput
  125.          "Making EXE..." print$
  126.          2 isoutput
  127.          "copy /b tipicore.bin+register.dat+" print$
  128.          p$ fetch dup$ print$ " " print$
  129.          ucase$ ".TPI" ".EXE" replace$ print$
  130.          " /b /v > nul" print$ cr lf
  131.          restartline
  132.         endof
  133.       6 of # Lookup
  134.          | call helptipi.bat
  135.          restartline
  136.         endof
  137.       7 of # DOS Command
  138.          console isoutput
  139.          "DOS Command: " print$ get$
  140.          2 isoutput
  141.          print$ cr lf
  142.          "pause" print$ cr lf
  143.          restartline
  144.         endof
  145.  endcase
  146.  console isoutput
  147.  bye
  148. enddef
  149.  
  150. command$
  151. parse$ drop$
  152. parse$
  153. # if there is no p$, ask for one
  154. dup$ "" =$
  155. if
  156.  drop$ drop$ "2" "Name of TIPI program: " print$ get$
  157. endif
  158. "." instr drop$
  159. not if ".tpi" +$ endif
  160. ucase$ p$ store
  161.  
  162. # get the cursor parameter if it exists
  163. val 1 max
  164.  
  165. 6 setvmode
  166.  
  167. 0 8 setfont
  168. 15 6 movepen
  169. 0 172 634 drawrect
  170. 140 6 movepen
  171. 0 172 634 drawrect
  172.  
  173. 0 4 40
  174. "TIPI Programmer's Workbench"
  175. plottext
  176.  
  177. 0 145 40
  178. "Program Name: " p$ fetch +$
  179. plottext
  180. 0 160 40
  181. "Command Line: " cline$ +$
  182. plottext
  183.  
  184. 0 175 40
  185. "Select with the arrow keys and Enter, or press the"
  186. plottext
  187. 0 185 40
  188. "underlined letter.  Press Esc to quit."
  189. plottext
  190.  
  191. 7 do
  192.  0 7 index - 1 + dup text$ textcoords plottext
  193.  0 7 index - 1 + dup text$ textcoords swap 1 + swap drop$ "_" plottext
  194.  0 7 index - 1 + dup icons iconcoords ploticon
  195. loop
  196.  
  197. begin
  198.  dup drawcursor
  199.  getkey
  200.  case 101 of drawcursor 1 makecmd endof                   # e
  201.        45 of drawcursor 1 makecmd endof                   # E
  202.        99 of drawcursor 2 makecmd endof                   # c
  203.        67 of drawcursor 2 makecmd endof                   # C
  204.       115 of drawcursor 3 makecmd endof                   # s
  205.        83 of drawcursor 3 makecmd endof                   # S
  206.       114 of drawcursor 4 makecmd endof                   # r
  207.        82 of drawcursor 4 makecmd endof                   # R
  208.       109 of drawcursor 5 makecmd endof                   # m
  209.        77 of drawcursor 5 makecmd endof                   # M
  210.       108 of drawcursor 6 makecmd endof                   # l
  211.        76 of drawcursor 6 makecmd endof                   # L
  212.       100 of drawcursor 7 makecmd endof                   # d
  213.        68 of drawcursor 7 makecmd endof                   # D
  214.       333 of dup drawcursor 1 + 7 min endof               # right
  215.       331 of dup drawcursor 1 - 1 max endof               # left
  216.       336 of dup drawcursor 4 + dup 7 >                   # down
  217.              if 4 - endif endof
  218.       328 of dup drawcursor dup 4 > if  4 - endif endof   # up
  219.       327 of drawcursor 1 endof                           # home
  220.       335 of drawcursor 7 endof                           # end
  221.        13 of makecmd endof                                # enter
  222.        27 of drop 0 makecmd endof                         # esc
  223.  default dup drawcursor
  224.  endcase
  225. 0 until
  226.