home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / SAVEINI.ZIP / SAVEINI.CMD next >
OS/2 REXX Batch file  |  1993-08-01  |  8KB  |  256 lines

  1. /*  This REXX CMD File will copy the original versions of
  2.     the five (5) major configuration files to the holding
  3.     adirectory, D:\OS2\HOLDINI for safekeeping.  Only the
  4.     most current version is retained.  However, an alter-
  5.     nate FileNameExtension may be given upon prompting in
  6.     order that multiple copies are saved.
  7.  
  8.     FileName:  SAVEINI.CMD
  9.     Date:      August 1, 1993
  10.     Author:    Chris Hascall
  11.                49 McKinley Street
  12.                South Portland ME 04106   USA
  13.                1 (207) 799-8679
  14.  
  15.     Usage:  SAVEINI <switches>
  16.  
  17.          Switches:    (preceded by a '/' or '-')
  18.  
  19.                   ? - to produce a help "screen"
  20.  
  21.                   A - when present, indicates that prompting is
  22.                       required for alternate file extension
  23.  
  24.                   O - automatically overwrite existing copies
  25.                       without prompting
  26.  
  27.          Example:    SAVEINI /A /O
  28.  
  29.  
  30.     Changes:    change default names of files/directories within
  31.                 the 'sin_init' procedure
  32.  
  33.     -------------------------------------------------------------------
  34. */
  35.  
  36. /* trace all */
  37.  
  38. /* ----------------------------------------------------------------------- */
  39. /*      Globals                                                            */
  40. /* ----------------------------------------------------------------------- */
  41.  
  42. '@ECHO OFF'                       /* do not display any SHELL commands */
  43. global. = ""                      /* initialization                    */
  44.  
  45. /* ----------------------------------------------------------------------- */
  46. /*      Main                                                               */
  47. /* ----------------------------------------------------------------------- */
  48.  
  49. main:
  50.  
  51.      parse arg switches
  52.  
  53.      say " "
  54.      say " " switches " switches selected"
  55.  
  56.      CALL sin_init
  57.  
  58.      IF Substr(switches, 1, 1) <> "-" & Substr(switches, 1, 1) <> "/",
  59.       & Substr(switches, 1, 1) <> "?" THEN
  60.      DO
  61.         switches = ""
  62.      END
  63.      ELSE
  64.      DO
  65.         if Pos("?", switches) > 0 THEN
  66.         DO
  67.            CALL sin_help
  68.            CALL sin_exit
  69.         END
  70.         global.prompt    = Pos("A", switches)
  71.         global.overwrite = Pos("O", switches)
  72.      END
  73.  
  74.      if global.prompt <> 0 THEN
  75.      DO
  76.         CALL sin_prompt
  77.      END
  78.  
  79.      if global.overwrite = 0 THEN
  80.      DO
  81.         global.filespec = global.save_dir || "*." || global.f_extension
  82.         CALL sin_copy_chek
  83.      END
  84.  
  85.      if global.do_copy = 0 THEN
  86.      DO
  87.         copy global.auto_exec global.save_dir || "*." || global.f_extension
  88.         copy global.config_s  global.save_dir || "*." || global.f_extension
  89.         copy global.start_up global.save_dir || "*." || global.f_extension
  90.         copy global.win_ini global.save_dir || "*." || global.f_extension
  91.         copy global.win_sys_ini global.save_dir || "*." || global.f_extension
  92.      END
  93.      ELSE
  94.      DO
  95.         say " "
  96.         say "       Files exist in target directory"
  97.      END
  98.      CALL sin_exit
  99.  
  100.   EXIT
  101.  
  102. /* ----------------------------------------------------------------------- */
  103. /*      sin_init                                                           */
  104. /* ----------------------------------------------------------------------- */
  105.  
  106. sin_init : PROCEDURE EXPOSE global.
  107. /***************************************************************
  108. **     initializes all global data                            **
  109. **                                                            **
  110. **     a. check whether RxFuncs are loaded, if not, load them **
  111. **     b. set default values                                  **
  112. **     c. create global file names with default (save) ext.   **
  113. ***************************************************************/
  114.  
  115.         if RxFuncQuery('SysLoadFuncs') THEN
  116.         DO
  117.            CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  118.            CALL SysLoadFuncs
  119.         END
  120.  
  121.         global.prompt        = 0
  122.         global.overwrite     = 0
  123.         global.do_copy       = 0
  124.  
  125.         /********************************************
  126.         ** Change the following defaults as neces- **
  127.         ** sary.                                   **
  128.         ********************************************/
  129.  
  130.         global.save_dir      = "D:\OS2\HOLDINI\"
  131.         global.f_extension   = "SAV"
  132.         global.auto_exec     = "D:\4DOS\AUTOEXEC.BAT"
  133.         global.config_s      = "D:\CONFIG.SYS"
  134.         global.start_up      = "D:\STARTUP.CMD"
  135.         global.win_ini       = "F:\OS2\MDOS\WINOS2\WIN.INI"
  136.         global.win_sys_ini   = "F:\OS2\MDOS\WINOS2\SYSTEM.INI"
  137.  
  138.         RETURN
  139.  
  140. /* sin_init */
  141.  
  142. /* ----------------------------------------------------------------------- */
  143. /*      sin_prompt                                                         */
  144. /* ----------------------------------------------------------------------- */
  145.  
  146. sin_prompt : PROCEDURE EXPOSE global.
  147. /***************************************************************
  148. **     gets the (save) filename extension from the user       **
  149. ***************************************************************/
  150.  
  151.         CALL SysCls
  152.  
  153.         say "Type extension to use for this Archive."
  154.         say "For HPFS drive, this may exceed three "
  155.         say "characters."
  156.         say " "
  157.         say " "
  158.         pull user_ext
  159.         say "Selected " user_ext " as global extension"
  160.         say " "
  161.         pause
  162.  
  163.         if user_ext <> " " THEN
  164.         DO
  165.            global.f_extension = user_ext
  166.         END
  167.         ELSE
  168.         DO
  169.            CALL SysCls
  170.            say " "
  171.            say " "
  172.            say "Using global extension - " global.f_extension
  173.            say " "
  174.         END
  175.  
  176.         RETURN
  177.  
  178. /*  sin_prompt  */
  179.  
  180. /* ----------------------------------------------------------------------- */
  181. /*      sin_copy_chek                                                      */
  182. /* ----------------------------------------------------------------------- */
  183.  
  184. sin_copy_chek : PROCEDURE EXPOSE global.
  185. /***************************************************************
  186. **      the auto-overwrite flag is checked first to ensure    **
  187. **      that previously saved files are not overwritten.      **
  188. ***************************************************************/
  189.  
  190.         CALL SysCls
  191.         say " "
  192.         say " "
  193.         say "       Checking files in "global.save_dir
  194.  
  195.         call SysFileTree global.filespec, files, F
  196.  
  197.         global.do_copy = files.0
  198.  
  199.         say " "
  200.  
  201.         if files.0 > 0 THEN
  202.         DO j = 1 to files.0
  203.            say files.j
  204.         END
  205.  
  206.         RETURN
  207.  
  208. /*  sin_copy_chek  */
  209.  
  210. /* ----------------------------------------------------------------------- **
  211. **      sin_help                                                           **
  212. ** ----------------------------------------------------------------------- */
  213.  
  214. sin_help:    PROCEDURE EXPOSE global.
  215. /***************************************************************
  216. **                                                            **
  217. **     prints a help message in response to request           **
  218. **                                                            **
  219. ***************************************************************/
  220.  
  221.         CALL SysCls
  222.  
  223.         Say " "
  224.         Say " Usage:  SAVEINI [{/|-}switches]"
  225.         Say " "
  226.         Say "     Possible switches are:"
  227.         Say " "
  228.         Say "        ?      this help"
  229.         Say "        A      prompt for extensions to create"
  230.         Say "        O      automatic overwrite of existing files"
  231.         Say " "
  232.  
  233.         Say " "
  234.         Say "     Created by Chris Hascall - 49 McKinley Street  "
  235.         Say "                                South Portland ME  04106"
  236.         Say "                                USA "
  237.  
  238.         RETURN
  239.  
  240. /* sin_help */
  241.  
  242. /* ----------------------------------------------------------------------- **
  243. **      sin_exit                                                           **
  244. ** ----------------------------------------------------------------------- */
  245.  
  246. sin_exit:    PROCEDURE EXPOSE global.
  247.  
  248.         say " "
  249.         say " "
  250.         say " "
  251.         say " "
  252.         say "       SAVEINI has finished ...."
  253.         say " "
  254.  
  255.         EXIT
  256.