home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / batch / sputils.zip / DEMO1.BAT < prev    next >
DOS Batch File  |  1991-01-08  |  16KB  |  462 lines

  1. echo off
  2. rem   ------------------------------------------------------
  3. rem                       batch file 1
  4. rem
  5. rem                (C) speter software, January 1991.
  6. rem   ------------------------------------------------------
  7. rem    this batch file will:
  8. rem      1  demonstrate the function of the batch utilities;
  9. rem      2  show the documentation for the utilities;
  10. rem      3  show demonstrations of the utilities.
  11. rem   ------------------------------------------------------
  12. rem   This section sets up the DOS environment variables used in this
  13. rem   batch file.
  14. rem set (ANSI) text colour to white on blue
  15. echo H1H
  16. hasmouse
  17. if errorlevel 1 set _um=T
  18. rem   suppress text cursor if mouse is available:
  19. if %_um%==T set _t=/t
  20. rem   chose which "more" command to use:
  21. if %_um%==T set _m=mormouse /c
  22. if not %_um%==T set _m=more
  23. rem   choose which prompt to use:
  24. if %_um%==T set _p=/t press a button to continue
  25. if not %_um%==T set _p=press any key to continue
  26.  
  27. rem --------------------------------------------------
  28. rem page 0 (general intro)
  29. rem --------------------------------------------------
  30. copyrect demo-p0.scr 0 1 1
  31. askmouse 51 23 52 23 Xx* 51 23 /m
  32. if errorlevel 203 goto ok
  33. if errorlevel 202 goto end
  34. rem --------------------------------------------------
  35. rem page 1 (provides short descriptions of utilities)
  36. rem --------------------------------------------------
  37. copyrect demo-p1.scr 0 1 1
  38. copyrect 0 37 2 80 25 1 37 2
  39. :in-p1
  40. askmouse 26 3 36 22 q 26 11 %_t%
  41. rem ---- mouse (or text cursor) entry
  42. if errorlevel 122 goto end
  43. if errorlevel 121 goto demos
  44. if errorlevel 120 goto docs
  45. if errorlevel 119 goto in-p1
  46. if errorlevel 118 BoxText /s1 s 37 17 113 Removes TABs from an file, replacing!them with SPACEs, writes the result to!a file.
  47. if errorlevel 117 BoxText /s1 s 37 16 113 Deletes a word (or series of) from a!file, the result is written to another!file.
  48. if errorlevel 116 BoxText /s1 s 37 15 113 Deletes any characters within a spec. !column range, writes the result to!a file.
  49. if errorlevel 115 BoxText /s1 s 37 14 113 Displays all (255) text attributes -  !foreground, background colour &!blinking.
  50. if errorlevel 114 BoxText /s1 s 37 13 113 Reports the length of the longest line!of a specified text file & the no.!of lines.
  51. if errorlevel 113 BoxText /s1 s 37 12 113 Show the Disk Usage - total bytes used!in the spec. directory and sub-dirs.
  52. if errorlevel 112 BoxText /s1 s 37 11 113 Simple decimal to binary (and Hex)   !converter (numbers less than 65768).
  53. if errorlevel 111 goto in-p1
  54. if errorlevel 110 BoxText /s1 s 37  9 113 Similar to DOS "more" command, except !uses mouse-button press INSTEAD of a!keypress.
  55. if errorlevel 109 BoxText /s1 s 37  8 113 Used in batch files to determine mouse!availability, sets the DOS errorlevel.
  56. if errorlevel 108 BoxText /s1 s 37  7 113 Display a message using a specified   !text attribute.
  57. if errorlevel 107 BoxText /s1 s 37  6 113 Copy part (or all) of a text screen!to/from disk & other (nonvisible) text!screens.
  58. if errorlevel 106 BoxText /s1 s 37  5 113 Wait for a mouse-button or key press;!optionally display a message before   !waiting.
  59. if errorlevel 105 BoxText /s1 s 37  4 113 Display a message inside a box using a!specified text attribute.!* *  used here  * *
  60. if errorlevel 104 BoxText /s1 s 37  3 113 Display a box using a specified text  !attribute, by default clears inside!the box.
  61. if errorlevel 103 BoxText /s1 s 37  2 113 For selections in batch files, uses a !mouse, cursor keys &/or specified!characters.
  62. BoxText /s1 s 73 23 103 OK
  63. askmouse 75 24 78 24 * 75 24 %_t%
  64. copyrect 1 37 2 80 25 0 37 2
  65. goto in-p1
  66. rem --------------------------------------------------
  67. rem page 2 (displays full documentation on utilities)
  68. rem --------------------------------------------------
  69. :docs
  70. copyrect 0 1 1 80 25 1 1 1      (copy display page 0 to display page 1)
  71. copyrect demo-p2.scr 2 1 1      (read 2nd page from file)
  72. :in-p2
  73. copyrect 2 1 1 80 25 0 1 1      (copy 2nd page to display page 0)
  74. askmouse 26 3 34 20 q 26 11 %_t%
  75. rem ---- mouse (or text cursor) entry
  76. if errorlevel 120 goto P2return
  77. if errorlevel 119 goto in-p2
  78. if errorlevel 118 %_m% < striptab.doc
  79. if errorlevel 117 %_m% < stripstr.doc
  80. if errorlevel 116 %_m% < stripcol.doc
  81. if errorlevel 115 %_m% < showattr.doc
  82. if errorlevel 114 %_m% < linelen.doc
  83. if errorlevel 113 %_m% < du.doc
  84. if errorlevel 112 %_m% < binary.doc
  85. if errorlevel 111 goto in-p2
  86. if errorlevel 110 %_m% < mormouse.doc
  87. if errorlevel 109 %_m% < hasmouse.doc
  88. if errorlevel 108 %_m% < dtext.doc
  89. if errorlevel 107 %_m% < copyrect.doc
  90. if errorlevel 106 %_m% < butnpres.doc
  91. if errorlevel 105 %_m% < boxtext.doc
  92. if errorlevel 104 %_m% < box.doc
  93. if errorlevel 103 %_m% < askmouse.doc
  94. BoxText /s1 s 73 23 103 OK
  95. askmouse 75 24 78 24 * 75 24 %_t%
  96. goto in-p2
  97. :P2return
  98. copyrect 2 1 1 30 1  1 1 1   ( rewrite portion that gets cleared by "cls" )
  99. copyrect 1 1 1 80 25 0 1 1   ( restore page 1 to display page 0 )
  100. goto in-p1
  101. rem --------------------------------------------------
  102. rem page 3 (gives demonstrations of the utilities)
  103. rem --------------------------------------------------
  104. :demos
  105. copyrect 0 1 1 80 25 1 1 1      (copy display page 0 to display page 1)
  106. copyrect demo-p3.scr 3 1 1      (read 3rd page from file)
  107. :in-p3
  108. copyrect 3 1 1 80 25 0 1 1      (copy 3rd page to display page 0)
  109. askmouse 26 3 34 20 q 26 11 %_t%
  110. rem ---- mouse (or text cursor) entry
  111. if errorlevel 120 goto P3return
  112. if errorlevel 119 goto in-p3
  113. if errorlevel 118 goto striptab
  114. if errorlevel 117 goto stripstr
  115. if errorlevel 116 goto stripcol
  116. if errorlevel 115 goto showattr
  117. if errorlevel 114 goto linelen
  118. if errorlevel 113 goto du
  119. if errorlevel 112 goto binary
  120. if errorlevel 111 goto in-p3
  121. if errorlevel 110 goto mormouse
  122. if errorlevel 109 goto hasmouse
  123. if errorlevel 108 goto dtext
  124. if errorlevel 107 goto copyrect
  125. if errorlevel 106 goto butnpres
  126. if errorlevel 105 goto boxtext
  127. if errorlevel 104 goto box
  128. if errorlevel 103 goto askmouse
  129. BoxText /s1 s 73 23 103 OK
  130. askmouse 75 24 78 24 * 75 24 %_t%
  131. goto in-p3
  132. :P3return
  133. copyrect 3 1 1 30 1  1 1 1   ( rewrite portion that gets cleared by "cls" )
  134. copyrect 1 1 1 80 25 0 1 1   ( restore page 1 to display page 0 )
  135. goto in-p1
  136. rem --------------------------------------------------------
  137. :striptab
  138. cls
  139. echo          STRIP-TABs
  140. echo  
  141. echo This demonstration will strip the tab characters from a file called TABS.TXT
  142. echo (supplied with the utilities);  the resulting text will then be displayed on
  143. echo the screen.
  144. echo  
  145. echo The command line used will be:
  146. echo  
  147. echo   STRIPTAB tabs.txt con
  148. echo  
  149. butnpres %_p%
  150. echo  
  151. STRIPTAB tabs.txt con
  152. BoxText /s1 s 73 23 103 OK
  153. askmouse 75 24 78 24 * 75 24 %_t%
  154. goto in-p3
  155. rem --------------------------------------------------------
  156. :stripstr
  157. cls
  158. echo          STRIP-STRING
  159. echo  
  160. echo This demonstration will strip the string "efghijk" from a file called
  161. echo LETTERS.TXT (supplied with the utilities);  the resulting text will then be
  162. echo displayed on the screen.
  163. echo  
  164. echo LETTERS.TXT contains the string "abcdefghijklmnopqrstuvwxyz" 5 times.
  165. echo  
  166. echo The command line used will be:
  167. echo  
  168. echo   STRIPSTR /sefghijk letters.txt con
  169. echo  
  170. butnpres %_p%
  171. echo  
  172. STRIPSTR /sefghijk letters.txt con
  173. BoxText /s1 s 73 23 103 OK
  174. askmouse 75 24 78 24 * 75 24 %_t%
  175. goto in-p3
  176. rem --------------------------------------------------------
  177. :stripcol
  178. cls
  179. echo  
  180. echo          STRIP COLUMN RANGE
  181. echo  
  182. echo This demonstration will strip all the characters between column 10 and column
  183. echo 20 from the file LETTERS.TXT (supplied with the utilities); the resulting text
  184. echo will then be displayed on the screen.
  185. echo  
  186. echo LETTERS.TXT contains the string "abcdefghijklmnopqrstuvwxyz" 5 times.
  187. echo                                         10*---------*20
  188. echo  
  189. echo the resulting text should be "abcdefghiuvwxyz" 5 times.
  190. echo  
  191. echo The command line used will be:
  192. echo  
  193. echo   STRIPCOL 10 20 letters.txt con
  194. echo  
  195. butnpres %_p%
  196. echo  
  197. STRIPCOL 10 20 letters.txt con
  198. BoxText /s1 s 73 23 103 OK
  199. askmouse 75 24 78 24 * 75 24 %_t%
  200. goto in-p3
  201. rem --------------------------------------------------------
  202. :showattr
  203. cls
  204. echo          SHOW TEXT ATTRIBUTES
  205. echo  
  206. echo This demonstration will simply execute the utility.
  207. echo  
  208. echo The command line used will be:
  209. echo  
  210. echo   SHOWATTR
  211. echo  
  212. butnpres %_p%
  213. echo  
  214. SHOWATTR
  215. BoxText /s1 s 73 23 103 OK
  216. askmouse 75 24 78 24 * 75 24 %_t%
  217. goto in-p3
  218. rem --------------------------------------------------------
  219. :linelen
  220. cls
  221. echo          FILE (longest) LINE LENGTH
  222. echo  
  223. echo This demonstration will execute the utility to determine the length of the
  224. echo longest line in the demonstration batch file.  The utility will also show the
  225. echo line number of the longest line and the total number of lines in the file.
  226. echo  
  227. echo The command line used will be:
  228. echo  
  229. echo   LINELEN DEMO1.BAT
  230. echo  
  231. butnpres %_p%
  232. echo  
  233. LINELEN DEMO1.BAT
  234. BoxText /s1 s 73 23 103 OK
  235. askmouse 75 24 78 24 * 75 24 %_t%
  236. goto in-p3
  237. rem --------------------------------------------------------
  238. :du
  239. cls
  240. echo          DISPLAY DISK USAGE FIGURES
  241. echo  
  242. echo This demonstration will execute the utility to display the total disk space
  243. echo taken up by the files in the current directory (and its sub-directories).
  244. echo  
  245. echo The command line used will be:
  246. echo  
  247. echo   DU
  248. echo  
  249. butnpres %_p%
  250. echo  
  251. DU
  252. BoxText /s1 s 73 23 103 OK
  253. askmouse 75 24 78 24 * 75 24 %_t%
  254. goto in-p3
  255. rem --------------------------------------------------------
  256. :binary
  257. cls
  258. echo          DECIMAL TO BINARY CONVERTER
  259. echo  
  260. echo This demonstration will simply execute the utility.  When prompted, type in
  261. echo a number between  0 to 65535, the utility will then display the binary (and
  262. echo HEX) equivalent of the number.
  263. echo  
  264. echo Enter the number  0  to exit the program.
  265. echo  
  266. echo The command line used will be:
  267. echo  
  268. echo   BINARY
  269. echo  
  270. butnpres %_p%
  271. echo  
  272. BINARY
  273. BoxText /s1 s 73 23 103 OK
  274. askmouse 75 24 78 24 * 75 24 %_t%
  275. goto in-p3
  276. rem --------------------------------------------------------
  277. :mormouse
  278. cls
  279. echo          MORE MOUSE
  280. echo  
  281. echo The more-mouse utility is used extensively throughout this demonstration.
  282. echo Here it will be used to display the contents of the file "mormouse.doc".
  283. echo  
  284. echo NOTE   /c   causes the screen to be cleared before the first page of the 
  285. echo             file is displayed.
  286. echo  
  287. echo The command used will be:
  288. echo  
  289. dtext 3 11 23 "mormouse /c < mormouse.doc"
  290. echo  
  291. echo  
  292. butnpres %_p%
  293. mormouse /c < mormouse.doc
  294. BoxText /s1 s 73 23 103 OK
  295. askmouse 75 24 78 24 * 75 24 %_t%
  296. goto in-p3
  297. rem --------------------------------------------------------
  298. :hasmouse
  299. cls
  300. echo          HAS MOUSE ?
  301. echo  
  302. echo This demonstration will execute the utility (which sets the DOS errorlevel),
  303. echo the errorlevel is then used to branch to the appropriate message.
  304. echo  
  305. echo An alternate way to use the errorlevel is to use it to set an DOS environment
  306. echo variable, which can then be checked numerous times inside a batch file.  This
  307. echo is how this batch file uses HASMOUSE.
  308. echo  
  309. echo The commands used will be:
  310. echo  
  311. echo   hasmouse
  312. echo   if errorlevel 1 goto mouseOK
  313. echo   if errorlevel 0 echo no mouse was found
  314. echo   goto h_m_end
  315. echo   :mouseOK
  316. echo   echo a mouse was found
  317. echo   :h_m_end
  318. echo  
  319. butnpres %_p%
  320. echo  
  321. echo  
  322. hasmouse
  323. if errorlevel 1 goto mouseOK
  324. if errorlevel 0 echo no mouse was found
  325. goto h_m_end
  326. :mouseOK
  327. echo a mouse was found
  328. :h_m_end
  329. BoxText /s1 s 73 23 103 OK
  330. askmouse 75 24 78 24 * 75 24 %_t%
  331. goto in-p3
  332. rem --------------------------------------------------------
  333. :dtext
  334. cls
  335. echo          DISPLAY A TEXT MESSAGE
  336. echo  
  337. echo This demonstration will execute the utility to display a blinking message
  338. echo "Hello All" on the display.
  339. echo  
  340. echo The command line used will be:
  341. echo  
  342. echo   DTEXT 30 15 187 "   Hello  All   "
  343. echo  
  344. butnpres %_p%
  345. echo  
  346. DTEXT 30 15 187 "   Hello  All   "
  347. BoxText /s1 s 73 23 103 OK
  348. askmouse 75 24 78 24 * 75 24 %_t%
  349. goto in-p3
  350. rem --------------------------------------------------------
  351. :copyrect
  352. cls
  353. echo          COPY (rectangular) SCREEN AREA
  354. echo  
  355. echo This demonstration will execute the utility to copy parts of this message
  356. echo around the screen.  This will, no doubt, make a fine mess all over the screen.
  357. echo  
  358. echo The commands used will be:
  359. echo  
  360. echo   COPYRECT 0  1 3  10 9  0 40 10
  361. echo   COPYRECT 0 41 3  78 7  0 10 17
  362. echo   COPYRECT 0  3 8  10 12 0 60 10
  363. echo   COPYRECT 0 31 3  63 4  0 31 20
  364. echo   COPYRECT 0 21 4  78 4  0 10 25
  365. echo  
  366. butnpres %_p%
  367. COPYRECT 0  1 3  10 9  0 40 10
  368. COPYRECT 0 41 3  78 7  0 10 17
  369. COPYRECT 0  3 8  10 12 0 60 10
  370. COPYRECT 0 31 3  63 4  0 31 20
  371. COPYRECT 0 21 4  78 4  0 10 25
  372. BoxText /s1 s 73 23 103 OK
  373. askmouse 75 24 78 24 * 75 24 %_t%
  374. goto in-p3
  375. rem --------------------------------------------------------
  376. :butnpres
  377. cls
  378. echo          BUTTON-PRESS
  379. echo  
  380. echo BUTTON-PRESS is functionally similar to the DOS "pause" command, it
  381. echo (optionally) displays a message, then waits until a mouse-button or key is
  382. echo pressed.
  383. echo  
  384. echo This demonstration will execute the utility to display a blinking message
  385. echo on the display, than wait for a keypress.
  386. echo  
  387. echo BUTNPRES is being used in this batch file whenever you see the message:
  388. echo      %_p%
  389. echo  
  390. echo The command line used will be:
  391. echo  
  392. echo   BUTNPRES 10 18 187 "   Hello  All   Press a mouse-button or key when ready:"
  393. echo  
  394. butnpres %_p%
  395. echo  
  396. BUTNPRES 10 18 187 "   Hello  All   Press a mouse-button or key when ready:"
  397. BoxText /s1 s 73 23 103 OK
  398. askmouse 75 24 78 24 * 75 24 %_t%
  399. goto in-p3
  400. rem --------------------------------------------------------
  401. :boxtext
  402. cls
  403. echo          DISPLAY A TEXT MESSAGE IN A BOX
  404. echo  
  405. echo This demonstration will execute the utility to display a blinking message
  406. echo "Hello All" on the display.
  407. echo  
  408. echo The command line used will be:
  409. echo  
  410. echo   BOXTEXT /s1 s 30 15 187 "   Hello  All   "
  411. echo  
  412. butnpres %_p%
  413. echo  
  414. BOXTEXT /s1 s 30 15 187 "   Hello  All   "
  415. BoxText /s1 s 73 23 103 OK
  416. askmouse 75 24 78 24 * 75 24 %_t%
  417. goto in-p3
  418. rem --------------------------------------------------------
  419. :box
  420. cls
  421. echo          DISPLAY A BOX
  422. echo  
  423. echo This demonstration will display a blinking box on the display!
  424. echo  
  425. echo The command line used will be:
  426. echo  
  427. echo   BOX /s1 s 30 15 45 17 187
  428. echo  
  429. butnpres %_p%
  430. echo  
  431. BOX /s1 s 30 15 45 17 187
  432. BoxText /s1 s 73 23 103 OK
  433. askmouse 75 24 78 24 * 75 24 %_t%
  434. goto in-p3
  435. rem --------------------------------------------------------
  436. :askmouse
  437. cls
  438. echo          ASK MOUSE
  439. echo  
  440. echo Ask Mouse is a utility that is meant to be functionally similar to the many
  441. echo ASK utilities, except that this version allows for mouse (or text cursor)
  442. echo input.  The utility is intended for use in menus and similar occasions when
  443. echo one option is to be chosen from amongst a range.
  444. echo  
  445. echo Ask Mouse is used for all the menu selections in the batch file, and so,
  446. echo needs no demonstration here :-)
  447. echo  
  448. echo The commands used will be (the commands used at the end of each demo):
  449. echo  
  450. echo   BoxText /s1 s 73 23 103 OK                  - draw OK box
  451. echo   AskMouse 75 24 78 24 * 75 24 %%_t%%      - button (or key)-press
  452. BoxText /s1 s 73 23 103 OK
  453. askmouse 75 24 78 24 * 75 24 %_t%
  454. goto in-p3
  455. rem --------------------------------------------------------
  456. :end
  457. set _um=
  458. set _t=
  459. echo 
  460. cls
  461. :exit
  462.