home *** CD-ROM | disk | FTP | other *** search
/ Colossal Cookbook / ColossalCookbook.cdr / menu / batprogs.doc next >
Text File  |  1987-06-23  |  7KB  |  226 lines

  1.  
  2.                             Batch File Utilities
  3.                      Copyright Psuedonym Software 1984
  4.                            Written by T. P. Devitt
  5.  
  6.  
  7.  
  8. Introduction:
  9. -------------
  10.  
  11. With the advent of the IBM PC, home computerists were given access to a
  12. facility that had previously been reserved for mainframe computers.  On large
  13. IBM computers that facility is known as IBM Job Control Language, or JCL for
  14. short.  On the PC, that concept was implemented in the form of the PC Dos Batch
  15. commands.  As powerful as these batch commands may be, they do lack two very
  16. important features:
  17.  
  18.        1)  The ability to accept operator input and
  19.        2)  The ability to perform branching within the batch file,
  20.            based on operator input
  21.  
  22. Of course, true variables would be nice........
  23.  
  24. The utilities included in this package help to provide some of these missing
  25. features.
  26.  
  27.  
  28. Limited license:
  29. ----------------
  30.  
  31. With a very few exceptions, you are free to use, copy and share these programs
  32. with others, provided the following conditions are met:
  33.  
  34.     1.  The programs included in this package must be distributed
  35.         as a complete package, together with this documentation,
  36.         in unmodified form.  The programs included in this package
  37.         are: Beep.com, Choose.com, Input.com, Inputb.com, Read.com,
  38.         Turn.com and this file, batprogs.doc.
  39.  
  40.     2.  No fee may be charged for this package, except for the
  41.         reasonable value of the diskette on which it is provided,
  42.         without the prior written consent of Psuedonym Software.
  43.  
  44.  
  45. Commercial interruption:
  46. ------------------------
  47.  
  48. This package is distributed as user-supported software.  If you find
  49. these programs useful, a donation ($10 suggested) is requested.  Those
  50. who send a donation will be placed on a mailing list and will be
  51. informed of all future revisions.  In addition, registered users may
  52. obtain support by either writing Psuedonym Software, or by contacting
  53. our bulletin board at 818-441-1904.
  54.  
  55.  
  56. Disclaimer:
  57. -----------
  58.  
  59. The programs in this package are distributed on an "as is" basis. Neither
  60. Psuedonym Software, or any of its employees, assume any responsiblity for loss
  61. or damages, either real or imagined, arrising from the use of of these
  62. programs, or the lack thereof.
  63.  
  64. While every effort has been made to ensure that these programs contain no bugs,
  65. and to correct any that may be discovered, we expressly deny any legal
  66. responsibility to do so.
  67.  
  68.  
  69. Input.com:
  70. ----------
  71.  
  72. Input.com allows a batch file to accept a yes or no answer from the operator.
  73. The prompt string is entered as a parameter of the input command, to which  '
  74. (Y/N)' is automatically appended.
  75.  
  76. A response of 'Y' or 'y' returns an error code of 0.  Any other response
  77. returns an error code of 1.
  78.  
  79. Branching within a batch file can be accomplished by checking the error return
  80. code through the ERRORLEVEL batch sub-command.  (See the IBM Dos manual for a
  81. complete discussion of the ERRORLEVEL command.)
  82.  
  83.  
  84. Syntax:     INPUT <your prompt goes here>
  85.  
  86. Example:    INPUT Do you wish to backup your files now ?
  87.  
  88. Result:     Do you wish to backup your files now ? (Y/N) _
  89.  
  90.  
  91. Input.com batch file example:
  92.  
  93. ECHO OFF
  94. CLS
  95. INPUT Do you want to go to work today ?
  96. IF ERRORLEVEL 1 GOTO NOWORK
  97. ....work....                      |  Optional code
  98. ....work....                      |
  99. GOTO END
  100. :NOWORK
  101. ....play....                      |  Optional code
  102. ....play....                      |
  103. :END
  104. CLS
  105. ECHO TH-TH-THAT'S ALL, FOLKS !!!!
  106.  
  107.  
  108. Inputb.com:
  109. -----------
  110.  
  111. Inputb.com is identical to Input.com, except that the console beeps when when
  112. the prompt message is printed.
  113.  
  114.  
  115. Choose.com:
  116. -----------
  117.  
  118. Choose.com is a generalized version of Input.com.  It allows you to operator to
  119. choose an item from a menu of choices. operator to choose an item from a menu
  120. of choices.
  121.  
  122. Syntax:   CHOOSE <your text string prompt goes here>
  123.  
  124. Example:  CHOOSE Select an item (1 - 8) :
  125.  
  126.  
  127. Programming considerations:
  128.  
  129. Menu choices may be alphabetical or numerical, but should start with either 'A'
  130. or '1' for best results.  Choose will return an error code which is the index
  131. of the menu item selected.  For example, menu item A or 1 will return error
  132. code 1, B or 2 will return 2, etc.  The error return code can be examined from
  133. within a batch file by using the PC DOS BATCH command 'ERRORLEVEL'.  Based on
  134. the results of ERRORLEVEL, you can control branching to various sections of
  135. your batch file.
  136.  
  137.  
  138. Constraints:
  139.  
  140. If you use a numerical menu, you are limited to 9 menu choices ( 1 - 9). An
  141. alpha menu theoretically allows you 32 choices, but after 'Z' things might tend
  142. to get a little confusing.  Lowercase letters are converted to uppercase, so
  143. 'A' and 'a' will produce the same result.
  144.  
  145. Batch file example:
  146.  
  147. ECHO OFF
  148. CLS
  149. READ README.DAT                     (See READ command, following)
  150. CHOOSE ENTER YOUR CHOICE (A - H):
  151. CLS
  152. IF ERRORLEVEL 8 GOTO END
  153. IF ERRORLEVEL 7 READ TURN.DOC
  154. IF ERRORLEVEL 6 READ READ.DOC
  155. IF ERRORLEVEL 5 READ PLEASE.DOC
  156. IF ERRORLEVEL 4 READ INPUTB.DOC
  157. IF ERRORLEVEL 3 READ INPUT.DOC
  158. IF ERRORLEVEL 2 READ CHOOSE.DOC
  159. IF ERRORLEVEL 1 READ BEEP.DOC
  160. PAUSE
  161. %0                                (causes re-execution of batch file)
  162. :END
  163. CLS
  164.  
  165. You may have noticed that the ERRORLEVEL is checked on a greater to lesser
  166. basis.  This is because the ERRORLEVEL command performs its compare on a
  167. equal-to-or-greater-than basis.
  168.  
  169.  
  170. Turn.com:
  171. ---------
  172.  
  173. Turn.com turns on or off either caps lock or num lock from within a
  174. batch file.
  175.  
  176. Syntax:      TURN caps/num  on/off
  177.  
  178. Example:     Turn caps off num on
  179.              Turn num on
  180.              Turn num on caps on
  181.  
  182. Constraints:
  183.  
  184. Only the toggle key you specifically reference will be turned on.  For example,
  185. TURN CAPS ON will result in caps lock being turned on and num lock being turned
  186. off.  TURN CAPS ON is therefore equivalent to TURN CAPS ON NUM OFF.  If you
  187. want a specific key turned on, you MUST specify that key as being ON.  If you
  188. do not, it will be turned off.
  189.  
  190. This program does not affect either the SCROLL LOCK or INSERT key.
  191.  
  192.  
  193. Beep.com:
  194. ---------
  195.  
  196. Beep.com may be inserted into any batch file to produce a tone which will
  197. signal the operator that some event has occurred.  For instance, you might want
  198. to inform the operator that a backup procedure has finished its execution.
  199.  
  200. Syntax:    Beep
  201.  
  202.  
  203. Read.com:
  204. ---------
  205.  
  206. Read.com outputs the contents of a text file to the console one screen at a
  207. time.  It is designed to work best with the output of text processors, such as
  208. EDLIN of SPFPC.  Each screen line should be terminated by a carriage return and
  209. a line feed.  Read.com will work with the output from most wordprocessors, but
  210. because many of them do not use the above convention, screen formatting may be
  211. unusual.
  212.  
  213. Read.com fully supports path (subdirectory) names.  If the file you wish to
  214. read is on the default drive, the drive specifier is optional.
  215.  
  216. Syntax:     READ [d:][\path\]filename.ext
  217.  
  218. Examples:   READ readme.doc
  219.             READ c:\mydir\myfile.doc
  220.             READ \yourdir\yourfile.doc
  221.  
  222.  
  223. Psuedonym Software
  224. 161 S. Sunnyslope Ave.
  225. Pasadena, Ca.  91107
  226.