MS DOS ".BAT" CODE


o The following is a simple BAT file that when run will show
  some good examples of DOS v6.21 available options (NOT WIN95 NOR NT DOS)
o ANSI.SYS must be running.
=======================================================
@ECHO OFF
GOTO bypassem
#d# Author: Randy Risher     Date: 06/30/93
#d#
#d# This represents a "self documenting" feature. You can extract
#d# JUST the lines with "#d#" when at the dos prompt via
#d#       FIND/I "#D#" THISFILE.BAT    (DOS/WIN)
#d#       FINDSTR/I "#D#" THISFILE.BAT (NT)
#d# (Other REM will NOT appear)
#d# FOR THE ACTUAL CODE FOLLOWING:
#d# o The CLS clears the screen
#d# o The E C H O. displays a blank line
#d# o The "echo (small circle character)" causes a BEEP. It was
#d#   inserted via WordPerfect using the "ctrl-G" combination, then
#d#   "Ctrl-F5" to save as a DOS file.
#d# o The first 2 IF statements enable a HELP. The check on variable
#d#   number 0 is if the command and the switch were together
#d#   (NO SPACE)
#d# o The 1st check on variable 1 is for if there was a space between
#d#   the command and the switch
#d# o The 2nd variable 1 check is if NO variable was given
#d# o The 3rd variable 1 check controls what to do if the file is NOT
#d#   found
#d# o The PAUSE causes a prompt to appear
#d# o Paragraph names are CaSe SeNsItIvE, so if the GOTO name
#d#   is UPPERCASE, so MUST the :NAME entry.
#d# o Paragraph names max is 8 digits with truncation after the 8th digit
#d# ----------------------------------------------------------------------------------------------------
:bypassem
CLS
ECHO         o This is an EXAMPLE batch file
ECHO.
ECHO         o To get self documentation, enter
ECHO                FIND/I "#d#" %0     (if DOS or WIN)
ECHO                FINDSTR/I "#d#" %0  (if NT)
ECHO.
ECHO         o To exit at any time press "Ctrl" and "C" together
ECHO.
ECHO         o The NEXT two lines enable a doslike HELP switch
ECHO         o The line AFTER senses if a parameter was passed
PAUSE
IF "%1"=="/?" GOTO helpem
IF %1.==. GOTO novar
IF NOT EXIST %1 GOTO nofile
GOTO doem

:novar
ECHO.
ECHO.
ECHO o
ECHO                   ERROR: you GOTTA supply a file
ECHO            o Sample message for running without a variable
ECHO            o Try re-running with THIS files name (%0)
ECHO                THEN AGAIN with a filename that does NOT exist
PAUSE
GOTO endem

:nofile
ECHO.
ECHO.
ECHO o
ECHO            ERROR: file %1 was NOT found
ECHO            (sample error message)
ECHO . . . this allows a tailored PAUSE message
PAUSE>NUL:
GOTO endem

:helpem
ECHO.
ECHO.
ECHO                   THIS IS THE   H E L P    AREA
ECHO                   GOT FROM THE /? PARAMETER
PAUSE
GOTOendem

:doem
ECHO.
ECHO.
ECHO                 THESE LINES WOULD BE THE ACTUAL
ECHO                 FUNCTION THIS BATCH FILE WAS TO 
ECHO                 PERFORM
ECHO.
PAUSE

:endem
GOTO bypend
#d# Show ANSI settings
#d#
#d# o First line sets this file to NOT display lines as they process
#d# o FYI:
#d#   TEXT:   30 blk, 31 red, 32 gn, 33 yl, 34 bl, 35 mag, 36 cya, 37 wh
#d#   SCREEN: 40 blk, 41 red, 42 gn, 43 yl, 44 bl, 45 mag, 46 cya, 47 wh
#d#   MISC: 0 wh on blk, 1 bold, 5 blink, 7 inverse, 8 invisible
#d# o The ESCAPE character (small left pointing arrow) was created
#d#   via dos 6 EDIT command pressing "Ctrl" and "P" together then
#d#   pressing "Esc" button
#d# -------------------------------------------------------------------------------------------------
:bypend
ECHO             S E T T I N G   S C R E E N   C O L O R S
ECHO.
ECHO   TEXT;    30 blk, 31 rd, 32 gr, 33 yl, 34 bl, 35 ma, 36 cy, 37 wh
ECHO   SCREEN: 40 blk, 41 rd, 42 gr, 43 yl, 44 bl, 45 ma, 46 cy, 47 wh
ECHO   MISC:     0 wh on blk, 1 bold, 5 blink, 7 inverse, 8 invisible
ECHO   =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ECHO   IF YOU DO NOT SEE COLOR CHANGES, YOU MUST ADD
ECHO   THE NEXT LINE TO YOUR CONFIG.SYS FILE (DOS or WIN)
ECHO           DEVICE=C:\DOS\ANSI.SYS
ECHO           DEVICE=%windir%SYSTEM32\ansi.sys
ECHO   THEN REBOOT AND RERUN THIS HERE FILE
ECHO   =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ECHO   NEXT line is from setting to   hi-red   ON blu <-[0;31;44;1m
ECHO   NEXT line is from setting to   hi-red   ON red <-[0;31;41;1m
ECHO   NEXT line is from setting to   hi-grn   ON wht <-[0;32;47;1m
ECHO   NEXT line is from setting to   NORMAL          <-[0m
ECHO   NEXT line is from setting to   INVISIBLE       <-[8m
ECHO   CANT READ THIS ...setting to   red      ON blu <-[0;31;44m
ECHO   NEXT line is from setting to   NORMAL          <-[0;1m
ECHO   NEXT line is from setting to   hi-blk   ON blk <-[0;30;40;1m
ECHO   NEXT line is from setting to   NORMAL          <-[0;1m
ECHO   NEXT line is from setting to   blk      ON blk <-[0;30;40m
ECHO   NEXT line is from setting to   hi-red   ON blu <-[0;31;44;1m
ECHO   NEXT line is from setting to   NORMAL          <-[0;1m

Return to Randys HOME PAGE
Created Jun 30, 1993 ~ Updated Jul 22, 2003
© 1996 R.D.RISHER