home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / srtbt20.zip / SRT.CMD < prev   
OS/2 REXX Batch file  |  1997-08-12  |  9KB  |  493 lines

  1. /* Author: Jerry Pedone                 */
  2. /* jpedone@flash.net                    */
  3. /* Legal Stuff:                                   */
  4. /*     It's free - you get what you pay for         */
  5. /* Load the REXX functions                 */
  6. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7. call SysLoadFuncs
  8. signal on failure name halt
  9. signal on halt name halt
  10. /* Set up variables                     */
  11. Options 'EXMODE'
  12. cr = '0d'x
  13. lf = '0a'x
  14. tab = '09'x
  15. rem1 = 'REM **************************************************'
  16. file_attempt = 0
  17. /* Initialize stems                        */
  18. fs = 0
  19. ex = 0
  20. od = 0
  21. lb = 0
  22. st = 0
  23. sw = 0
  24. cn = 0
  25. cd = 0
  26. ds = 0
  27. rn = 0
  28. os = 0
  29. dos = 0
  30. dvi = 0
  31. bd = 0
  32. rk = 0
  33. basedev.0 = 0
  34. lib.0 = 0
  35. setter.0 = 0
  36. cdpg.0 = 0
  37. cntry.0 = 0
  38. devin.0 = 0
  39. osdev.0 = 0
  40. ffn.0 = 0
  41. swp.0 = 0
  42. doscom.0 = 0
  43. dosdev.0 = 0
  44. odos.0 = 0
  45. runn.0 = 0
  46. extr.0 = 0
  47. rmk.0 = 0
  48. /* Yes I know - 15 stems is a bit excessive     */
  49. Parse Upper Arg drive rems
  50. If rems = '?' Then Signal help
  51. if rems = 'HELP' Then Signal help
  52. if drive = ' ' Then Signal help
  53. /* Check for existence of config.sys            */
  54. rc = SysFileTree(drive':\config.sys','config_sys.','F')
  55. if config_sys.0 <> 1 Then Do
  56.     halt_string = 'Could not find CONFIG.SYS'
  57.     Signal halt
  58. End
  59. /* Delete any previously sorted file            */
  60. rc = SysSearchPath('.' , 'config.new')
  61. if rc <> ' ' THEN DEL 'config.new'
  62. /* Bring in the lines one at a time */
  63. Current_Line_Number = 0
  64. Do While Lines(drive":\config.sys")
  65.     in_line = Linein(drive":\config.sys")
  66.     in_line = Translate(in_line)
  67.     test_part = substr(in_line,1,3)
  68.     Call stem_find
  69. end 
  70. rc = Stream(drive":\config.sys","C","Close")
  71. /* Output the sorted file                */
  72. rem2 = 'REM Base Devices'
  73. Call rem_it
  74. DO i = 1 TO basedev.0
  75.     CALL CHAROUT 'config.new' , basedev.i
  76.     CALL Endline
  77. End
  78. rem2 = 'REM Libraries'
  79. Call rem_it
  80. DO i = 1 TO lib.0
  81.     CALL CHAROUT 'config.new' , lib.i
  82.     CALL Endline
  83. End
  84. rem2 = 'REM Set Statements'
  85. Call rem_it
  86. DO i = 1 TO setter.0
  87.     CALL CHAROUT 'config.new' , setter.i
  88.     CALL Endline
  89. End
  90. rem2 = 'REM Code Page'
  91. Call rem_it
  92. DO i = 1 TO cdpg.0
  93.     CALL CHAROUT 'config.new' , cdpg.i
  94.     CALL Endline
  95. End
  96. rem2 = 'REM Country Code'
  97. Call rem_it
  98. DO i = 1 TO cntry.0
  99.     CALL CHAROUT 'config.new' , cntry.i
  100.     CALL Endline
  101. End
  102. rem2 = 'REM Device Info'
  103. Call rem_it
  104. DO i = 1 TO devin.0
  105.     CALL CHAROUT 'config.new' , devin.i
  106.     CALL Endline
  107. End
  108. rem2 = 'REM OS/2 Devices'
  109. Call rem_it
  110. DO i = 1 TO osdev.0
  111.     CALL CHAROUT 'config.new' , osdev.i
  112.     CALL Endline
  113. End
  114. rem2 = 'REM File Systems'
  115. Call rem_it
  116. DO i = 1 TO ffn.0
  117.     CALL CHAROUT 'config.new' , ffn.i
  118.     CALL Endline
  119. End
  120. rem2 = 'REM Swap Files'
  121. Call rem_it
  122. DO i = 1 TO swp.0
  123.     CALL CHAROUT 'config.new' , swp.i
  124.     CALL Endline
  125. End
  126. rem2 = 'REM DOS Commands'
  127. Call rem_it
  128. DO i = 1 TO doscom.0
  129.     CALL CHAROUT 'config.new' , doscom.i
  130.     CALL Endline
  131. End
  132. rem2 = 'REM DOS Devices'
  133. Call rem_it
  134. DO i = 1 TO dosdev.0
  135.     CALL CHAROUT 'config.new' , dosdev.i
  136.     CALL Endline
  137. End
  138. rem2 = 'REM Other DOS Stuff'
  139. Call rem_it
  140. DO i = 1 TO odos.0
  141.     CALL CHAROUT 'config.new' , odos.i
  142.     CALL Endline
  143. End
  144. rem2 = 'REM Programs to Run'
  145. Call rem_it
  146. DO i = 1 TO runn.0
  147.     CALL CHAROUT 'config.new' , runn.i
  148.     CALL Endline
  149. End
  150. rem2 = 'REM Anything Else'
  151. Call rem_it
  152. DO i = 1 TO extr.0
  153.     CALL CHAROUT 'config.new' , extr.i
  154.     CALL Endline
  155. End
  156. rem2 = 'REM Informational Remarks'
  157. If rems = 'ALL' Then Do
  158.     Call rem_it
  159.     DO i = 1 TO rmk.0
  160.         CALL CHAROUT 'config.new' , rmk.i
  161.         CALL Endline
  162.     End
  163. End
  164. Call done
  165. /* Program is done - these are procedures            */
  166. rem_it:
  167. If rems = 'ALL' Then call rem_it2
  168. IF rems = 'SOME' Then Call rem_it2
  169. Return
  170. rem_it2:
  171. Call CHAROUT 'config.new' , rem1
  172. Call Endline
  173. Call CHAROUT 'config.new' , rem2
  174. Call Endline
  175. Call CHAROUT 'config.new' , rem1
  176. Call Endline
  177. Return
  178. Endline:
  179. CALL CHAROUT 'config.new' , cr
  180. CALL CHAROUT 'config.new' , lf    
  181. Return
  182. stem_find:
  183. If test_part = 'BAS' Then Do
  184.     bd = bd+1
  185.     basedev.0 = bd
  186.     basedev.bd = in_line
  187.     Return
  188. End
  189. If test_part = 'LIB' Then Do
  190.     lb = lb+1
  191.     lib.0 = lb
  192.     lib.lb = in_line
  193.     Return
  194. End
  195. If test_part = 'SET' Then Do
  196.     st = st+1
  197.     setter.0 = st
  198.     setter.st = in_line
  199.     Return
  200. End
  201. If test_part = 'COD' Then Do
  202.     cd = cd+1
  203.     cdpg.0 = cd
  204.     cdpg.cd = in_line
  205.     Return
  206. End
  207. If test_part = 'COU' Then Do
  208.     cn = cn+1
  209.     cntry.0 = cn
  210.     cntry.cn = in_line
  211.     Return
  212. End
  213. If test_part = 'IFS' Then Do
  214.     fs = fs + 1
  215.     ffn.0 = fs
  216.     ffn.fs = in_line
  217.     Return
  218. End
  219. If test_part = 'SWA' Then Do
  220.     sw = sw+1
  221.     swp.0 = sw
  222.     swp.sw = in_line
  223.     Return
  224. End
  225. If test_part = 'BRE' Then Do
  226.     ds = ds+1
  227.     doscom.0 = ds
  228.     doscom.ds = in_line
  229.     Return
  230. End
  231. If test_part = 'DOS' Then Do
  232.     od = od+1
  233.     odos.0 = od
  234.     odos.od = in_line
  235.     Return
  236. End
  237. If test_part = 'FCB' Then Do
  238.     od = od+1
  239.     odos.0 = od
  240.     odos.od = in_line
  241.     Return
  242. End
  243. If test_part = 'FIL' Then Do
  244.     od = od+1
  245.     odos.0 = od
  246.     odos.od = in_line
  247.     Return
  248. End
  249. If test_part = 'LAS' Then Do
  250.     od = od+1
  251.     odos.0 = od
  252.     odos.od = in_line
  253.     Return
  254. End
  255. If test_part = 'RMS' Then Do
  256.     od = od+1
  257.     odos.0 = od
  258.     odos.od = in_line
  259.     Return
  260. End
  261. If test_part = 'SHE' Then Do
  262.     od = od+1
  263.     odos.0 = od
  264.     odos.od = in_line
  265.     Return
  266. End
  267. If test_part = 'RUN' Then Do
  268.     rn = rn+1
  269.     runn.0 = rn
  270.     runn.rn = in_line
  271.     Return
  272. End
  273. If test_part = 'CAL' Then Do
  274.     rn = rn+1
  275.     runn.0 = rn
  276.     runn.rn = in_line
  277.     Return
  278. End
  279. test_part2 = substr(in_line,1,9)
  280. If test_part2 = 'PROTECTON' Then Do
  281.     od = od+1
  282.     odos.0 = od
  283.     odos.od = in_line
  284.     Return
  285. End
  286. If test_part = 'DEV' Then Do
  287.     Call Devices
  288.     Return
  289. End
  290. If test_part = 'REM' Then Do
  291.     Call Remarking
  292.     Return
  293. End
  294. test_part2 = substr(in_line,1,1)
  295. If test_part2 <> ' ' Then Do
  296.     ex = ex+1
  297.     extr.0 = ex
  298.     extr.ex = in_line
  299.     Return
  300. End
  301. Return
  302. Devices:
  303. test_part2 = substr(in_line,1,7)
  304. If test_part2 = 'DEVINFO' Then Do
  305.     dvi = dvi + 1
  306.     devin.0 = dvi
  307.     devin.dvi = in_line
  308.     Return
  309. End
  310. test_part2 = substr(in_line,15,5)
  311. If test_part2 <> 'MDOS\' Then Do
  312.     os = os + 1
  313.     osdev.0 = os
  314.     osdev.os = in_line
  315.     Return
  316. End
  317. If test_part2 = 'MDOS\' Then Do
  318.     dos = dos + 1
  319.     dosdev.0 = dos
  320.     dosdev.dos = in_line
  321.     Return
  322. End
  323. halt_string = 'Unknown Device'
  324. signal halt
  325. Return
  326. Remarking:
  327. If rems = 'ALL' Then Do
  328.     test_part2 = substr(in_line,5,3)
  329.     If test_part2 = 'BAS' Then Do
  330.         bd = bd+1
  331.         basedev.0 = bd
  332.         basedev.bd = in_line
  333.         Return
  334.     End
  335.     If test_part2 = 'LIB' Then Do
  336.         lb = lb+1
  337.         lib.0 = lb
  338.         lib.lb = in_line
  339.         Return
  340.     End
  341.     If test_part2 = 'SET' Then Do
  342.         st = st+1
  343.         setter.0 = st
  344.         setter.st = in_line
  345.         Return
  346.     End
  347.     If test_part2 = 'COD' Then Do
  348.         cd = cd+1
  349.         cdpg.0 = cd
  350.         cdpg.cd = in_line
  351.         Return
  352.     End
  353.     If test_part2 = 'COU' Then Do
  354.         cn = cn+1
  355.         cntry.0 = cn
  356.         cntry.cn = in_line
  357.         Return
  358.     End
  359.     If test_part2 = 'DEV' Then Do
  360.         Call Device2
  361.         Return
  362.     End
  363.     If test_part2 = 'IFS' Then Do
  364.         fs = fs + 1
  365.         ffn.0 = fs
  366.         ffn.fs = in_line
  367.         Return
  368.     End
  369.     If test_part2 = 'SWA' Then Do
  370.         sw = sw+1
  371.         swp.0 = sw
  372.         swp.sw = in_line
  373.         Return
  374.     End
  375.     If test_part2 = 'BRE' Then Do
  376.         ds = ds+1
  377.         doscom.0 = ds
  378.         doscom.ds = in_line
  379.         Return
  380.     End
  381.     If test_part2 = 'DOS' Then Do
  382.         od = od+1
  383.         odos.0 = od
  384.         odos.od = in_line
  385.         Return
  386.     End
  387.     If test_part2 = 'FCB' Then Do
  388.         od = od+1
  389.         odos.0 = od
  390.         odos.od = in_line
  391.         Return
  392.     End
  393.     If test_part2 = 'FIL' Then Do
  394.         od = od+1
  395.         odos.0 = od
  396.         odos.od = in_line
  397.         Return
  398.     End
  399.     If test_part2 = 'LAS' Then Do
  400.         od = od+1
  401.         odos.0 = od
  402.         odos.od = in_line
  403.         Return
  404.     End
  405.     If test_parts = 'RMS' Then Do
  406.         od = od+1
  407.         odos.0 = od
  408.         odos.od = in_line
  409.         Return
  410.     End
  411.     If test_part2 = 'SHE' Then Do
  412.         od = od+1
  413.         odos.0 = od
  414.         odos.od = in_line
  415.         Return
  416.     End
  417.     If test_part2 = 'RUN' Then Do
  418.         rn = rn+1
  419.         runn.0 = rn
  420.         runn.rn = in_line
  421.         Return
  422.     End
  423.     If test_part2 = 'CAL' Then Do
  424.         rn = rn+1
  425.         runn.0 = rn
  426.         runn.rn = in_line
  427.         Return
  428.     End
  429.     rk = rk+1
  430.     rmk.0 = rk
  431.     rmk.rk = in_line
  432.     Return
  433. End
  434. Return
  435. Device2:
  436. test_part2 = substr(in_line,5,7)
  437. If test_part2 = 'DEVINFO' Then Do
  438.     dvi = dvi + 1
  439.     devin.0 = dvi
  440.     devin.dvi = in_line
  441.     Return
  442. End
  443. test_part2 = substr(in_line,20,5)
  444. If test_part2 <> 'MDOS\' Then Do
  445.     os = os + 1
  446.     osdev.0 = os
  447.     osdev.os = in_line
  448.     Return
  449. End
  450. If test_part2 = 'MDOS\' Then Do
  451.     dos = dos + 1
  452.     dosdev.0 = dos
  453.     dosdev.dos = in_line
  454.     Return
  455. End
  456. halt_string = 'Unknown Device Remark'
  457. signal halt
  458. Return
  459. help:
  460. say tab
  461. say tab
  462. say tab 'USAGE:'
  463. say tab
  464. say tab tab 'SRT drive remark_level'
  465. say tab
  466. say tab tab 'drive is the drive containing your CONFIG.SYS file'
  467. say tab
  468. say tab tab 'remark_level is one of the following:'
  469. say tab
  470. say tab tab 'ALL = Seperator remarks and present remarks'
  471. say tab tab '        will be placed in config.new'
  472. say tab
  473. say tab tab 'SOME = Only seperator remarks will be placed in config.new'
  474. say tab
  475. say tab tab 'anything else (or nothing else) = No remarks will be'
  476. say tab tab '     placed in config.new'
  477. say tab
  478. halt_string = ' '
  479. Call halt
  480. halt:
  481. say tab
  482. Say tab halt_string
  483. rc = Stream("config.new","C","Close")
  484. rc = Stream(drive":\config.sys","C","Close")
  485. exit
  486. done:
  487. say tab
  488. say tab tab 'Your sorted CONFIG.SYS file is stored as'
  489. say tab tab 'CONFIG.NEW in this directory'
  490. rc = Stream("config.new","C","Close")
  491. rc = Stream(drive":\config.sys","C","Close")
  492. exit
  493.