home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / HARDDISK / HD_TIPS.ZIP / HD-TIPS2.TXT < prev    next >
Encoding:
Text File  |  1985-04-15  |  4.6 KB  |  112 lines

  1.             Taking Advantage of Your PC's Hard Disk:
  2.                     Part II, DOS BATch Files
  3.  
  4.                           Barry Gordon
  5.                 New York Personal Computer, Inc.
  6.  
  7. DOS and BATch Files
  8.  
  9. Familiarity  with DOS is assumed.  However,  it is helpful to the 
  10. new user to include a paragraph or two on BATch files.   The  IBM 
  11. PC  and DOS work with three different kinds of program or command 
  12. files:   .EXE, .COM, and .BAT files.  (BASIC and BASICA work with 
  13. their own .BAS files,  but those are not relevant to the  present 
  14. discussion.)  The .EXE and .COM files give instructions to the PC 
  15. itself.  They are produced by assemblers, compilers, and linkers.  
  16. The .BAT or BATch files are instructions to DOS which you  create 
  17. for  your own convenience.   I will discuss a couple of  commands 
  18. that  you  may  find convenient in working on your  PC:  the  DOS 
  19. PROMPT command and the PATH command.
  20.  
  21. The DOS PROMPT Command
  22.  
  23. Just  as DOS keeps track of a default disk drive,  it  will  also 
  24. keep  track of each drive's current directory (the directory  you 
  25. are working in).  Most often,  this directory is the one you tell 
  26. DOS to assume and use when no other is specified.  The DOS prompt 
  27. always  has  indicated  the default disk drive  followed  by  the 
  28. greater-than symbol:   A>  which works well for diskette  drives.  
  29. With  a  hard disk,  you will want to know the directory you  are 
  30. working  in (the current directory) as well.   You can  customize 
  31. the  prompt  to show the current directory using the  DOS  PROMPT 
  32. command.   The command PROMPT $P$G tells DOS to display the  name 
  33. of  the  current  directory whenever the prompt appears  on  your 
  34. screen.  Other,  more elaborate,  prompt variations are possible, 
  35. but  $P$G  is  a useful  beginning.
  36.  
  37. The DOS PATH Command
  38.  
  39. The  actual program fetching is accomplished by means of the  DOS 
  40. PATH  command.   This  command tells DOS where to look  for  your 
  41. programs (the executable files) when they are not in the  current 
  42. directory.  The overall scheme begins to take shape:  you work in 
  43. the (current) directory containing your data files, and DOS looks 
  44. for  the programs you need (in priority sequence) in  other  sub-
  45. directories.   Thus,  your PATH command might look something like 
  46. this:
  47.  
  48.  PATH C:\anyname1;C:\anyname2;C:\any3
  49.  
  50. The  PATH  command should contain the full specification of  each 
  51. sub-directory,  including the drive designation.   This keeps the 
  52. search path valid even if you should decide to make,  say,  drive 
  53. A:  the default drive temporarily. 
  54. Since the root directory is not named,  it is not included in the 
  55. PATH command. 
  56.  
  57. Of  course,   having  to  enter  all  of  this  PROMPT  and  PATH 
  58. information each time you turn on your PC can become a  nuisance.  
  59. The proper way to handle this is to create special BATch files in 
  60. the root directory that store and execute your commands. 
  61.  
  62. Creating BATch Files
  63.  
  64. The  most  direct  way  to create .BAT files is to  use  the  DOS 
  65. ability to COPY a file directly from the PC keyboard into a  disk 
  66. file:
  67.  
  68.          COPY CON filename.BAT
  69.  
  70. where  CON  is  the DOS name for  the  keyboard,  and  "filename" 
  71. represents  the name you wish to give your new BATch  file.   You 
  72. enter  your  file  contents,  line by line,  ending with  a  line 
  73. containing ^Z (Control-Z),  which can be entered by pressing  the 
  74. Function Key 6 (F6).  As an alternative (though I don't recommend 
  75. it)  you could learn to use EDLIN,  a minimal file editor,  whose 
  76. chief  virtue  is its automatic inclusion with the  DOS  package.  
  77. For  serious  work of this kind,  a good file editor is  a  great 
  78. help.  The IBM Personal Editor is one of the very best. 
  79.  
  80. The AUTOEXEC and SETPATH BATch Files
  81.  
  82. The  AUTOEXEC.BAT  file is executed only at startup  (unless  you 
  83. specifically enter it),  and contains those commands you wish  to 
  84. enter for your convenience in operating your PC.
  85.  
  86. A simple version of an AUTOEXEC.BAT file might look like this:
  87.  
  88. DATE
  89. TIME
  90. PROMPT $P$G
  91. PATH C:\anyname1;C:\anyname2;C:\any3
  92.  
  93. The  first  thing you may want to do is to move the PATH  command 
  94. from  the  AUTOEXEC.BAT  file and put it in its  own  BATch  file 
  95. called SETPATH.BAT. The AUTOEXEC.BAT would have these four lines:
  96.  
  97. DATE
  98. TIME
  99. PROMPT $P$G
  100. SETPATH
  101.  
  102. Your SETPATH.BAT file would look like this:
  103.  
  104. PATH C:\anyname1;C:\anyname2;C:\any3
  105.  
  106. Putting the PATH command in the SETPATH.BAT file lets you  modify 
  107. your  program search path any time you wish,  and then restore it 
  108. by  getting  into  the root directory and  entering  the  SETPATH 
  109. command. 
  110.  
  111. ath any time you wish,  and then restore it 
  112. by  getting  i