home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / batch / buba.zip / BUBA.DOC next >
Text File  |  1990-03-26  |  13KB  |  318 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                               ************************
  8.                                B U B A
  9.  
  10.                                Bill's
  11.                                Unique
  12.                                Batch
  13.                                Arsenal
  14.                                ***********************
  15.  
  16.                   A free, public-domain group of utilities
  17.                   designed to make batch files more capable.
  18.  
  19.                   by Bill Reamy
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. This archive should contain the following files:
  27. DISKSIZE.EXE   Reports (in ErrorLevel) the size of a disk.
  28. FILEFITS.EXE   Checks the size of a particular file.
  29. FILESIZE.EXE   Reports (in ErrorLevel) the size of a file.
  30.    INPUT.EXE   Places user input in an environment variable.
  31. SELECTOR.EXE   A point & shoot file picker .
  32.     BUBA.DOC   This Documentation.
  33.  
  34. If you want a quick help screen for any of these programs, just run the
  35. program with just ? as a parameter. For example: FileFits ?
  36.  
  37. *****************************************************************************
  38. * DISCLAIMER: These programs are provided as is. They seem to work on my    *
  39. * system without causing damage. I do NOT guarantee they will do the same   *
  40. * on your system. I haven't (can't) tested these programs with all versions *
  41. * of DOS, and I can't guarantee they won't lock up your computer, destroy   *
  42. * data or make you impotent or anything like that. But I would like to hear *
  43. * about any problems you have.                                              *
  44. *****************************************************************************
  45.  
  46.  
  47.  
  48.  
  49. If you have comments, suggestions, questions, or (gasp) complaints, you
  50. can E-mail me at either of these addresses:
  51.       GEnie Mail: W.Reamy
  52.       CompServe: 71660,3072
  53. Or, if you prefer real paper (paper, what's that?), drop me a line at:
  54.       Bill Reamy
  55.       9426 Dubarry Ave.
  56.       SeaBrook Md. 20706
  57.  
  58.  
  59.  
  60.  
  61. The programs in this package are designed to extend, rather than replace
  62. the many fine batch utility packages currently available. You won't find yet
  63. another screen color manipulator here. If you don't yet have a good general
  64. purpose batch file enhancer package, I suggest you look into getting one.
  65. PC Magazine has put out some good utilities in this department, and Peter
  66. Norton has blessed us with some really excellent stuff to add capabilities
  67. and pizzaz to batch files. There are certainly many other good packages, both
  68. commercial and shareware, that can let you harness the power of batch files.
  69.  
  70. I wrote most of these programs when I was writing a batch file and got
  71. stuck because I didn't have a way of doing a particular task. That's why
  72. the 'U' in BUBA stands for Unique. If anyone has written similar programs,
  73. I am unaware of it. These programs probably won't get used in all (or
  74. even most) of your batch files, but when they are needed, they can prove
  75. to be very valuable indeed.
  76.  
  77.    ****************
  78. **** DiskSize.exe ***********************************************************
  79.    ****************
  80.  
  81. DiskSize can let your batch program determine the actual size of a floppy
  82. (or hard) disk. For instance, if you have a 1.2meg 5 1/2" floppy drive, but
  83. the disk currently in it is a 360k floppy, DiskSize can spot it as being 360k.
  84.  
  85. Usage.......DISKSIZE [d:]
  86.   d: is drive you specify, and it is optional.
  87.  
  88. Returns.....ErrorLevel   1: 360k 5.25"
  89.             ErrorLevel   2: 720k 3.5"
  90.             ErrorLevel   3: 1.2m 5.25"
  91.             ErrorLevel   4: 1.44m 3.5"
  92.             ErrorLevel 128: 11-20meg Hard Disk
  93.             ErrorLevel 129: 21-40meg Hard Disk
  94.             ErrorLevel 130: 41-60meg Hard Disk
  95.             ErrorLevel 131: 61-80meg Hard Disk
  96.             ErrorLevel 132: 81+ meg Hard Disk
  97.             ErrorLevel 255: unknown disk type,
  98.                             door open,
  99.                             or other error
  100.  
  101. NOTE: RamDisks of various sizes may be identified oddly.
  102.       For example, a 5 megabyte ram-disk will return ErrorLevel 4.
  103.  
  104.  
  105.  
  106.    ****************
  107. **** FileFits.exe ************************************************************
  108.    ****************
  109. FileFits is a utility that reports (in ErrorLevel) on a file's size.
  110. It can be used to determine if a file is to large for a particular
  111. application program before the application is run. It can also be used
  112. to spot empty files, which are sometimes the side-effect of some accident.
  113.  
  114. usage:     FILEFITS file.ext (size)
  115.  
  116. example:   FILEFITS MYFILE.TXT 64000
  117.  
  118. returns: ErrorLevel = 0 if file size is < or = (size)
  119.          ErrorLevel = 1 if file size is > (size)
  120.          ErrorLevel = 255 file not found
  121.  
  122. note: (size) is expressed in bytes, NOT kilobytes.
  123.  
  124. Most editors won't work with files larger than what will fit in available
  125. memory. Here's a batch file that checks the size of a text file, runs the
  126. editor if possible, or a text file viewer instead. Substitute "EDITOR",
  127. "LISTER", and the trigger file size with names and value appropriate to
  128. what you've got in your system.
  129.  
  130.         Echo Off
  131.         if "%1"=="" goto Whoops
  132.         FileFits %1 64000
  133.         if ErrorLevel 255 goto Whoops
  134.         if ErrorLevel 1 goto View
  135.         EDITOR %1
  136.         goto End
  137.         :View
  138.         LISTER %1
  139.         goto End
  140.         :Whoops
  141.         Echo !!!ERROR!!!
  142.         :End
  143.  
  144. If you use this example, be sure to substitute the names of the editor and
  145. file viewer you use. The value 64000 should be replaced by a value appropriate
  146. to your system and situation. You may have to experiment to determine this
  147. value.
  148.  
  149.  
  150.  
  151.    ****************
  152. **** FileSize.exe ********************************************************
  153.    ****************
  154. FileSize.exe is a utility that reports file size in ErrorLevel.
  155. FileSize can be used by a batch file that displays the rough amount of
  156. time a file will take to send to a modem, or printer. It could also be
  157. used to tell if a file will fit on a small ramdisk, etc.
  158. NOTE: If FileSize returns 0 that does not necessarily mean that the file is
  159.       empty! It just means that the file is smaller than 1k. To see if a
  160.       file is empty, use FileFits (see above).
  161.  
  162. Usage:     FILESIZE file.ext
  163. Returns:   ErrorLevel 0-253: file size in k
  164.            ErrorLevel 254:   file larger than 253k
  165.            ErrorLevel 255:   file not found
  166.  
  167.  
  168.  
  169.    *************
  170. **** Input.exe ************************************************************
  171.    *************
  172. Input.exe is a utility that allows user input in batch programs.
  173. Most user input programs let the user type in a single key, and then
  174. report which key was pressed in ErrorLevel. Input.exe allows the
  175. user to type in an entire line of text, and places this text in an
  176. environment variable. It can be used to get a parameter the user forgot
  177. to enter, or to get a filename, filespec, path or whatever.
  178.  
  179. NOTE: You MUST read the section of this file called "About Environment
  180.       Variables" before using this program.
  181.  
  182. usage:  INPUT envname
  183.     envname - The name of the Dos Environment Variable where
  184.               you want Input to store what the user types.
  185.               This variable must be created and
  186.               sized before you can run Input.
  187.  
  188. example batch file:
  189.    Set Test=12345678.123
  190.    Echo Please type in a filename.
  191.    Input Test
  192.    Dir %Test%
  193.    Set Test=
  194.  
  195. Input will return an ErrorLevel of 1 if it can't find the environment variable.
  196.  
  197. With a little clever redirection it can also put other things in environment
  198. variables. For example, the following portion of a batch file will save the
  199. current directory in an environment variable.
  200.  
  201.     rem   Create and size environment variable.
  202.     Set OldDir=123456789012345678901234567890
  203.  
  204.     rem  CD command with no parameters displays current dir.
  205.     rem  Redirect into Input.
  206.     CD | Input OldDir
  207.     CD /Data
  208.        .
  209.        .
  210.        .
  211.     rem  Later on, directory is restored and environment variable is destroyed.
  212.     CD %OldDir%
  213.     Set OldDir=
  214.  
  215.  
  216.  
  217.    ****************
  218. **** Selector.exe ************************************************************
  219.    ****************
  220. Selector.exe is a point and shoot file picker for batch programs.
  221. It can provide an easy to use, point and shoot menu from which
  222. the user can select a file. The name ONLY (no path) is then placed
  223. in an environment variable. Be SURE to read the section on at the end
  224. of this file called "About Environment Variables" before using Selector.
  225.  
  226. Usage:  SELECTOR envname filespec1 [filespec2...] ["title goes here"]
  227.   envname - The name of the environment variable that Selector
  228.             will use to store the name of the file selected by
  229.             the user. This environment variable must first be
  230.             created and sized. Example:
  231.                                SET TEXTFILE=12345678.123
  232.                                SELECTOR TEXTFILE *.TXT *.DOC "Text Files"
  233.                                TYPE %TEXTFILE%
  234.                                SET TEXTFILE=
  235.             The batch program shown above will type the text
  236.             file that the user selects. Be sure to get rid of
  237.             the environment variable when you are done with it.
  238.   filespec - The type of files Selector will display to the user.
  239.              For example: *.txt
  240.              You can use as many filespecs as you want, just
  241.              separate them with spaces.
  242.   title - Optional title that Selector will display.
  243.           It must be enclosed by quotes ("").
  244.  
  245. Selector will allow the user to abort by pressing the ESC key.
  246. If this happens, Selector will not modify the environment variable,
  247. and will return an ErrorLevel of 1. This will also happen if no
  248. files matching any of the filespecs given are found.
  249.  
  250. Selector will clear the screen before and after it does it's thing,
  251. so you don't have to worry about it yourself.
  252.  
  253. Selector uses whatever colors are on the screen when it starts,
  254. so you can use one of the many available utilities to set colors
  255. the way you like. However, if the foreground color is too bright,
  256. Selector may have trouble highlighting the current file.
  257. That's because all text is already highlighted.
  258.  
  259.  
  260.  
  261.   ******************************
  262. *** About Environment Variables *********************************************
  263.   ******************************
  264.  
  265. The Dos Environment (or Set) is an area of limited size where Dos stores
  266. information in environment variables. Each variable takes the form:
  267.         NAME=One or More Words
  268. Here are some examples:
  269.         OLDDIR=c:\SprdSht\Data
  270.         PHNUM=555-1212
  271.         LINES=43
  272.         PARA=/d+ /s- /f
  273.  
  274. Some applications allow you to set parameters using an environment variable
  275. instead of the command line. Dos itself uses three environment variables.
  276. These are COMSPEC, PATH, and PROMPT. You __MUST NOT__ use these names for
  277. your own variables. Comspec is where Dos stores the location of command.com
  278. so it can re-load it when necessary. Path and Prompt are where Dos stores
  279. the search path and current prompt settings.
  280.  
  281. You can create, change and view your own variables using the Dos Set command.
  282. To view the set of all variables just type SET at the C> prompt. To change
  283. a variable type SET NAME=Whatever. The variable NAME will now be set to
  284. Whatever. IMPORTANT: Do NOT leave a space between the environment
  285. variable name and the "=". For example:
  286.                              RIGHT:  Set Test=Qwerty
  287.                              WRONG:  Set Test =Qwerty
  288. To destroy an environment variable type: Set Name=
  289. Be sure you don't type anything after the "=", not even a space.
  290.  
  291. The environment is only so big, and if you put a lot of stuff in it, you
  292. may run out of space. If you are using Dos version 3.2 or later, you can
  293. set the size of your environment by putting the line:
  294.            SHELL C:\COMMAND.COM /E:512 /P
  295. in your Config.sys file. Be SURE to replace C:\ with the proper path to
  296. Command.com, and replace 512 with whatever size (in bytes) environment you
  297. would like to have.
  298.  
  299. One odd thing about the environment set is that every Com and Exe program
  300. gets it's own copy of the environment. This way, if a program modifies it's
  301. own copy, the master copy is not changed. The drawback to this approach is
  302. that you can wind up with several copies of the environment.
  303.  
  304. Since Input and Selector aren't sure which copies to change, they change all
  305. copies of the environment. This can be confusing because it is contrary to
  306. normal practice.
  307.  
  308. If you use Selector or Input in a batch file that will be run from inside
  309. of an application program, you may find that the environment has shrunk
  310. to a size that just barely large enough to hold the amount of stuff already
  311. in it. To cure this problem, create the environment variable before you run
  312. the application. You might even want to create a generic environment variable
  313. in your AutoExec.bat file, so that you'll always have it ready to go.
  314.  
  315.  
  316.  
  317.  
  318.