Batch File Utility

This is a little utility that provides some useful functions to batch
files:

Use: BATUTIL cmd [args] [options]

cmd:    CFPATH file...                  = Check File(s) in PATH
          /1=don't scan current  /2=cd to first file
        COUNT text...                   = Count arguments
        HOME                            = Home cursor
        KEY [allowed...]                = Wait for key
        MATCH keyword list...           = Match keywords
        MENU item...                    = Interactive menu
        PRINT text...                   = Display text
        TKEY                            = Test for key
        WAIT ms [allowed-keys...]       = Wait

opts:   /C      = Clear screen
        /D      = Drop 1st character from 1st argument
        /F      = accept First (allow ambiguous)
        /U      = convert all args to Upper case
        /V      = Verbose output
        C=bf    = Color (background/Foreground)
        X=x,y   = set X/Y position


CFPATH file...

  Checks that each file specified occurs in the current directory or
  along the command path (as defined in PATH environment variable).

  If 'file' does not contain an extension, then any of 'file.BAT',
  'file.COM' or 'file.EXE' will be accepted.

  Exit code is the number of files NOT found in the path (0 means all
  files were found).

  /1 = do not check current directory (must exist in PATH)
  /2 = CD to directory containing the first file in the list


COUNT text...

  Exits with an ERRORLEVEL equal to the number of arguments - a useful
  way to count batch file operands.


HOME

  Homes the cursor to the upper left hand corner of the screen.

  Use 'X=' to move the cursor to a different position.



KEY [allowed...]

  Wait for a key to be pressed on the keyboard, and returns the key code
  as the ERRORLEVEL.

  If [allowed...] keycodes are specified, then only those keys will be
  accepted (use: 'BATUTIL /V KEY' to see keycodes for any key pressed).

  '/U' option can be used to force ASCII character keys to be returned
  in UPPER CASE.


MATCH keyword list...

  Compares the keyword to each word from the list, and returns the
  index (0...) in ERRORLEVEL if the keyword unambuguously matches
  the beginning characters of a word from the list. If no match is
  found, 255 is returned.

  Use '/U' to perform case-insensitive matches.
  Use '/D' to prefix keyword with a character to insure that it always
  takes an argument place, even if nul. eg: BATUTIL /V MA .%1 ONE TWO THREE


MENU item...

  Offers an interactive menu of items, allowing any item to be selected
  with the Up/Down keys and pressing ENTER - ESC can be used to abort.
  Returns with ERRORLEVEL equal to the menu selection (1...) or 0 if
  the menu was aborted.

  Use 'C=' to set the display colors for the menu.
  Use 'X=' to set the X/Y position (default = centered on screen)


PRINT text...

  Print the text words on the screen.
  Each word of text may begin with:
   ~S       = Do not print preceeding space
   ~N       = Send NEWLINE
   ~Rn;     = Repeat the text this many times
   ~[-][0]n = Format in field 'n' wide.
      '-'=Left justify (otherwise right)
      Leading '0' means fill with '0' (otherwise ' ')
  You can use multiple '~' prefixes on one word of text, however
  once text is encountered, no more '~' prefixes will be processed
  until a space has occured.


TKEY

  Test for keypress.
  Returns with ERRORLEVEL set to the keycode.
  (use: 'BATUTIL /V KEY' to see keycodes for any key pressed).

  '/U' option can be used to force ASCII character keys to be returned
  in UPPER CASE.


WAIT

  Pauses for the specified number of milliseconds.
  If additional arguments are specified, they are keycodes for keys
  which will be allowed to prematurely terminate the wait.

  Return ERRORLEVEL of 0 if no key pressed, otherwise the keycode
  of the interrupting key.


Options:

 /C = Clear the screen

   Can be used to clear the screen before any other command, or by itself
   to perform a clear-screen only.

   Use 'C=' to set the forground/background colors of the new screen.
   Use 'X=' to position the cursor following the clear.


 /D = Drop first character from first argument

  Used mainly with MATCH to handle the case where the keyword to be
  tested has not been supplied to the batch file - without this feature
  the first list word would be taken as the keyword. To prevent this,
  place any character in front of the '%n' batch parameter in the keyword
  position, and use '/D' to logically remove it.


/F = accept First match

  Allows MATCH to accept ambiguous matches, returning the index of the
  first list word that qualifies.


/U = force arguments to Upper case

  Used mainly to allow case-insensitive MATCH.


/V = Verbose output

  Displays the ERRORLEVEL being returned.


/1 = These are options which pertain only to specific functions. See
/2 = the function descriptions for meaning.

C=bf = set background/forground Color

  Used with /C and MENU to set the screen color which will be used.
  Argument is a 2 HEX digits corresponding to the DOS background and
  forground colors to be used.


X=x,y

  Set the X and Y cursor position.
  Used with HOME, MENU and /C to position the cursor.


Dunfield Development Services (DDS) offers software and firmware
development services specializing in systems and embedded applications.
For more information, visit: http://www.dunfield.com
