home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / newlook.zip / NEWLOOK.CMD < prev    next >
OS/2 REXX Batch file  |  1996-03-11  |  16KB  |  406 lines

  1. /*****************************************************************************\
  2. * NEWLOOK.CMD - main procedure                                                *
  3. \*****************************************************************************/
  4.  
  5. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6. call SysLoadFuncs
  7. '@echo off'
  8. 'ECHO '
  9. 'cls'
  10.  
  11. /* check working directory                                                   */
  12. wkdir = SysSearchPath('PATH', 'NEWLOOK.CMD')
  13. if wkdir = '' then do
  14.    call alarm
  15.    call SysCurPos 5, 0
  16.    say '  NEWLOOK.CMD must be run in its own directory. Just double clic on its icon.'
  17.    call SysCurPos 15, 2
  18.    'pause'
  19.    call SysDropFuncs
  20.    exit
  21. end
  22.  
  23. /* look for RC.EXE                                                           */
  24. rcpath = SysSearchPath('PATH', 'RC.EXE')
  25. if rcpath = '' then do
  26.    call alarm
  27.    call SysCurPos 5, 0
  28.    say '  You must install RC.EXE in a directory included in the PATH statement of'
  29.    say '  your CONFIG.SYS'
  30.    call SysCurPos 15, 2
  31.    'pause'
  32.    call SysDropFuncs
  33.    exit
  34. end
  35.  
  36. /* look for Martin Lafaix's RESMGR                                           */
  37. rdcpath = SysSearchPath('PATH', 'RDC.CMD')
  38. resmgrpath = SysSearchPath('PATH', 'RESMGR.CMD')
  39. rdcpppath = SysSearchPath('PATH', 'RDCPP.EXE')
  40. nldir = DIRECTORY()
  41. if (rdcpath = '' | resmgrpath = '' | rdcpppath = '') then do
  42.    call alarm
  43.    call SysCurPos 5, 0
  44.    say '  You must install Martin Lafaix''s RESMGR in...'
  45.    say '  'nldir
  46.    say '  or any other directory included in the PATH statement of your CONFIG.SYS.'
  47.    say '  See NEWLOOK.TXT for more details.'
  48.    call SysCurPos 15, 2
  49.    'pause'
  50.    call SysDropFuncs
  51.    exit
  52. end
  53.  
  54. /* look for CMD.EXE                                                          */
  55. cmdpath = SysSearchPath('PATH', 'CMD.EXE')
  56. if cmdpath = '' then do
  57.    call alarm
  58.    call SysCurPos 5, 0
  59.    say '  cannot find CMD.EXE. If you use a different command processor you must'
  60.    say '  reinstall CMD.EXE or edit NEWLOOK.CMD file, replacing all CMD.EXE'
  61.    say '  occurrencies with the name of the executable of your command processor.'
  62.    call SysCurPos 15, 2
  63.    'pause'
  64.    call SysDropFuncs
  65.    exit
  66. end
  67.  
  68. /* gets OS/2 drive and directory                                             */
  69. os2drive = FILESPEC('drive', cmdpath)
  70. os2path = FILESPEC('path', cmdpath)
  71.  
  72. call mainmenu
  73. call SysDropFuncs
  74. exit
  75.  
  76.  
  77. /*****************************************************************************\
  78. *  mainmenu: menu procedure                                                   *
  79. \*****************************************************************************/
  80.  
  81. mainmenu:
  82.    say ''
  83.    'cls'
  84.    call SysCurPos 2, 0
  85.    say '   ┌────────────────────────────────────────────────────────────────────────┐'
  86.    say '   │                                                                        │'
  87.    say '   │    ACTION                                                  COMMAND     │'
  88.    say '   │    Read NEWLOOK.TXT ...................................... read        │'
  89.    say '   │    Edit the new system icons ............................. editico     │'
  90.    say '   │    Edit the new window controls .......................... editctls    │'
  91.    say '   │    Change the default system icons ....................... newico      │'
  92.    say '   │    Change window controls ................................ newctls     │'
  93.    say '   │    Change both system icon and window controls ........... newall      │'
  94.    say '   │    Restore original system icons ......................... restico     │'
  95.    say '   │    Restore original window controls ...................... restctls    │'
  96.    say '   │    Restore both original system icons and window controls  restall     │'
  97.    say '   │    Exit .................................................. quit        │'
  98.    say '   │                                                                        │'
  99.    say '   └────────────────────────────────────────────────────────────────────────┘'
  100.  
  101.    say ''
  102.    call SysCurPos 18, 0
  103.    say '   ┌────────────────────────────────────────────────────────────────────────┐'
  104.    say '   │                                                                        │'
  105.    say '   │                                                                        │'
  106.    say '   │                                                                        │'
  107.    say '   └────────────────────────────────────────────────────────────────────────┘'
  108.    do while done \= 1
  109.       call SysCurPos 20, 8
  110.       say '                                                          '
  111.       call SysCurPos 20, 8
  112.       pull action
  113.       say ''
  114.       select
  115.          when action = 'READ'          /* read program documentation         */
  116.             then do
  117.                call readdoc
  118.                call mainmenu
  119.                done = 1
  120.             end
  121.          when action = 'EDITICO'       /* open SYSICONS folder for editing   */
  122.             then do
  123.                call editing 'SYSICONS'
  124.                call mainmenu
  125.                done = 1
  126.             end
  127.          when action = 'EDITCTLS'      /* open WINCTLS folder for editing    */
  128.             then do
  129.                call editing 'WINCTLS'
  130.                call mainmenu
  131.                done = 1
  132.             end
  133.          when action = 'NEWICO'        /* patch PMWP.DLL                     */
  134.             then do
  135.                call patchdll 'PMWP'
  136.                call endmsg
  137.                done = 1
  138.             end
  139.          when action = 'NEWCTLS'       /* patch PMMERGE.DLL                  */
  140.             then do
  141.                call patchdll , 'PMMERGE'
  142.                call endmsg
  143.                done = 1
  144.             end
  145.          when action = 'NEWALL'        /* patch both PMWP.DLL and PMMERGE.DLL*/
  146.             then do
  147.                call patchdll 'PMWP', 'PMMERGE'
  148.                call endmsg
  149.                done = 1
  150.             end
  151.          when action = 'RESTICO'       /* restore original PMWP.DLL          */
  152.             then do
  153.                call restore 'PMWP'
  154.                call endmsg
  155.                done = 1
  156.             end
  157.          when action = 'RESTCTLS'      /* restore original PMMERGE.DLL       */
  158.             then do
  159.                call restore , 'PMMERGE'
  160.                call endmsg
  161.                done = 1
  162.             end
  163.          when action = 'RESTALL'       /* restore original PMWP and PMMERGE  */
  164.             then do
  165.                call restore 'PMWP', 'PMMERGE'
  166.                call endmsg
  167.                done = 1
  168.             end
  169.          when action = 'QUIT'          /* terminate NEWLOOK.CMD and exit     */
  170.             then do
  171.                call SysDropFuncs
  172.                exit
  173.             end
  174.          otherwise                     /* unvalid command: alarm and loop    */
  175.             call alarm
  176.       end                              /* end select                         */
  177.    end                                 /* end do                             */
  178. return
  179.  
  180.  
  181. /*****************************************************************************\
  182. *  readdoc: shows the program documentation                                   *
  183. \*****************************************************************************/
  184.  
  185. readdoc:
  186.    editpath = SysSearchPath('PATH', 'E.EXE')
  187.    if editpath = '' then do
  188.       'cls'
  189.       call alarm
  190.       call SysCurPos 5, 0
  191.       say '  Cannot find E.EXE.'
  192.       call SysCurPos 15, 2
  193.       pause
  194.       call SysDropFuncs
  195.       exit
  196.    end
  197.    e NEWLOOK.TXT
  198. return
  199.  
  200.  
  201. /*****************************************************************************\
  202. *  editing: opens "SYSICONS" or "WINCTLS" folder for editing                  *
  203. \*****************************************************************************/
  204.  
  205. editing:
  206. arg folder
  207.    'cls'
  208.    call alarm
  209.    call SysCurPos 5, 0
  210.    say '  Now the' folder 'folder will be opened.'
  211.    say '  Icons are saved with a PTR extension. Do not rename them!'
  212.    say '  Icons and Bitmaps are saved in various formats. Remember to check all'
  213.    say '  the available formats by the "Device | List... | View" menu commands.'
  214.    say '  See NEWLOOK.TXT for more details.'
  215.    call SysCurPos 15, 2
  216.    pause
  217.    rc = SysOpenObject(nldir || '\' || folder, 'default', 'FALSE')
  218.    if rc = 0 then do
  219.       call alarm
  220.       call SysCurPos 5, 0
  221.       say '  Cannot open ' nldir || '\' || folder
  222.       call SysCurPos 15, 2
  223.       pause
  224.       call SysDropFuncs
  225.       exit
  226.    end
  227. return
  228.  
  229.  
  230. /*****************************************************************************\
  231. *  endmsg: after patching DDLs says you must reboot                           *
  232. \*****************************************************************************/
  233.  
  234. endmsg:
  235.    cls
  236.    call endsnd
  237.    call SysCurPos 5, 0
  238.    say '  Your system files have been updated. You must reboot in order to'
  239.    say '  let changes take into effect'
  240.    call SysCurPos 15, 2
  241.    pause
  242. return
  243.  
  244.  
  245. /*****************************************************************************\
  246. *  patchdll: backups DLLs passed as arguments, patches them, patches          *
  247. *  CONFIG.SYS and swaps old DLLs with new ones on next reboot                 *
  248. \*****************************************************************************/
  249.  
  250. patchdll:
  251. arg name1, name2
  252.    'cls'
  253.    say
  254.    'copy' os2drive || '\CONFIG.SYS' os2drive || '\CONFIG.NLK'
  255.    'del' os2drive || '\CONFIG.SYS'     /* back up config.sys                 */
  256.    if name1 = ''
  257.       then nop
  258.    else do                             /* PMWP.DLL                           */
  259.       call checkbackup name1, 'PATCH'
  260.       filename = checkdll(name1)
  261.       'copy' filename
  262.       'copy PMWP.DLL PMWP.SAV'
  263.       'rc -r SYSICONS\PMWP.RC'
  264.       call resmgr '-a PMWP.DLL SYSICONS\PMWP.RES'
  265.       ' del SYSICONS\PMWP.RES'
  266.       'echo call=' || cmdpath '/c copy' nldir || '\PMWP.DLL' os2drive || os2path,
  267.                    || 'DLL >>' os2drive || '\CONFIG.SYS'
  268.       'echo call=' || cmdpath '/c del' nldir || '\PMWP.DLL >>' os2drive,
  269.                    || '\config.sys'
  270.    end
  271.    if name2 = ''
  272.       then nop
  273.    else do                             /* PMMERGE.DLL                        */
  274.       call checkbackup name2, 'PATCH'
  275.       filename = checkdll(name2)
  276.       'copy' filename
  277.       'copy PMMERGE.DLL PMMERGE.SAV'
  278.       'rc -r WINCTLS\PMMERGE.RC'
  279.       call resmgr '-a PMMERGE.DLL WINCTLS\PMMERGE.RES'
  280.       'del WINCTLS\PMMERGE.RES'
  281.       'echo call='|| cmdpath '/c copy' nldir || '\PMMERGE.DLL' os2drive || os2path,
  282.                   || 'DLL >>' os2drive || '\CONFIG.SYS'
  283.       'echo call=' || cmdpath '/c del' nldir || '\PMMERGE.DLL >>' os2drive,
  284.                    || '\config.sys'
  285.    end
  286.    'type' os2drive || '\CONFIG.NLK >>' os2drive || '\CONFIG.SYS'
  287.    'echo call=' || cmdpath '/c copy' os2drive || '\CONFIG.NLK' os2drive,
  288.                 || '\CONFIG.SYS >>' os2drive || '\CONFIG.SYS'
  289. return
  290.  
  291.  
  292. /*****************************************************************************\
  293. *  checkdll: checks PMWP.DLL or PMMERGE.DLL existence                         *
  294. \*****************************************************************************/
  295.  
  296. checkdll: procedure expose os2drive os2path
  297. arg dllname
  298.    filename = stream( os2drive || os2path || '\DLL\' || dllname || '.DLL', 'C',,
  299.                      'query exists')
  300.    if filename = '' then do
  301.       call alarm
  302.       call SysCurPos 5, 0
  303.       say '  Cannot find ' dllname || '.DLL in ' os2drive || os2path,
  304.              || '\DLL directory'
  305.       call SysCurPos 15, 2
  306.       'pause'
  307.       'rename ' os2drive || '\CONFIG.NLK CONFIG.SYS'
  308.       call SysDropFuncs
  309.       exit
  310.    end
  311. return filename
  312.  
  313.  
  314. /*****************************************************************************\
  315. *  restore: restore backup copies of original DLLs                            *
  316. \*****************************************************************************/
  317.  
  318. restore:
  319. arg name1, name2
  320.    'cls'
  321.    say
  322.    'copy' os2drive || '\CONFIG.SYS' os2drive || '\CONFIG.NLK'
  323.    'del' os2drive || '\CONFIG.SYS'     /* back up config.sys                 */
  324.    if name1 = ''
  325.       then nop
  326.    else do                             /* PMWP.DLL                           */
  327.       filename = checkbackup(name1, 'RESTORE')
  328.       'echo call=' || cmdpath '/c copy' filename os2drive || os2path,
  329.                   || 'DLL\PMWP.DLL >>' os2drive || '\CONFIG.SYS'
  330.       'echo call=' || cmdpath '/c del' filename '>>' os2drive || '\CONFIG.SYS'
  331.    end
  332.    if name2 = ''
  333.       then nop
  334.    else do                             /* PMMERGE.DLL                        */
  335.       filename = checkbackup(name2, 'RESTORE')
  336.       'echo call=' || cmdpath '/c copy' filename os2drive || os2path,
  337.                   || 'DLL\PMMERGE.DLL >>' os2drive || '\CONFIG.SYS'
  338.       'echo call=' || cmdpath '/c del' filename '>>' os2drive || '\CONFIG.SYS'
  339.    end
  340.    'type' os2drive || '\CONFIG.NLK >>' os2drive || '\CONFIG.SYS'
  341.    'echo call=' || cmdpath '/c copy' os2drive || '\CONFIG.NLK' os2drive,
  342.                 || '\CONFIG.SYS >>' os2drive || '\CONFIG.SYS'
  343. return
  344.  
  345.  
  346. /*****************************************************************************\
  347. *  checkbackup: checks the existence of original backup copies of PMWP.DLL    *
  348. *  or PMMERGE.DLL                                                             *
  349. \*****************************************************************************/
  350.  
  351. checkbackup: procedure expose nldir os2drive
  352. arg dllname, action
  353.    filename = stream( nldir || '\' || dllname || '.SAV', 'C', 'query exists')
  354.    select
  355.       when (filename = '' & action = 'RESTORE')
  356.          then do
  357.             'cls'
  358.             call alarm
  359.             call SysCurPos 5, 0
  360.             say '  Cannot find backup copy of' dllname || '.DLL in ' nldir || 'directory!'
  361.             say '  You must copy the original from the installation disk renaming it',
  362.                    dllname || '.SAV'
  363.             call SysCurPos 15, 2
  364.             'pause'
  365.             'rename ' os2drive || '\CONFIG.NLK CONFIG.SYS'
  366.             call SysDropFuncs
  367.             exit
  368.          end
  369.       when (filename \= '' & action = 'PATCH')
  370.          then do
  371.             'cls'
  372.             call alarm
  373.             call SysCurPos 5, 0
  374.             say '  NEWLOOK has detected a backup copy of' dllname || '.DLL .'
  375.             say '  Since RESMGR does not work correctly when re-patching DLLs,'
  376.             say '  you must restore original OS/2 DLLs before patching them.'
  377.             say '  Anyway if you have just installed an OS/2 fixpack, overwriting so'
  378.             say '  previously patched DLLs, you can patch the new DLLs now.'
  379.             say '  Type "continue" to patch DLLs, press "enter" to go back to mainmenu'
  380.             pull reply
  381.             if reply = 'CONTINUE' then
  382.                return filename
  383.             else do
  384.                'rename ' os2drive || '\CONFIG.NLK CONFIG.SYS'
  385.                call mainmenu
  386.             end
  387.          end
  388.       otherwise
  389.          nop
  390.    end
  391. return filename
  392.  
  393.  
  394. alarm:
  395.   call beep 1000,300
  396.   call beep 100, 300
  397. return
  398.  
  399. endsnd:
  400.   x=5000
  401.   do 99
  402.     x = x - 50
  403.     call beep (x), 1
  404.   end
  405. return
  406.