home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / eeedit22.zip / enhanced.zip / PostPlug.cmd < prev    next >
OS/2 REXX Batch file  |  2001-04-15  |  7KB  |  149 lines

  1. /*********************************************************/
  2. /*                                                       */
  3. /* Additional work for the Enhanced E installation       */
  4. /* This script is run as the "PostPlugin" at close       */
  5. /* and adds a "Sound" and "PlugIns" directory as well    */
  6. /* as rewriting the "UnInstal.cmd" to remove it all at   */
  7. /* uninstallation time and to remove entries made to     */
  8. /* the os2.ini file.                                     */
  9. /*                                                       */
  10. /* For those using this file as a template for SFX:      */
  11. /*                                                       */
  12. /* This file is interpreted and may have problems with   */
  13. /* subroutines on some machines so it has to be written  */
  14. /* in a straight line for the most part.                 */
  15. /*                                                       */
  16. /*********************************************************/
  17. parse source . . ThisProgram
  18.  
  19. crlf              = '0d0a'x
  20. ThisDir           = Left(ThisProgram, lastpos('\', ThisProgram)-1)
  21. UnInstall         = InstDir||'\UnInstal.cmd'
  22.  
  23. /*********************************************************/
  24. /* Unzip Printer files and delete the zip                */
  25. /*********************************************************/
  26. address cmd 'unzip' InstDir||'\vpt.zip'
  27. Call  SysFileDelete(InstDir||'\vpt.zip')
  28.  
  29. /*********************************************************/
  30. /* Make the "Sound" directory and move files to it       */
  31. /*********************************************************/
  32. rc                = Directory(InstDir)
  33. rc                = SysFileTree(InstDir||'\sound','List','DO')
  34. if List.0         = 0 then rc = SysMkDir('Sound')
  35.  
  36. BadSound          = 0
  37. Do index          = 1 to 4
  38.   FileName        = InstDir||'\click'||index||'.wav'
  39.   NewFileName     = InstDir||'\sound\click'||index||'.wav'
  40.   rc              = SysFileTree(NewFileName,'List','FO')
  41.   result          = 0
  42.   if List.0       > 0 then Call SysFileDelete(NewFileName)
  43.   Contents        = CharIn(FileName,1,Chars(FileName))
  44.   rc              = Stream(FileName,'c','close')
  45.   rc              = CharOut(NewFileName,Contents)
  46.   rc              = Stream(NewFileName,'c','close')
  47.   rc              = SysFileTree(NewFileName,'List','FO')
  48.   if List.0       > 0 then Call SysFileDelete(FileName)
  49.   else BadSound   = BadSound + 1
  50. end
  51.  
  52. /*********************************************************/
  53. /* Make the "ClipText" directory and move files to it    */
  54. /* We won't worry about overwriting because of the odd   */
  55. /* names we've given them but won't delete if not written*/
  56. /*********************************************************/
  57. rc                = Directory(InstDir)
  58. rc                = SysFileTree(InstDir||'\cliptext','List','DO')
  59. if List.0         = 0 then rc = SysMkDir('ClipText')
  60.  
  61. Do index          = 1 to 3
  62.   FileName        = InstDir||'\_ReadMe'||index||'.txt'
  63.   NewFileName     = InstDir||'\ClipText\_ReadMe'||index||'.txt'
  64.   rc              = SysFileTree(NewFileName,'List','FO')
  65.   if List.0       > 0 then Call SysFileDelete(NewFileName)
  66.   Contents        = CharIn(FileName,1,Chars(FileName))
  67.   rc              = Stream(FileName,'c','close')
  68.   rc              = CharOut(NewFileName,Contents)
  69.   rc              = Stream(NewFileName,'c','close')
  70.   rc              = SysFileTree(NewFileName,'List','FO')
  71.   if List.0       > 0 then Call SysFileDelete(FileName)
  72. end
  73.  
  74. /*********************************************************/
  75. /* Make the "PlugIns" directory and move files to it     */
  76. /*********************************************************/
  77. rc                = SysFileTree(InstDir||'\plugins','List','DO')
  78. if List.0         = 0 then rc = SysMkDir('Plugins')
  79.  
  80. PlugIn.0          = 0
  81. PIndex            = 0
  82. rc                = SysFileTree(InstDir||'\plugin.api','aList','FO')
  83. rc                = SysFileTree(InstDir||'\*.plg','List','FO')
  84. if aList.0        > 0 then do
  85.   NewTotal        = List.0 + 1
  86.   List.0          = NewTotal
  87.   List.NewTotal   = aList.1
  88. end
  89. if List.0         > 0 then do
  90.   do index        = 1 to List.0
  91.     BaseName      = FileSpec('N',List.index)
  92.     NewFile       = InstDir||'\plugins\'||BaseName
  93.     rc            = SysFileTree(NewFile,'nList','FO')
  94.     if nList.0    > 0 Then do
  95.       Template    = Left(nList.1, Length(nList.1)-3)||'???'
  96.       TempFile    = SysTempFileName(Template)
  97.       Contents    = CharIn(NewFile,1,Chars(NewFile))
  98.       rc          = Stream(NewFile,'c','close')
  99.       rc          = CharOut(TempFile,Contents)
  100.       rc          = Stream(TempFile,'c','close')
  101.       rc          = SysFileDelete(NewFile)
  102.       PIndex      = PIndex+1
  103.       PlugIn.0    = PIndex
  104.       Plugin.PIndex = FileSpec('N',List.index)||' > '||FileSpec('N',TempFile)
  105.     end
  106.     Contents      = CharIn(List.index,1,Chars(List.index))
  107.     rc            = Stream(List.index,'c','close')
  108.     rc            = CharOut(NewFile,Contents)
  109.     rc            = Stream(NewFile,'C','Close')
  110.     rc            = SysFileDelete(List.index)
  111.   end
  112. end
  113.  
  114. if PlugIn.0>0 then do
  115.   PlugInList      = 'Plugins backed up:'||crlf
  116.   Do index        = 1 to PlugIn.0
  117.     PlugInList    = PlugInList||Plugin.index||crlf
  118.   end
  119.   if BadSound     > 1 then Plural = 's'
  120.   else Plural     = ''
  121.   if BadSound     > 0 then msg1 = BadSound 'sound file'||Plural||' could not be copied to the sounds directory. Uncopied files always remain in the main directory.'||crlf||crlf
  122.   else msg1       = ''
  123.   msg2            = PlugIn.0||' (out of '||List.0||' total) plugin files were backed up in the "Plugin" directory.'
  124.   msg3            = crlf||crlf||PlugInList
  125.   msg4            = crlf||'These plugins may have been modified by the user and the installer will not overwrite them'
  126.   msg5            = ' for this reason. Please check the plugin directory for the backups and update any that you may'
  127.   msg6            = ' have modified.'||crlf||crlf
  128.   response        = VpMessageBox(window,'Enhanced E Installation',msg1||msg2||msg3||msg4||msg5||msg6)
  129. end
  130.  
  131. /*********************************************************/
  132. /* Make changes to the "UnInstal.cmd" file               */
  133. /*********************************************************/
  134. UnInstValue       = CharIn(UnInstall,1,Chars(UnInstall))
  135. rc                = Stream(UnInstall,'c','close')
  136.  
  137. NewInfo1          = "rc = sysini('User', 'EE', 'Delete:')"||crlf
  138. NewInfo2          = "rc = sysini('User', 'EEE', 'Delete:')"||crlf
  139. NewInfo           = NewInfo1||NewInfo2
  140.  
  141. Start             = Pos('/* Other work    */', UnInstValue)
  142. UnInstValue       = Insert(newInfo,UnInstValue,start+20)
  143. rc                = SysFileDelete(UnInstall)
  144. rc                = CharOut(UnInstall,UnInstValue)
  145. rc                = Stream(UnInstall,'c','close')
  146. rc                = Directory(ThisDir)
  147. rc                = SysFileDelete(InstDir||'\PrePlug.cmd')
  148. rc                = SysFileDelete(InstDir||'\PostPlug.cmd')
  149.