home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / af0_32b.zip / english.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-18  |  6KB  |  223 lines

  1. /**/
  2. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  3. call SysLoadFuncs
  4.  
  5. Call SysCls
  6. lang = "English"
  7.  
  8. Say
  9. Say "         AF - The Archive Folder - Installation program"
  10. Say "         =============================================="
  11. Say
  12. Say "  This script will copy the program files to the installation directory,"
  13. Say "  create a program object and create associations and templates for the"
  14. Say "  Archive Folder."
  15. Say
  16. Call charout, "  Do you want to continue? (y/N): "
  17.  
  18. answer = SysGetKey(echo)
  19.  
  20.  
  21. if answer <> "y" & answer <> "Y" then return
  22. Say
  23.  
  24. say "  Enter the FULL path to the directory where you want "
  25. say "  AF installed or press ENTER to install from current directory."
  26. Call charout, "  Directory (no trailing backslash!): "
  27. pull InstallDir
  28.  
  29. if length(InstallDir) = 0 then do
  30.   DontCopy = 1
  31.   InstallDir = Directory()
  32. end
  33. else do
  34.   DontCopy = 0
  35.   if SysFileTree(InstallDir, dir, D) <> 0 then do
  36.     Say "Out of memory!"
  37.     return
  38.   end
  39.   if dir.0 = 0 then do
  40.     Call charout, "  "InstallDir "doesn''t exist! Do you want to create it? (y/N): "
  41.     answer = SysGetKey(echo);say
  42.     if answer <> "y" & answer <> "Y" then return
  43.     if SysMkDir(InstallDir) <> 0 then do
  44.       Say "  Error creating" InstallDir"!"
  45.       return -1
  46.     end
  47.   end
  48. end
  49.  
  50. if exists(lang'.dll') then
  51.   'copy' lang'.dll' InstallDir'\af.dll'
  52. else do
  53.   say "  Unable to locate" lang'.dll'
  54.   return -1
  55. end
  56.  
  57. if \DontCopy Then do
  58.   if exists(lang'.cmd') then
  59.     'copy' lang'.cmd' InstallDir'\'lang'.cmd'
  60.   else do
  61.     say "  Unable to locate" lang'.cmd'
  62.     return -1
  63.   end
  64.  
  65.   if exists('af.exe') then
  66.     'copy af.exe' InstallDir
  67.   else do
  68.     say "  Unable to locate af.exe"
  69.     return -1
  70.   end
  71.  
  72.   if exists('af.hlp') then
  73.     'copy af.hlp' InstallDir
  74.   else do
  75.     say "  Unable to locate af.hlp"
  76.     return -1
  77.   end
  78.  
  79.   if exists('editarc.exe') then
  80.     'copy af.hlp' InstallDir
  81.   else do
  82.     say "  Unable to locate editarc.exe"
  83.     return -1
  84.   end
  85.  
  86.   if exists('beta.txt') then
  87.     'copy beta.txt' InstallDir
  88.   else do
  89.     say "  Unable to locate beta.txt"
  90.   end
  91.  
  92.   if exists('install.txt') then
  93.     'copy install.txt' InstallDir
  94.   else do
  95.     say "  Unable to locate install.txt"
  96.   end
  97.  
  98.   if exists('whatsnew') then
  99.     'copy whatsnew' InstallDir
  100.   else do
  101.     say "  Unable to locate WhatsNew"
  102.   end
  103.  
  104.   if exists(archiver.bb2) then
  105.     'copy archiver.bb2' InstallDir
  106.   else do
  107.     say "  Unable to locate ARCHIVER.BB2"
  108.     return -1
  109.   end
  110. end
  111.  
  112. EAT_ASCII = REVERSE('FFFD'X)
  113.  
  114.  
  115. TypeText = 'Archive'
  116. Type     = EAT_ASCII || d2c(length(TypeText)) || '00'x || TypeText
  117. Name     = "Archive Templates"
  118. LongName = EAT_ASCII || d2c(length(Name)) || '00'x || Name
  119.  
  120. if SysFileTree("TEMPLATE", dir, D) <> 0 then do
  121.   Say "  Not enough memory!"
  122.   return
  123. end
  124.  
  125. if \ SysCreateObject( "WPFolder", "Archive Folder", "<WP_DESKTOP>","OBJECTID=<AF_FOLDER>;","u")
  126. then do
  127.   Say "  Error creating folder!"
  128.   return
  129. end
  130. else
  131.   say "  Created template folder."
  132.  
  133. rc = SysCreateObject( "WPProgram", "Archive Folder", "<AF_FOLDER>","PROGTYPE=PM;EXENAME="InstallDir"\AF.EXE;STARTUPDIR="Installdir";ASSOCTYPE=Archive;ASSOCFILTER=*.lzh,*.zip,*.arc,*.arj,*.rar;OBJECTID=<AF>;","r")
  134. if \rc then do
  135.   Say "  Error creating program object!"
  136.   return
  137. end
  138. else
  139.   say "  Created program object for Archive Folder."
  140.  
  141. rc = SysCreateObject( "WPProgram", "Archiver Registry", "<AF_FOLDER>","PROGTYPE=PM;EXENAME="InstallDir"\EDITARC.EXE;STARTUPDIR="Installdir";ASSOCTYPE=Archive;ASSOCFILTER=*.lzh,*.zip,*.arc,*.arj,*.rar;OBJECTID=<AF_REG>;","r")
  142. if \rc then do
  143.   Say "  Error creating program object for Archiver Registry!"
  144.   return
  145. end
  146. else
  147.   say "  Created program object for Archiver Registry."
  148.  
  149. if dir.0 = 0 then do
  150.   if \ SysCreateObject( "WPFolder", "TEMPLATE", InstallDir,"OBJECTID=<AF_TEMPS>;","u")
  151.   then do
  152.     Say "  Error creating template folder!"
  153.     say "   Do you have another AF template folder somewhere else?"
  154.     return
  155.   end
  156.   else
  157.     say "  Created template folder."
  158. end
  159. else do
  160.   if \ SysSetObjectData(InstallDir"\TEMPLATE", "OBJECTID=<AF_TEMPS>;") then
  161.     Say "  Error Setting ObjectID on template folder!"
  162.   else
  163.     say "  Setting object ID on template folder."
  164. end
  165.  
  166. if SysPutEA( "TEMPLATE", ".LONGNAME", LongName ) <> 0 then
  167.   Say "  Error setting .LONGNAME Extended Attribute!"
  168. else
  169.   say "  Setting .LONGNAME Extended Attribute on template folder."
  170.  
  171. if \ SysCreateObject( "WPShadow", "Archive templates", "<AF_FOLDER>", "SHADOWID=<AF_TEMPS>;OBJECTID=<AF_TEMPS_SHADOW>;","u" ) then
  172.   Say "  Error creating shadow of template folder on the desktop!"
  173.  
  174. Call SysOpenObject "<AF_TEMPS>", 1, 1
  175.  
  176. file = "Archive.Arj"; ID = "<AF_ARJ_TEMPLATE>"
  177. call SetData file ID
  178. file = "Archive.Arc"; ID = "<AF_ARC_TEMPLATE>"
  179. call SetData file ID
  180. file = "Archive.Rar"; ID = "<AF_RAR_TEMPLATE>"
  181. call SetData file ID
  182. file = "Archive.Zip"; ID = "<AF_ZIP_TEMPLATE>"
  183. call SetData file ID
  184. file = "Archive.Lzh"; ID = "<AF_LZH_TEMPLATE>"
  185. call SetData file ID
  186.  
  187. Say "  Archive Folder successfully installed!"
  188. Say
  189. Say "  Now copy the ARCHIVER.BB2 file to a directory in your PATH or DPATH."
  190. Say
  191. '@pause'
  192.  
  193. return
  194.  
  195.  
  196. SetData:
  197. parse arg file ID
  198. updated = 0
  199. if \ exists( "TEMPLATE\"file ) then do
  200.   say "  Creating template" file "with object ID" ID
  201.   if \ SysCreateObject( "WPDataFile", file, "<AF_TEMPS>","TEMPLATE=YES;TYPE=Archive;OBJECTID="ID";","r")
  202.     then Say "  Error creating "file" template! It may already exist."
  203.   else updated = 1
  204. end
  205. else do
  206.   say "  Updating template" file "with object ID" ID
  207.   if \ SysSetObjectData(InstallDir"\TEMPLATE\"file, "OBJECTID="ID";TEMPLATE=YES;TYPE=Archive;") then
  208.     Say "  Error Setting template data!"
  209.   else updated = 1
  210. end
  211. if updated then do
  212.   if SysPutEA( "TEMPLATE\"file, ".TYPE", Type ) <> 0 then
  213.     say "Error putting .TYPE EA"
  214. end
  215. return
  216.  
  217. exists:
  218. arg filename
  219. if stream( filename, 'c', 'query exists') <> ''
  220.   then return 1
  221. else return 0
  222.  
  223.