home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / tipi / batmenu.tpi < prev    next >
Text File  |  1993-11-06  |  842b  |  50 lines

  1. # Displays a batch menu
  2. # and runs the chosen function
  3. # by Kent Peterson
  4.  
  5. defstr valid$
  6.  
  7. define waitforkey ( -- choice )
  8.                   ( valid$ -- )
  9.  27 chr$ +$     # Add the escape character to the end
  10.  0 cursor
  11.  begin
  12.   inkey$ ucase$ # valid$ key$
  13.   len instr *
  14.   dup
  15.   if dup drop$ endif drop$
  16.  until
  17.  1 cursor 
  18. enddef
  19.  
  20. cls
  21. command$
  22. parse$ drop$
  23. parse$ swap$ drop$
  24. dup$ "" =$ if "Usage: BATMENU menufile" print$ 1 bye endif
  25. "I" swap$ 1 open
  26. 1 isinput
  27. "" valid$ store
  28. begin
  29.  get$ parse$ dup$ "" =$
  30.  if 1 drop$ drop$
  31.  else 0 valid$ fetch swap$ +$ valid$ store drop$
  32.  endif
  33. until
  34. begin
  35.  get$ error
  36.  dup if drop$ else print$ cr endif
  37. until
  38.  
  39. valid$ fetch waitforkey
  40. dup
  41. 1 0 filepos drop
  42. "" do drop$ get$ loop
  43. parse$ drop$
  44. 1 close
  45. "O" "BATCMD.BAT" 1 open
  46. 1 isoutput
  47. print$ cr lf
  48. 1 close
  49. cls
  50.