home *** CD-ROM | disk | FTP | other *** search
- WHAT - Batch file enhancer
-
- Documentation and enhancements by
- Tom Peters,
- Glendale, WI 53209
-
-
- Revision History:
-
- October 1989 V1.3 Tom Peters Many new functions
- January 1990 V1.4 Tom Peters Extended P (printer) function to return
- a character string. Also allowed checking
- printer status for LPT1 thru LPT4.
- March 1990 V1.45 Tom Peters Fix bug under DR-DOS that made K function
- return 0 for directory, instead of 255.
- Note: It is likely that other functions will
- also exhibit anomalous behavior under DR-DOS.
- Only the most rudimentary testing has been
- done. If you find other bugs, please report
- them to me.
- April 3, 1990 V1.47 Tom Peters Fix bug in T function that caused wrong
- values from 12:00 to 12:59 in both AM & PM.
- September 1990 V1.5 Tom Peters Add G option- timed wait for character input.
-
- WHAT came undocumented, uncopyrighted, and unsupported, with my
- assembler. After making extensive modifications, I have decided to make it
- available to the rest of the computer community. WHAT has become an almost
- indispensable part of my suite of DOS enhancement programs, and I'm sure
- that anyone who has to write batch files will also come to find it so.
-
- In brief, WHAT allows you to ask questions during the execution of a
- batch file and take specific action based on the reply. But WHAT is NOT
- limited to just asking the user for input via the keyboard. It can
- also ask DOS questions, like "is printer 2 online and ready?" or "is
- there a math coprocessor available?" or "how big is file XYZZY.ZIP?" etc.
-
- Command format:
- WHAT x[E] [parms][parms]
-
- In the format above, "x" is a single option letter from the list below.
- The "E" parameter, if given, alters the operation of a given
- option slightly, e.g. WHAT C gets a character from the keyboard, WHAT CE
- does the same with no echo of the character.
-
- Follow the command WHAT with one of the option letters, as below.
- The result is that the environment variable %WHAT% is created with the
- value listed under the "Environ" column below. Follow the option letter
- with an E for the result in the "Extended" column.
-
- Do NOT enter a space between the option letter and the E for extended
- functions,if used, IE WHAT SE is correct, WHAT S E is not.
-
- BUT, DO enter a space after the option letter and the "E" if any,
- to separate any arguments from the option letter and "E".
-
- This is best seen in the C option (below) when used with the
- optional prompt. Example:
-
- WHAT CE "Install now? (Y or N)" YN
-
- In this example, the particular option is "C", the "get a character"
- option, the extended function is specified with the "E", a prompt is used
- (the text in quotes) and only the "Y" and "N" keys are accepted.
-
- One could allow the user to enter "Y", "N", or ENTER by using a "~" to
- represent the ENTER e.g. WHAT CE "Install now? " YN~
-
- WHAT also sets the DOS errorlevel to the value in the "Exit" column,
- for most options.
-
- If you enter some invalid data, like asking for the size of a file (F
- option) using a filename with wildcards, the number reported will be zero.
-
- Note: Options that have an option for Echo seem to be influenced by the
- setting of the DOS batch switch ECHO, e.g. ECHO OFF.
- Brief options list:
-
- WHAT V1.50- Batch file enhancer
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- C[E] ["prompt"] [chars] Get Allowable Character Character Echo
- character characters
-
- Accept a single char from keyboard. Returns tilde ("~") if ENTER is
- struck. Echoes the char unless E used. Prompt in quotes is given if
- present. If an allowable chars list is used, WHAT beeps and refuses to
- proceed until one of those chars is entered. Do not press ENTER after the
- character entered.
-
- Options C and G do not allow extended keys, like arrow or function keys.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- G[E] ["prompt"] [chars] Get Allowable Character Character Echo
- character characters
-
- Accept a single char from keyboard. Returns tilde ("~") if ENTER is
- struck. Echoes the char unless E used. Prompt in quotes is given if
- present. If an allowable chars list is used, WHAT beeps and refuses to
- proceed until one of those chars is entered. Do not press ENTER after the
- character entered. The G option differs from the C option in that it gives
- up after 65535 passes thru a loop if no key is ever struck. If this occurs,
- WHAT return "TO" for "time out" to the environment. It should also return 0
- to the DOS errorlevel but this is not tested.
-
- The timed-wait is done by a crude loop and therefore will run for various
- amounts of time on various machines. It waited 20 seconds on my 12 mHz
- 80286, and roughly 65 seconds on an 9.54 mHz V20 (8088) machine.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- S[E] ["prompt"] Get string None String Length Echo
-
- Get a string from keyboard. Prompt is optional. Extended option suppresses
- echo.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- D[E] Check DOS None Major (Major*10) Minor
- version +Minor version
-
- Get DOS version running. WHAT D returns portion of DOS version left of
- the decimal point. WHAT DE returns the other part.
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- E[E] Get environ None Bytes Bytes/10 10 bytes
- bytes left bytes in exit
-
- Get number of bytes available in the environment, or number of bytes
- divided by 10 (extended).
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- F[E] filespec Get file Filespec Kilobytes Ks/10Ks 10Ks in
- size (255=directory) exit
-
- Get size of file "filespec" in kb. If Extended, get Kb/10. If the file
- is a directory, returns 255. If file nonexistent or exists but is
- zero length, returns 0.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- K[E] [driveletter] Get disk Drive Kilobytes Ks/10Ks 10Ks in
- space exit
-
- Get space on disk in kbytes. Returns kbytes free, or tens of kbytes
- if extended. If file nonexistent, returns 0.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- M[E] Check None Kilobytes Ks/10Ks 10Ks in
- memory exit
-
- Report kbytes free in main RAM memory. This is installed memory - DOS
- overhead - buffers & file space - TSR's - environment, i.e. what is free
- for a program to use. If extended, value shown is kbytes / 10.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- ------
- P Check for None 1=yes,0=no 1=yes,0=no None
- printer
-
- Modified March 1990, Tom Peters, See below. Returns 1 if printer is online
- and ready, 0 if not.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- V [number] Get/Set New mode Current or Current or None
- video mode last mode last mode
-
- Get current video mode. If you card supports multiple modes, this option
- will report the mode number or change the current mode. Mode 7 is
- monochrome. If the mode is changed, the value output reports what mode was
- in effect BEFORE the change. This option uses interrupt 10h, functions 00
- and 0Fh.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- 7 Check for None 1=yes,0=no 1=yes,0=no None
- coprocessor
-
- Checks the BIOS installed equipment list to see if a math coprocessor
- (8087, 80287, 80387, etc) is available. Uses INT 11h.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- A Check for None 1=yes,0=no 1=yes,0=no None
- ANSI driver
-
- Check if the computer was booted with DEVICE=ANSI.SYS or some equivalent in
- the CONFIG.SYS file. This option writes the ANSI command string "Return
- Cursor Position" to the display, and if ANSI.SYS was installed, it will
- respond and WHAT will report the fact.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- Y[E] Get current None Directory Level/Drive Drive
- directory
-
- Return name of current directory in the form of "\DOCS\LETTERS". If
- extended, returns only drive letter, e.g. "C". The value returned to the
- ERRORLEVEL is the number of directories deep the current directory is.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- T[E] Get Time None HH:MM Nothing 12 hour
- of day format
-
- Return current time of day as 24-hour clock, hours and minutes only.
- If extended, time is returned as 12-hour clock with "AM" or "PM"
- appended. Lead zeros are used to pad to 2 digits each. Function added
- March 1990, Tom Peters.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- X[E] Get Date None mm-dd-yy Nothing yy-mm-dd
-
- Returns today's date, e.g. "03-29-90". Since this is difficult to sort on,
- the extended version of this option returns the date year first, then
- month, then date, e.g. "90-03-29".
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- --------
- W[E] Get Day None Day Name 0-7 for Abbrev.
- of week Sun-Sat
-
- Returns day of week as a character string. "Wednesday" is misspelled so
- that all day names can fit into an 8-character string. Extended:
- 3-letter abbreviation. See "WHAT Messages" below.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- ------
- P n Check for n = 1-4 1=yes,0=no 1=yes,0=no none
- printer for LPTn:
-
- Return Printer Status. Changed, version 1.4:
-
- This option now takes an integer argument for the printer number to check.
- It still returns 1 if the device is installed, online, and ready. It now
- returns 255 if a printer number argument falls outside the range of 1 thru
- 4 inclusive. No argument is considered a request for the status of LPT1:.
- This option works by getting the printer status via INT 17 and checking
- that the OnLine bit is set AND the NotBusy bit is set.
-
- Command Purpose Argument Environ Exit Extended
- --------- ------- -------- ------- ---- ------
- P[E] n Check for n = 1-4 1=yes,0=no 1=yes,0=no Verbal
- printer for LPTn: Message
-
- Return Printer Status. Changed, version 1.45:
-
- Added extended option to return a verbal status message, e.g. "Busy",
- "Ready", "No Paper" etc. See "WHAT Messages" below.
-
- WHAT Examples
-
- In a batch file,
-
- ECHO OFF
- ECHO Do you wish to skip running FOOBAR?
- WHAT C "Please Enter Y or N and do not press ENTER: "
- IF %WHAT==Y GOTO DONT
- FOOBAR
- :DONT
- WHAT S "Please enter your name and press ENTER: "
- ECHO Hello %WHAT%, we are now going to switch to your own private directory:
- CD \%WHAT%
- ECHO We will now run FRAP if you don't have an 8087 or 80287,
- ECHO or FRAP87 if you do:
- WHAT 7
- IF %WHAT%==1 FRAP87
- IF NOT %WHAT%==1 FRAP
- WHAT K
- ECHO The program SNEEP requires 1500k of free disk space, and you have
- %WHAT%k
- ECHO free. Do you want to continue?
- WHAT C "Press Y or N: (do not press ENTER) "
- IF NOT %WHAT%==Y GOTO QUIT
- INSTALL SNEEP
- :QUIT
- ECHO Goodbye.
-
- WHAT messages
-
- In most cases, WHAT returns a character string or number depending on
- the function invoked. Some of them are shown below: (note
- intentional misspellings)
-
- For the W function: For WE For PE
-
- Sunday Sun Ready
- Monday Mon No Paper
- Tuesday Tue On Line
- Wednsday Wed IO Error
- Thursday Thu Time Out
- Friday Fri Busy
- Saturday Sat OffLine
- ?Unknown
-
-
- WHAT Error Messages
-
- "Invalid command"
-
- The parameter immediately following the word WHAT on the command line is
- not a valid option. Valid options as of version 1.45 are CSVDMEKFP7AYTX and
- W.
-
- "Out of environment space"
-
- There is no more room on the environment to store additional strings.
- This problem is common when using a "shell to DOS" function from within
- another program. WordStar's ^KF function will do this. The FOXBASE "!"
- or "RUN" command probably does too.
-
- If you are not running WHAT from within a program and you get this
- error, shorten or erase some of your environment variables, such as your
- PATH, etc. You can also expand the space allotted for your environment.
- Doing so in versions of DOS prior to 3.20 required a patch to
- COMMAND.COM but later releases provided easier ways. In DOS 3.30,
- include the line below in your CONFIG.SYS file:
-
- SHELL=C:\COMMAND.COM /P /E:320
-
- The /E:320 is the size of the environment in bytes. Use WHAT E to find
- out how much environment space you really need and tune this value
- accordingly. Some (older) versions of DOS require you to express the size
- of the environment space in paragraphs, i.e. 16 byte chunks.
-
- There is a problem with certain versions of DOS that seem to pass the
- current number of bytes used in the environment to a child process. This
- may cause an "Out of environment space" error even if the DOS environment
- is big enough, when a "shell to DOS" function is used. This can sometimes
- be circumvented. Set the symbol WHAT in the environment equal to some long
- string:
-
- SET WHAT=ABCDEFGHIJKLMNOPQRSTUVWXYZ
-
- Do this before you start the application you wish to shell out of. WHAT
- scans the the environment and replaces the value of the symbol "WHAT" if
- one is found, rather than attempting to add a new string.
-
- "Must have DOS Version 2.0 or higher"
-
- WHAT doesn't run under old versions of DOS. Upgrade!!
-
- Effective Date
-
- This document last revised September 1990.
-
- If you find this program usefull, please contribute $10 (or whatever) or
- if you send $25 or more I will send the commented source and the latest
- version.
-
- Tom Peters
- 4517 N. Oakland Ave
- Milwaukee, WI 53211
-