home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / HILFEN / 4DOS / 4TNT / AUTOEXEC.DOC < prev    next >
Text File  |  1993-12-01  |  6KB  |  215 lines

  1. This is an extract of my autoexec.bat file.  It shows a number of little 
  2. tricks to help manage your configuration and to maintain drive letter
  3. independence.  This one is IDENTICAL on my hard disk and my boot diskettes.
  4.  
  5. In a multi-machine site, this example could be the basis of an autoexec
  6. which is independent of any particular system configuration and is
  7. generically usable on all machines at a given site.
  8.  
  9.       Debugging aids
  10. @echo off
  11. rem pause
  12.  
  13.       Find the boot drive and the "DRIVERS" directory where I keep all my
  14.       TSRs.  Keeping them in environment variables eliminates a lot of
  15.       hard coding later.
  16.  
  17. set bootd=%[_boot]:
  18. set drp=%bootd%\DRIVERS\
  19.  
  20.       Call a couple of processes which are tad long for in-line code.
  21.       The first one figures out the letter of my ramdisk.  The second
  22.       sets my CDPATH down all my hard drives for drive letter indpendence
  23.       later.
  24.  
  25. gosub setramd
  26. gosub cdpath
  27.  
  28.       Vary the size of my disk cache based on the amount of EMS remaining.
  29.       The maximum is 2048K no matter how much EMS is left.  If there isn't
  30.       at least 512K left, disk caching is not used.
  31.  
  32. set csize=%@eval[%@ems[k]-512]
  33. if %csize gt 2048 set csize=2048
  34.  if %csize gt 512 %drp%loadhi  %drp%adcache -w0.2 -e%csize
  35. unset csize
  36.  
  37.       Set buffers, files, and fcbs.  Note the use of @name to get the 
  38.       major part of the DOS version.  It works because @name is just
  39.       a string parser, not a file manipulator, so "5.0" can be string
  40.       which is not necessarily a file name.  The @int function could
  41.       have been used instead, but @int was added late in the beta 
  42.       cycle, while _dosver was introduced early.
  43.  
  44. if %@name[%_dosver] lt 5 %drp%loadhi  %drp%buffers +3
  45. %drp%loadhi  %drp%files +80
  46. %drp%loadhi  %drp%fcbs +20,2
  47.  
  48.       Another call to a piece I'd rather keep separate instead of in-line.
  49. gosub uvsetup
  50.  
  51.       Finish loading the rest of the TSRs:
  52. %drp%loadhi  %drp%uvreset
  53. %drp%loadhi  %drp%4dos24h
  54. %drp%loadhi  c:\dos\mode lpt1,,b 
  55. %drp%loadhi  %drp%dmp /NV /G+ /MXP /D%ramd%
  56. %drp%loadhi  %drp%kstack.com
  57. %drp%loadhi  %bootd%\dos\trakball dos
  58.  
  59.       Switch to BTM mode now that all TSRs are loaded.
  60. loadbtm on
  61.  
  62.       Switch to my ramdisk
  63. %ramd%
  64.       Copy all the stuff to ramdisk that I want fast repeat access to.
  65. copy %bootd%\ramdisk\*.* %ramd% >& NUL
  66.  
  67.       Extract the path portion of comspec for future use.  Again, the
  68.       4DOS @path function is just a parser.
  69.  
  70. set compath=%@path[%comspec%]
  71.  
  72.       Because I've been a beta tester since the 3.0 days, I have some
  73.       version dependencies built in to facilitate switching back and 
  74.       forth between 3.x and 4.x.  This stuff shouldn't be necessary
  75.       for normal use, but you never know.
  76.  
  77. iff "%_4ver" ne "" then
  78.  
  79.      Copy 4DOS.COM to the ramdisk for fast shelling and switch COMSPEC.
  80.  
  81.  copy %compath%\copylib\*.* %ramd% >& NUL
  82.  set comspec=%ramd%\4DOS.COM
  83. endiff
  84.  
  85.  
  86.      I've been doing some ANSI clone beta testing, too, so there's a
  87.      switch on whether the ANSI driver happens to be loaded this time.
  88.  
  89. iff %_ansi == 0 then
  90.  prompt $P$g
  91. else
  92.  prompt $e[37;44m$P$g
  93. endiff
  94.  
  95.     Set a bunch of environment variables for various utilities.
  96.  
  97. set temp4dos=%ramd%
  98. set temp=%ramd%
  99. set tmp=%ramd%
  100. set pktmp=%ramd%
  101.  
  102.     Here's the first way I tested for version 3.x versus 4.x.  The _4ver
  103.     variable wasn't available in early beta tests.  This one uses the fact
  104.     that only 3.x and below have 4DOSn.EXE files.
  105.  
  106. iff exist %compath%4dos286.exe then
  107.  path %ramd%\;%bootd%\dos
  108. else
  109.  path %ramd%\;.;%bootd%\dos
  110. endiff
  111.  
  112.     Note (above) the very short PATH; especially the "else" case for 4DOS
  113.     4.0 which causes it to look on the ramdisk first for fastest possible
  114.     loading of the most commonly used utilities.
  115.  
  116. if "%_4ver" eq "" set 4dshell=/u /s:b%ramd%\ /e+256u
  117.  
  118. unalias *
  119.  
  120.     Switching alias loads depending upon the DOS version.  I used this
  121.     while being noncomittal about my 5.0 upgrade.
  122.  
  123. iff %@name[%_dosver] ge 5 then
  124.   alias /R %compath%aliases.500
  125.  else
  126.   alias /R %compath%aliases
  127. endiff
  128.  
  129. rem toggle n > NUL
  130. fastatkb 00
  131. unset compath
  132.  
  133.     Start the non-resident screen saver if I don't hit a key within 15
  134.     seconds of boot up.
  135.  
  136. inkey /W15 Are you there? %%x
  137.  (Don't waste the keystroke -- stack it for the prompt.)
  138. iff "%x" ne "" then
  139.  keystack "%x"
  140.  unset x
  141.  goto exit
  142. else
  143.  dazzle
  144.  goto exit
  145. endiff
  146.  
  147. goto exit
  148. :exit
  149. quit
  150. rem
  151. rem **********************************************************************
  152. rem *                     COMMON SUBROUTINES                             *
  153. rem **********************************************************************
  154. rem
  155. rem                        SET UP ULTRAVISION
  156. rem
  157. :uvsetup
  158. %drp%loadhi  g:\uv\uv.com
  159. %drp%loadhi  g:\uv\prtsc.com
  160. set uv=%ramd%
  161. return
  162. rem
  163. rem                     FIND RAMDISK AND SETRAMD
  164. rem
  165.  
  166.     This subroutine works by going backward through the alphabet until
  167.     it finds the first (highest lettered) logical drive which is not
  168.     a network drive, is not a removable drive (I have a Bernoulli which
  169.     may or may not have its driver loaded), and is ready.  That one is
  170.     the ramdisk.  If my ramdisk driver is not loaded for some reason,
  171.     the highest lettered hard drive will be substituted automatically.
  172.  
  173. :setramd
  174. set work=ZYXWVUTSRQPONMLKJIHGFEDC
  175. set count=0
  176. :ramdloop
  177. set foo=%@substr[%work,%count,1]:
  178. iff %@ready[%foo] == 1 .and. %@removable[%foo] == 0 .and. %@remote[%foo] == 0 then
  179.   set ramd=%foo
  180.   unset work count foo
  181.   goto ramdexit
  182.  else
  183.   set count=%@eval[%count+1]
  184. endiff
  185. iff %count lt 24 then 
  186.  goto ramdloop
  187. else
  188.  set ramd=%_boot\ramdisk
  189.  unset count work foo
  190.  goto ramdexit
  191. endiff
  192. :ramdexit
  193. return
  194.  
  195. rem
  196. rem                           SET CDPATH
  197. rem
  198.     This subroutine builds the CDPATH variable for all non-diskette disks
  199.     in alphabetical order.  CDPATH is the foundation of drive letter
  200.     independence demonstrated in other examples.
  201.  
  202. :cdpath
  203. set work=CDEFGHIJKLMNOPQRSTUVWXYZ
  204. set count=1
  205. set cdpath=C:\
  206. :cdloop
  207. set d=%@substr[%work,%count,1]:
  208. if %d gt %[_lastdisk]: goto cdexit
  209. if %@eval[%@ready[%d]+%@removable[%d]] gt 0 set cdpath=%[cdpath];%d\
  210. set count=%@eval[%count+1]
  211. goto cdloop
  212. :cdexit
  213. unset work count d
  214. return
  215.