home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1995 December / SOFM_Dec1995.bin / pc / os2 / pmview / install.cmd < prev    next >
OS/2 REXX Batch file  |  1995-10-31  |  8KB  |  236 lines

  1. /* REXX program to 1) make Workplace Shell object for PMView, 2) unzip
  2. filters, and 3) create NEWVARS.CMD and/or append to CONFIG.SYS */
  3.  
  4. 'cls'
  5.  
  6. say "Welcome to the PMView installer."
  7. say
  8. reply = GetYesNo("Do you have an older version of PMView installed")
  9. if reply then do
  10.    say "Please run Update instead of this install program. To run Update,"
  11.    say "simply enter UPDATE at the OS/2 prompt."
  12.    exit
  13.    end
  14.    
  15. say "Have you installed PMView before?"
  16.  
  17. say "This program will do the following:"
  18. say ""
  19.  
  20. say "1) It will create a desktop icon for PMView, complete with"
  21. say "   filename associations (so you can double-click on an image"
  22. say "   filename in a drives object to automatically start PMView"
  23. say '   and view that image). The icon will be named "PMView92", since'
  24. say "   we do not want to overwrite any customized PMView icon you"
  25. say "   might have on the desktop."
  26. say ""
  27. say "2) It will unzip the transformation filters."
  28. say ""
  29. say "3) It will append three SET statements to your CONFIG.SYS file."
  30. say ""
  31. say "It will ask your permission before doing any of these steps. If you'd"
  32. say "rather do these steps yourself, please read the file DIY.TXT."
  33. say ""
  34.  
  35. reply = GetYesNo("Have you unzipped the PMView ZIP file yet")
  36. if \reply then do
  37.    say ""
  38.    say "Please unzip the ZIP file into the current directory and then re-run"
  39.    say "this program."
  40.    say ""
  41.    say "Bye for now."
  42.    exit
  43.    end
  44.  
  45. Call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  46. Call sysloadfuncs
  47.  
  48. fullpath=Directory()
  49. if right(fullpath, 1) \= "\" then do
  50.    fullpath = fullpath || "\"
  51.    end
  52. say
  53. say "Okay. Is" fullPath
  54. reply = GetYesNo("the directory where you want to install PMView")
  55. if \reply then do
  56.    say "Please create the directory for PMView, unzip the ZIP file"
  57.    say "there, and run this program from that directory."
  58.    say ""
  59.    say "Bye for now."
  60.    exit
  61.    end
  62.  
  63. say
  64. say "Good. Should I create a desktop icon for PMView, complete with"
  65. reply = GetYesNo("associations")
  66. if reply then do
  67.    drop res.
  68.    call SysFileTree fullpath || "PMVIEW.EXE", res, "OF"
  69.    if res.1 = "RES.1" then do
  70.       say "Hmm, I can't find PMView.EXE here...."
  71.       say "I'm afraid I'll have to stop."
  72.       say
  73.       say "Please make sure to unzip PMView into this directory and"
  74.       say "re-run this program."
  75.       exit
  76.       end
  77.    else do
  78.       assoc = '*.BMP,*.EPS,*.GIF,*.IFF,*.JPG,*.MSP,*.PBM,*.PCD,*.PCX,' ||,
  79.               '*.PGM,*.PIC,*.PNG,*.PPM,*.SHW,*.TGA,*.TIF,'
  80.       Call SysCreateObject 'WPProgram','PMView92','<WP_DESKTOP>','CCVIEW=YES;EXENAME='||fullpath||'\PMVIEW.EXE;PROGTYPE=PM;PARAMETERS=%*;STARTUPDIR='||fullpath||';ASSOCFILTER='||assoc,'R'
  81.       Say "Okay, I've created a desktop icon for PMView."
  82.       end
  83.    end
  84.  
  85. drop filterPath
  86. say
  87. reply = GetYesNo("Do you have Info-Zip's unzip.exe on your path")
  88. if \reply then do
  89.    say "Then I'm afraid I will not be able to set up the filters."
  90.    say "See DIY.TXT for instructions on doing this by hand."
  91.    end
  92. else do
  93.    reply = GetYesNo("Good. Should I set up the transformation filters")
  94.    if reply then do
  95.       drop res.
  96.       filterPath = fullPath || "filters"
  97.       call SysFileTree filterPath, res, "OD"
  98.       if res.1 = "RES.1" then do
  99.          'md filters'
  100.          drop res.
  101.          call SysFileTree filterPath, res, "OD"
  102.          if res.1 = "RES.1" then do
  103.             say
  104.             say "I'm sorry, but I can't seem to create the directory"
  105.             say filterPath
  106.             say "I'm afraid I will have to stop."
  107.             say "Please create this directory for me and re-run"
  108.             say "this program."
  109.             say
  110.             say "Bye for now."
  111.             exit
  112.             end
  113.          end
  114.       'cd filters&&unzip -o -qq ../filters&&cd ..'
  115.       end
  116.    end
  117.  
  118. '@if exist newvars.cmd del newvars.cmd'
  119. call lineout "newvars.cmd", "set pmview_ini=" || fullPath || "pmview.ini"
  120. call lineout "newvars.cmd", "set pmview_help=" || fullpath
  121. if filterPath = "FILTERPATH" then do
  122.    filterPath = fullPath
  123.    end
  124. call lineout "newvars.cmd", "set pmview_filter=" || filterPath
  125. say
  126. say "Okay. Before you run PMView, you need to set 3 environment variables."
  127. reply = GetYesNo("May I append these to your CONFIG.SYS file")
  128. if reply then do
  129.    configName = "\CONFIG.SYS"
  130.    configLen = length(configName)
  131.    reply = GetYesNo("Is your OS/2 CONFIG.SYS file on drive C:")
  132.    if reply then do
  133.       configPath = "c:"
  134.       end
  135.    else do
  136.       configPath = "unknown"
  137.       end
  138.    do until res.1 \= "RES.1"
  139.       if right(configPath, configLen) \= configName then do
  140.          configPath = configPath || configName
  141.          end
  142.       drop res.
  143.       call SysFileTree configPath, res, "OF"
  144.       if res.1 = "RES.1" then do
  145.          say "I can't find" || ' "' || configPath || '".'
  146.          say "In response to the following question, please enter a full" ||,
  147.              " path."
  148.          say "For example, you might enter H:\CONFIG.SYS"
  149.          call charout, "Where does OS/2 find CONFIG.SYS when it boots? "
  150.          pull configPath
  151.          drop res.
  152.          call SysFileTree configPath, res, "OF"
  153.          if res.1 = "RES.1" then do
  154.             say "Yow! I can't find that file!"
  155.             say
  156.             end
  157.          end
  158.       end /* loop*/
  159.    cBaq = left(configPath, length(configPath) - 3) || "baq"
  160.    drop res.
  161.    call SysFileTree cBaq, res, "OF"
  162.    if res.1 \= "RES.1" then do
  163.       call CantBaqup
  164.       end
  165.    else do
  166.       'copy' configPath cBaq
  167.       drop res.
  168.       call SysFileTree cBaq, res, "OF"
  169.       if res.1 = "RES.1" then do
  170.          call CantBaqup
  171.          end
  172.       else do
  173.          call lineout configPath, "rem *** Set up 3 environment" ||,
  174.                                   " variables for PMView"
  175.          call lineout configPath, "set pmview_ini=" || fullPath || "pmview.ini"
  176.          call lineout configPath, "set pmview_help=" || fullpath
  177.          call lineout configPath, "set pmview_filter=" || filterPath
  178.          call lineout configPath
  179.          say
  180.          say "Okay, I've updated CONFIG.SYS"
  181.          say "I've saved a copy of the old version in CONFIG.BAQ in your"
  182.          say "boot directory."
  183.          say "Please shutdown and reboot OS/2 after this installation program"
  184.          say "is done."
  185.          end
  186.       end
  187.    end
  188. else do
  189.    say
  190.    say "Well, all right then."
  191.    say 'You can enter "NEWVARS" at the OS/2 prompt to set the variables'
  192.    say "correctly -- but this will work only for the current OS/2"
  193.    say "session."
  194.    say
  195.    say "To set the variables permanently, for all OS/2 sessions, please"
  196.    say "add the lines from NEWVARS.CMD to your CONFIG.SYS file."
  197.    end
  198.  
  199. say
  200. say "If you added a desktop icon, with associations, I recommend that you"
  201. say "remove any other associations that these file types may have."
  202. say "Basically: If you double-click an image, and some program other"
  203. say "than PMView starts up (and you want PMView to start up), please"
  204. say "remove the association from that other program."
  205. say
  206. say "(For instance, OS/2 defaults to attaching *.BMP/Bitmap associations to"
  207. say "the Icon Editor, and Warp also attaches them to Windows Paintbrush."
  208. say
  209. say "Whew! We're done! Thanks for your patience, and thanks for your"
  210. say "interest in PMView!"
  211.  
  212. exit
  213.  
  214. GetYesNo: procedure
  215. ok = 0
  216. do until ok
  217.    call charout, arg(1) || "? "
  218.    pull reply
  219.    reply = left(reply, 1)
  220.    ok = (reply = "Y") | (reply = "N")
  221.    if \ok then do
  222.       say
  223.       say 'Huh? Please enter "Y" or "N".'
  224.       end
  225.    end /* loop */
  226. return (reply = "Y")
  227.  
  228. CantBaqup: procedure
  229. say d2c(7) d2c(7)
  230. say "Ouch! I cannot make a backup copy of CONFIG.SYS."
  231. say "Therefore, to be safe, I will not modify your CONFIG.SYS file."
  232. say "PLEASE edit CONFIG.SYS by hand, and add the 3 lines"
  233. say "from NEWVARS.CMD."
  234.  
  235. return
  236.