home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / pbaseiv.zip / P4UTL006.TIP < prev    next >
Text File  |  1991-12-16  |  1KB  |  53 lines

  1. DOS lacks a batch file command for reading key presses, so I
  2. wrote my own. KEY.COM is like a skeleton key that can unlock
  3. the keyboard for any batch file.
  4.  
  5. In a batch file, feed KEY a set of characters in commands
  6. like key ynq or key 01234. If you type just key, the
  7. characters default to YN.
  8.  
  9. KEY waits for you to type a character. The program sets
  10. ERRORLEVEL to 0 for the first character, 1 for the second
  11. character, and so on. For the command KEY YNQ, pressing Y,
  12. N, or Q sets ERRORLEVEL to 0, 1, or 2, respectively.
  13.  
  14. Wong Choong Sheong
  15. Selango, West Malaysia
  16.  
  17. Editor's note: KEY.COM is included, in executable form, in
  18. the P4UTIL directory on your PowerBase *.* Volume IV
  19. diskette. To use it, copy it to a directory listed in your
  20. PATH.
  21.  
  22. KEY ignores case. The commands key AbC and KEY aBc are
  23. functionally identical. For a sample of how to use KEY, run
  24. TESTKEY.BAT [see below]. Press y, n, or q, and the
  25. program will display `Yes', `No', or `Quit', proving that
  26. KEY returned the correct values to the batch file.
  27.  
  28. TESTKEY.BAT (Use Alt-F to extract)
  29.  
  30. ---- BEGIN LISTING ----
  31. @echo off
  32. echo Press Y, N, or Q.
  33. key ynq
  34. if errorlevel 2 goto QUIT
  35. if errorlevel 1 goto NO
  36. rem -- errorlevel is 0
  37. echo "Yes"
  38. goto END
  39. :NO
  40. echo "No"
  41. goto END
  42. :QUIT
  43. echo "Quit"
  44. :END
  45. echo on
  46. ---- END LISTING ----
  47.  
  48. Title: Skeleton Key
  49. Category: DOS
  50. Issue date: Apr 1991
  51. Editor: Tom Swan
  52. Supplementary files: P4UTIL\KEY.COM
  53.