home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / greed223.zip / DELSAVES.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-04  |  4KB  |  115 lines

  1. /* REXX *********************************************/
  2. /*                                                  */
  3. /* Program name: DELSAVES                           */
  4. /* Function    : Delete Backup after successfully   */
  5. /*               installation                       */
  6. /*               example for the post-install-      */
  7. /*               successful exit                    */
  8. /*                                                  */
  9. /* Syntax      : Call from the INSTALL.DAT via:     */
  10. /*    START_REXX_BY_SUCCESSFUL=DELSAVES dest_path   */
  11. /*                                                  */
  12. /* Changes     :                                    */
  13. /*                                                  */
  14. /* Made use of GREED.  21 May 1996 / 21:22:36   JRK */
  15. /****************************************************/
  16. Parse Arg destPath
  17. /*-------------(Write lines into file)--------------*/
  18. myLog = destPath'\install.log'
  19. rc = LineOut( myLog, 'Destination Directory:' destPath)
  20.  
  21. /*==============(Exception handling)================*/
  22. Signal On Failure Name CLEARUP
  23. Signal On Halt    Name CLEARUP
  24. Signal On Syntax  Name CLEARUP
  25.  
  26. /*==========(Initialize RexxUtil support)===========*/
  27. If RxFuncQuery('SysLoadFuncs') Then Do
  28.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  29.   Call SysLoadFuncs
  30. End /* If RxFuncQuery... */
  31.  
  32. /*--------------(Save directory)---------------*/
  33. directory = destPath||'\SAVEPREV'
  34.  
  35. /* Call HandleFNC(directory, destPath, myLog) */
  36.  
  37. /*-----------(Find file/Set attributes)-------------*/
  38. rc = SysFileTree( directory||'\*.*', fileList, 'FO' )
  39. Do i = 1 To fileList.0
  40.   /*------------------(Delete file)-------------------*/
  41.   delRC = SysFileDelete( fileList.i )
  42. End /* If ... */
  43.  
  44. /*-------------(Remove directory)--------------*/
  45. rc = SysRmDir( directory )
  46.  
  47. /*================(End this program)================*/
  48. Return
  49.  
  50. CLEARUP:
  51. Return
  52.  
  53. /*================(Search FNC files)================*/
  54. CheckFNC: Procedure
  55. Arg destPath, filename
  56.  
  57. /*----------------(Split path name)-----------------*/
  58. name = FileSpec( "Name", filename )  /* FILENAME.EXT */
  59. newFNC = destPath||'\'||name
  60. rc = SysFileTree( newFNC, List )
  61. If List.0 > 0 Then Return newFNC
  62. Else rc = LineOut( myLog, 'No FNC' name 'found' )
  63.  
  64. Return ''
  65.  
  66.  
  67. /*================(Copy FNC files)=================*/
  68. CopyFNC: Procedure
  69. Arg oldFNC, newFNC
  70.  
  71. appl.0 = 0
  72. key.0 = 0
  73. result = SysIni( oldFNC, 'ALL:', 'appl' )
  74. Do i = 1 To appl.0
  75.   result = SysIni( oldFNC, appl.i, 'ALL:', 'key' )
  76.   Do j = 1 To key.0
  77.     value = SysIni( oldFNC, appl.i, key.j )
  78.     /*---------------(Set key value data)---------------*/
  79.     result = SysIni( newFNC, appl.i, key.j, value )
  80.     If result = 'ERROR:' Then Do
  81.       Queue 'APPL' i appl.i 'KEY' j key.j result
  82.       Parse Var newFNC name '.' ext
  83.       renFNC = name || '.' || 'FUN'
  84.       "ren" newFNC renFNC ">>NUL"
  85.       Return result
  86.     End
  87.   End
  88. End
  89.  
  90. Return 'OK:'
  91.  
  92.  
  93. /*===============(Handle FNC files)=================*/
  94. HandleFNC: Procedure
  95. Arg directory, destPath, myLog
  96.  
  97. /*-----------(Find previous *.FNC files)------------*/
  98. appl.0 = 0
  99. rc = SysFileTree( directory||'\*.FNC', fileList, 'FO' )
  100. rc = LineOut( myLog, 'FNC files:' fileList.0 )
  101.  
  102. Do i = 1 To fileList.0
  103.   newFNC = CheckFNC(destPath, fileList.i)
  104.   rc = LineOut( myLog, 'From:' fileList.i 'to:' newFNC)
  105.   If newFNC > '' Then Do
  106.     Call CopyFNC fileList.i, newFNC
  107.     If result = 'ERROR:' Then Do
  108.       Pull erRecord
  109.       rc = LineOut( myLog, erRecord )
  110.     End
  111.   End
  112. End
  113. status = Stream( myLog, 'C', 'Close' )
  114.  
  115. Return