home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / BATCH / WHAT150.ZIP / WHAT.DOC < prev    next >
Encoding:
Text File  |  1990-09-24  |  17.4 KB  |  359 lines

  1.                          WHAT - Batch file enhancer
  2.  
  3.                         Documentation and enhancements by
  4.                                   Tom Peters,
  5.                               Glendale, WI 53209
  6.  
  7.  
  8. Revision History:
  9.  
  10. October 1989  V1.3   Tom Peters   Many new functions
  11. January 1990  V1.4   Tom Peters   Extended P (printer) function to return
  12.                                   a character string. Also allowed checking
  13.                                   printer status for LPT1 thru LPT4.
  14. March 1990    V1.45  Tom Peters   Fix bug under DR-DOS that made K function
  15.                                   return 0 for directory, instead of 255.
  16.                                   Note: It is likely that other functions will
  17.                                   also exhibit anomalous behavior under DR-DOS.
  18.                                   Only the most rudimentary testing has been
  19.                                   done. If you find other bugs, please report
  20.                                   them to me. 
  21. April 3, 1990 V1.47  Tom Peters   Fix bug in T function that caused wrong
  22.                                   values from 12:00 to 12:59 in both AM & PM. 
  23. September 1990 V1.5  Tom Peters   Add G option- timed wait for character input.
  24.  
  25. WHAT    came   undocumented,  uncopyrighted,  and  unsupported,   with   my  
  26. assembler. After making extensive modifications, I have decided to make  it 
  27. available to the rest of the  computer community. WHAT has become an almost 
  28. indispensable  part  of my suite of DOS enhancement programs, and I'm  sure 
  29. that anyone  who has to write batch files will also come to find it so.
  30.  
  31. In   brief,  WHAT  allows you to ask questions during the  execution  of  a  
  32. batch  file  and take specific action based on the reply. But WHAT  is  NOT 
  33. limited  to  just  asking  the  user  for input via the keyboard.  It   can  
  34. also  ask  DOS questions,  like  "is  printer  2 online and ready?" or  "is  
  35. there  a  math coprocessor available?" or "how big is file XYZZY.ZIP?" etc. 
  36.  
  37. Command format:
  38. WHAT x[E] [parms][parms]
  39.  
  40. In  the  format above, "x" is a single option letter from the  list  below.  
  41. The   "E"   parameter,   if  given, alters the   operation   of   a   given  
  42. option  slightly,  e.g. WHAT C gets a character from the keyboard, WHAT  CE 
  43. does  the same with no echo of the character. 
  44.  
  45. Follow   the   command  WHAT  with one of the option letters,   as   below.  
  46. The  result  is  that the environment variable %WHAT% is created with   the  
  47. value  listed  under the "Environ" column below. Follow the  option  letter 
  48. with an  E for the result in the "Extended" column.
  49.  
  50. Do  NOT  enter  a space between the option letter and the  E  for  extended 
  51. functions,if used, IE WHAT SE is correct, WHAT S E is not. 
  52.  
  53. BUT,   DO  enter  a  space after the option letter and the  "E"   if   any,  
  54. to separate any arguments from the option letter and "E". 
  55.  
  56. This   is   best   seen  in the C option  (below)  when   used   with   the  
  57. optional prompt. Example:
  58.  
  59. WHAT CE "Install now? (Y or N)" YN
  60.  
  61. In  this  example,  the particular option is "C",  the  "get  a  character" 
  62. option,  the extended function is specified with the "E", a prompt is  used 
  63. (the  text in quotes) and only the "Y" and "N" keys are accepted. 
  64.  
  65. One  could  allow the user to enter "Y", "N", or ENTER by using  a  "~"  to 
  66. represent the ENTER e.g. WHAT CE "Install now? " YN~
  67.  
  68. WHAT   also   sets the DOS errorlevel to the value in the  "Exit"   column,  
  69. for most options. 
  70.  
  71. If  you  enter  some invalid data, like asking for the size of  a  file  (F 
  72. option) using a filename with wildcards, the number reported will be zero. 
  73.  
  74. Note:  Options  that have an option for Echo seem to be influenced  by  the 
  75. setting of the DOS batch switch ECHO, e.g. ECHO OFF.
  76.                            Brief options list:
  77.  
  78.                         WHAT V1.50- Batch file enhancer
  79.  
  80. Command                 Purpose    Argument   Environ     Exit    Extended
  81. ---------               -------    --------   -------     ----    --------
  82. C[E] ["prompt"] [chars] Get        Allowable  Character   Character   Echo
  83.                         character  characters
  84.  
  85. Accept   a   single char from keyboard. Returns tilde ("~")  if  ENTER   is  
  86. struck.  Echoes   the   char unless E used. Prompt in quotes  is  given  if  
  87. present.   If  an allowable  chars list is used, WHAT beeps and refuses  to 
  88. proceed until  one  of those chars is entered. Do not press ENTER after the 
  89. character entered. 
  90.  
  91. Options C and G do not allow extended keys, like arrow or function keys. 
  92.  
  93. Command                 Purpose     Argument   Environ     Exit        Extended
  94. ---------               -------     --------   -------     ----        --------
  95. G[E] ["prompt"] [chars] Get         Allowable  Character   Character   Echo
  96.                         character   characters
  97.  
  98. Accept   a   single char from keyboard. Returns tilde ("~")  if  ENTER   is  
  99. struck.  Echoes   the   char unless E used. Prompt in quotes  is  given  if  
  100. present.   If  an allowable  chars list is used, WHAT beeps and refuses  to 
  101. proceed until  one  of those chars is entered. Do not press ENTER after the 
  102. character entered. The G option differs from the C option in that it  gives 
  103. up after 65535 passes thru a loop if no key is ever struck. If this occurs, 
  104. WHAT return "TO" for "time out" to the environment. It should also return 0 
  105. to the DOS errorlevel but this is not tested. 
  106.  
  107. The  timed-wait is done by a crude loop and therefore will run for  various 
  108. amounts  of  time on various machines. It waited 20 seconds on  my  12  mHz 
  109. 80286, and roughly 65 seconds on an 9.54 mHz V20 (8088) machine. 
  110.  
  111. Command                 Purpose     Argument   Environ     Exit        Extended
  112. ---------               -------     --------   -------     ----        --------
  113. S[E] ["prompt"]         Get string  None       String      Length      Echo
  114.  
  115. Get a string from keyboard. Prompt is optional. Extended option  suppresses 
  116. echo. 
  117.  
  118. Command                 Purpose     Argument   Environ     Exit        Extended
  119. ---------               -------     --------   -------     ----        --------
  120. D[E]                    Check DOS   None       Major       (Major*10)  Minor
  121.                                                version     +Minor      version
  122.  
  123. Get  DOS  version running. WHAT D returns portion of DOS version  left   of  
  124. the decimal point. WHAT DE returns the other part. 
  125. Command                 Purpose     Argument   Environ     Exit        Extended
  126. ---------               -------     --------   -------     ----        --------
  127. E[E]                    Get environ None       Bytes       Bytes/10    10 bytes
  128.                         bytes left                         bytes       in exit
  129.  
  130. Get  number  of  bytes available in the environment,  or  number  of  bytes 
  131. divided by 10 (extended). 
  132.  
  133. Command                 Purpose     Argument   Environ     Exit        Extended
  134. ---------               -------     --------   -------     ----        --------
  135. F[E] filespec           Get file    Filespec   Kilobytes   Ks/10Ks     10Ks in
  136.                         size                     (255=directory)       exit
  137.  
  138. Get   size  of file "filespec" in kb. If Extended, get Kb/10. If  the  file  
  139. is   a  directory,  returns  255.  If file nonexistent or  exists  but   is  
  140. zero  length, returns 0.
  141.  
  142. Command                 Purpose     Argument   Environ     Exit        Extended
  143. ---------               -------     --------   -------     ----        --------
  144. K[E] [driveletter]      Get disk    Drive      Kilobytes   Ks/10Ks     10Ks in
  145.                         space                                          exit
  146.  
  147. Get  space  on  disk  in kbytes. Returns kbytes free,  or  tens  of  kbytes  
  148. if extended. If file nonexistent, returns 0.
  149.  
  150. Command                 Purpose     Argument   Environ     Exit        Extended
  151. ---------               -------     --------   -------     ----        --------
  152. M[E]                    Check       None       Kilobytes   Ks/10Ks     10Ks in
  153.                         memory                                         exit
  154.  
  155. Report  kbytes  free  in main RAM memory. This is installed  memory  -  DOS  
  156. overhead  -  buffers & file space - TSR's - environment, i.e. what is  free 
  157. for a  program to use. If extended, value shown is kbytes / 10. 
  158.  
  159. Command                 Purpose     Argument   Environ     Exit        Extended
  160. ---------               -------     --------   -------     ----        ------
  161. P                       Check for   None       1=yes,0=no  1=yes,0=no  None
  162.                         printer
  163.  
  164. Modified March 1990, Tom Peters, See below. Returns 1 if printer is  online  
  165. and ready, 0 if not. 
  166.  
  167. Command                 Purpose     Argument   Environ     Exit        Extended
  168. ---------               -------     --------   -------     ----        --------
  169. V [number]              Get/Set     New mode   Current or  Current or  None
  170.                         video mode             last mode   last mode
  171.  
  172. Get   current video mode. If you card supports multiple modes, this  option  
  173. will  report  the  mode  number  or change the  current  mode.  Mode  7  is 
  174. monochrome. If the mode  is changed, the value output reports what mode was 
  175. in effect  BEFORE  the change. This option uses interrupt 10h, functions 00 
  176. and 0Fh. 
  177.  
  178. Command                 Purpose     Argument   Environ     Exit        Extended
  179. ---------               -------     --------   -------     ----        --------
  180. 7                       Check for   None       1=yes,0=no  1=yes,0=no  None
  181.                         coprocessor
  182.  
  183. Checks   the  BIOS installed equipment list to see if a  math   coprocessor  
  184. (8087, 80287, 80387, etc) is available. Uses INT 11h.
  185.  
  186. Command                 Purpose     Argument   Environ     Exit        Extended
  187. ---------               -------     --------   -------     ----        --------
  188. A                       Check for   None       1=yes,0=no  1=yes,0=no  None
  189.                         ANSI driver
  190.  
  191. Check if the computer was booted with DEVICE=ANSI.SYS or some equivalent in 
  192. the CONFIG.SYS  file.  This option writes the ANSI command  string  "Return  
  193. Cursor  Position"  to the display, and if ANSI.SYS was installed,  it  will  
  194. respond  and WHAT will report the fact. 
  195.  
  196. Command                 Purpose     Argument   Environ     Exit        Extended
  197. ---------               -------     --------   -------     ----        --------
  198. Y[E]                    Get current None       Directory   Level/Drive Drive
  199.                         directory
  200.  
  201. Return   name  of  current directory in the  form  of  "\DOCS\LETTERS".  If  
  202. extended,  returns  only drive letter, e.g. "C". The value returned to  the  
  203. ERRORLEVEL  is the number of directories deep the current directory is. 
  204.  
  205. Command                 Purpose     Argument   Environ     Exit        Extended
  206. ---------               -------     --------   -------     ----        --------
  207. T[E]                    Get Time    None       HH:MM       Nothing     12 hour
  208.                         of day                                         format
  209.  
  210. Return  current  time  of  day as 24-hour clock, hours  and  minutes  only.  
  211. If  extended,   time  is  returned  as 12-hour  clock  with  "AM"  or  "PM"  
  212. appended.   Lead  zeros are used to pad to 2 digits  each.  Function  added 
  213. March 1990, Tom Peters. 
  214.  
  215. Command                 Purpose     Argument   Environ     Exit        Extended
  216. ---------               -------     --------   -------     ----        --------
  217. X[E]                    Get Date    None       mm-dd-yy    Nothing     yy-mm-dd
  218.  
  219. Returns today's date, e.g. "03-29-90". Since this is difficult to sort  on,  
  220. the  extended   version of this option returns the date  year  first,  then 
  221. month,  then date, e.g. "90-03-29". 
  222.                                                                        
  223. Command                 Purpose     Argument   Environ     Exit        Extended
  224. ---------               -------     --------   -------     ----        --------
  225. W[E]                    Get Day     None       Day Name    0-7 for     Abbrev. 
  226.                         of week                            Sun-Sat
  227.  
  228. Returns   day of week as a character string. "Wednesday" is misspelled   so  
  229. that  all  day  names  can  fit  into  an  8-character  string.   Extended:   
  230. 3-letter abbreviation. See "WHAT Messages" below.
  231.  
  232. Command                 Purpose     Argument   Environ     Exit        Extended
  233. ---------               -------     --------   -------     ----        ------
  234. P n                     Check for   n = 1-4    1=yes,0=no  1=yes,0=no  none
  235.                         printer     for LPTn:
  236.  
  237. Return Printer Status. Changed, version 1.4:
  238.  
  239. This option now takes an integer argument for the printer number to  check. 
  240. It  still returns 1 if the device is installed, online, and ready.  It  now 
  241. returns 255 if a printer number argument falls outside the range of 1  thru 
  242. 4  inclusive. No argument is considered a request for the status of  LPT1:. 
  243. This  option  works by getting the printer status via INT 17  and  checking 
  244. that the OnLine bit is set AND the NotBusy bit is set. 
  245.  
  246. Command                 Purpose     Argument   Environ     Exit       Extended
  247. ---------               -------     --------   -------     ----        ------
  248. P[E] n                  Check for   n = 1-4    1=yes,0=no  1=yes,0=no  Verbal
  249.                         printer     for LPTn:                          Message
  250.  
  251. Return Printer Status. Changed, version 1.45:
  252.  
  253. Added  extended  option  to return a verbal status  message,  e.g.  "Busy",  
  254. "Ready", "No Paper" etc. See "WHAT Messages" below.
  255.  
  256.                                WHAT Examples 
  257.  
  258. In a batch file,
  259.  
  260. ECHO OFF
  261. ECHO Do you wish to skip running FOOBAR? 
  262. WHAT C "Please Enter Y or N and do not press ENTER: "
  263. IF %WHAT==Y GOTO DONT
  264. FOOBAR
  265. :DONT
  266. WHAT S "Please enter your name and press ENTER: "
  267. ECHO Hello %WHAT%, we are now going to switch to your own private directory:
  268. CD \%WHAT%
  269. ECHO We will now run FRAP if you don't have an 8087 or 80287, 
  270. ECHO or FRAP87 if you do:
  271. WHAT 7
  272. IF     %WHAT%==1 FRAP87
  273. IF NOT %WHAT%==1 FRAP
  274. WHAT K
  275. ECHO  The  program  SNEEP requires 1500k of free disk space,  and  you  have 
  276. %WHAT%k
  277. ECHO free. Do you want to continue? 
  278. WHAT C "Press Y or N: (do not press ENTER) "
  279. IF NOT %WHAT%==Y GOTO QUIT
  280. INSTALL SNEEP
  281. :QUIT
  282. ECHO Goodbye.
  283.  
  284.                                 WHAT messages
  285.  
  286. In   most  cases, WHAT returns a character string or number  depending   on  
  287. the  function    invoked.   Some   of   them   are   shown   below:   (note   
  288. intentional misspellings)
  289.  
  290. For the W function:      For WE      For PE
  291.  
  292. Sunday                   Sun         Ready    
  293. Monday                   Mon         No Paper 
  294. Tuesday                  Tue         On Line  
  295. Wednsday                 Wed         IO Error 
  296. Thursday                 Thu         Time Out 
  297. Friday                   Fri         Busy     
  298. Saturday                 Sat         OffLine  
  299.                                      ?Unknown 
  300.  
  301.  
  302.                             WHAT Error Messages
  303.  
  304.                              "Invalid command"
  305.  
  306. The  parameter immediately following the word WHAT on the command  line  is 
  307. not a valid option. Valid options as of version 1.45 are CSVDMEKFP7AYTX and 
  308. W.
  309.  
  310.                          "Out of environment space"
  311.  
  312. There   is  no more room on the environment to  store  additional  strings.  
  313. This  problem  is common when using a "shell to DOS" function  from  within  
  314. another  program.  WordStar's  ^KF function will do this. The FOXBASE   "!"  
  315. or  "RUN" command probably does too. 
  316.  
  317. If   you  are  not running WHAT from within a program  and  you  get   this  
  318. error,  shorten or erase some of your environment variables, such  as  your 
  319. PATH, etc.  You  can  also expand the space allotted for your  environment. 
  320. Doing   so   in  versions   of   DOS prior to  3.20  required  a  patch  to  
  321. COMMAND.COM   but   later  releases  provided easier  ways.  In  DOS  3.30, 
  322. include the line below in  your CONFIG.SYS file:
  323.  
  324. SHELL=C:\COMMAND.COM /P /E:320
  325.  
  326. The   /E:320  is the size of the environment in bytes. Use WHAT E  to  find  
  327. out  how  much  environment  space you really  need  and  tune  this  value  
  328. accordingly. Some  (older) versions  of DOS require you to express the size  
  329. of  the  environment space in paragraphs, i.e. 16 byte chunks. 
  330.  
  331. There  is  a  problem with certain versions of DOS that seem  to  pass  the 
  332. current  number of bytes used in the environment to a child  process.  This 
  333. may  cause an "Out of environment space" error even if the DOS  environment 
  334. is  big enough, when a "shell to DOS" function is used. This can  sometimes 
  335. be circumvented.  Set the symbol WHAT in the environment equal to some long 
  336. string: 
  337.  
  338. SET WHAT=ABCDEFGHIJKLMNOPQRSTUVWXYZ
  339.  
  340. Do  this  before you start the application you wish to shell out  of.  WHAT 
  341. scans  the the environment and replaces the value of the symbol  "WHAT"  if 
  342. one is found, rather than attempting to add a new string. 
  343.  
  344.                    "Must have DOS Version 2.0 or higher"
  345.  
  346. WHAT doesn't run under old versions of DOS. Upgrade!!
  347.  
  348.                                Effective Date
  349.  
  350. This document last revised September 1990. 
  351.  
  352. If you find this program usefull, please contribute $10 (or whatever) or
  353. if you send $25 or more I will send the commented source and the latest
  354. version. 
  355.  
  356. Tom Peters
  357. 4517 N. Oakland Ave
  358. Milwaukee, WI 53211
  359.