home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / drchk034.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-12  |  19KB  |  576 lines

  1. /* installation and INI setup */
  2. call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  3. call SysLoadFuncs
  4. call RxFuncAdd 'VInit','VRexx','VInit'
  5.  
  6. arg par1
  7. if par1='/?' | par1='?' then signal usage
  8. if translate(par1)='/I' then do
  9.     inionly=1
  10.     signal inimake
  11. end
  12.  
  13. if translate(par1)='/O' then do
  14.     objonly=1
  15.     signal objmake
  16. end
  17.  
  18. CurrDir=directory()
  19. do until allok=1
  20.     call SysCls
  21.     call SysCurPos 12,0
  22.     say "Which directory do you wish to install DriveCheck to?"
  23.     call charout ," : "
  24.     parse pull instdir
  25.     if directory(instdir)='' then do until valid=1
  26.         call SysCls
  27.         if valid=0 then do
  28.             call SysCurPos 10,0
  29.             say "Please answer with Y or N."
  30.         end
  31.         call SysCurPos 10,0
  32.         call charout ,"Directory not found.  OK to create? (Y/N) :"
  33.         reply=SysGetKey('echo')
  34.         if translate(reply)\='Y' & translate(reply)\='N' then valid=0
  35.         else do
  36.             valid=1
  37.             if translate(reply)='Y' then do
  38.                 rc=SysMkDir(instdir)
  39.                 if rc\=0 then do
  40.                     allok=0
  41.                     call SysCls
  42.                     call SysCurPos 12,0
  43.                     say "Invalid directory name."
  44.                     say ""
  45.                     say "Press any key to continue..."
  46.                     junk=SysGetKey('noecho')
  47.                 end
  48.                 else allok=1
  49.             end
  50.             else allok=0
  51.         end        
  52.     end    
  53.     else do until confirm=1
  54.         call SysCls
  55.         if confirm=0 then do
  56.             call SysCurPos 10,0    
  57.             say "Please answer with either Y or N."
  58.         end
  59.         call SysCurPos 12,0
  60.         call charout ,"Directory already exists, OK to continue? (Y/N) :"
  61.         ans=SysGetKey('echo')
  62.         if translate(ans)\='Y' & translate(ans)\='N' then confirm=0        
  63.         else do
  64.             confirm=1
  65.             if translate(ans)='Y' then allok=1
  66.             else allok=0
  67.         end
  68.     end
  69. end
  70. call directory CurrDir
  71. '*@copy drivechk.cmd '||instdir||' > nul'
  72. '*@copy readme.txt '||instdir||' > nul'
  73. '*@copy drivechk.ico '||instdir||' > nul'
  74. '*@copy install.cmd '||instdir||' > nul'
  75. call directory instdir
  76.  
  77. inimake:
  78.  
  79. if inionly=1 then do
  80.     call SysCls
  81.     call SysCurPos 12,0
  82.     say "Please enter the directory where DriveCheck is located."
  83.     call charout ,': '
  84.     pull instdir
  85.     if directory(instdir)='' then do
  86.         say ""
  87.         say "Directory not found."
  88.         exit
  89.     end
  90.     else call directory instdir
  91. end
  92. call SysCls
  93. call SysCurPos 12,0
  94. say "We will now create an initialization file that will determine"
  95. say "the default behavior of the visual portion of DriveCheck."
  96. say ""
  97. say "Press Q to skip this part or any other key to continue..."
  98. ch=SysGetKey('noecho')
  99. if translate(ch)='Q' then skipini=1
  100. else skipini=0
  101. if skipini=0 then do
  102.  
  103.     crlf='0d0a'x
  104.     rtable=crlf                             ||,
  105.            '         1) 640x480'crlf        ||,
  106.            '         2) 800x600'crlf        ||,
  107.            '         3) 1024x768'crlf       ||,
  108.            '         4) 1280x1024'crlf      ||,
  109.            '         5) 1600x1200'crlf      ||,
  110.            crlf                             ||,
  111.            'Your choice? :'
  112.     rstring.1="Please select a number corresponding to a resolution on the list."
  113.     rstring.2="If your resolution isn't listed, pick the closest one."
  114.     do until rok=1
  115.         call SysCls
  116.         if rok=0 then do
  117.             call SysCurPos 3,0
  118.             do i=1 to 2
  119.                 call lineout ,rstring.i
  120.             end
  121.         end
  122.         call SysCurPos 6,0
  123.         say "Select the screen resolution your desktop is set to:"
  124.         call charout ,rtable
  125.         ans=SysGetKey('echo')
  126.         if datatype(ans)\='NUM' then rok=0
  127.         else if datatype(ans,'W')\=1 then rok=0
  128.         else if ans<1 | ans>5 then rok=0
  129.         else do
  130.             rok=1
  131.             ScrRes=ResID(ans)
  132.         end
  133.     end
  134.     cstring='Please select a color-corresponded number from the list.'    
  135.     table=crlf                                           ||,
  136.           '     1) Black                 5) Blue'crlf    ||,          
  137.           '     2) White                 6) Cyan'crlf    ||,
  138.           '     3) Red                   7) Yellow'crlf  ||,
  139.           '     4) Green                 8) Pink'crlf    ||,
  140.           crlf                                           ||,
  141.           'Your choice? :'
  142.     
  143.     do until mok=1
  144.         call SysCls
  145.         if mok=0 then do
  146.             call SysCurPos 4,0
  147.             say cstring
  148.         end
  149.         call SysCurPos 6,0
  150.         say "Choose the main window background color from the list,"||crlf||,
  151.             "or press S to skip this choice and use the default:"
  152.         call charout ,table
  153.         ans=SysGetKey('echo')
  154.         if translate(ans)='S' then do
  155.             MainColor='WHITE'
  156.             mok=1
  157.         end
  158.         else if datatype(ans)\='NUM' then mok=0
  159.         else if datatype(ans,'W')\=1 then mok=0
  160.         else if ans<1 | ans>8 then mok=0
  161.         else do
  162.             mok=1
  163.             MainColor=ColorID(ans)
  164.         end    
  165.     end    
  166.     mok=''
  167.     do until mok=1
  168.         call SysCls
  169.         if mok=0 then do
  170.             call SysCurPos 4,0
  171.             say cstring
  172.         end
  173.         call SysCurPos 6,0
  174.         say "Choose the main window text color from the list,"||crlf||,
  175.             "or press S to skip this choice and use the default:"
  176.         call charout ,table
  177.         ans=SysGetKey('echo')
  178.         if translate(ans)='S' then do
  179.             MainTextColor='BLACK'
  180.             mok=1
  181.         end
  182.         else if datatype(ans)\='NUM' then mok=0
  183.         else if datatype(ans,'W')\=1 then mok=0
  184.         else if ans<1 | ans>8 then mok=0
  185.         else do
  186.             mok=1
  187.             MainTextColor=ColorID(ans)
  188.             if MainTextColor=MainColor then do
  189.                 say crlf    
  190.                 say "Note:  You have chosen the same color for both the"
  191.                 say "foreground and background of the Main window.  You"
  192.                 say "won't be able to see a damn thing unless you change it."
  193.                 say ""
  194.                 say "Press any key to continue..."
  195.                 junk=SysGetKey('noecho')
  196.             end    
  197.         end
  198.     end
  199.     do until dok=1
  200.         call SysCls
  201.         if dok=0 then do
  202.             call SysCurPos 4,0
  203.             say cstring
  204.         end
  205.         call SysCurPos 6,0
  206.         say "Choose the directory window background color from the list,"||crlf||,
  207.             "or press S to skip this choice and use the default:"
  208.         call charout ,table
  209.         ans=SysGetKey('echo')
  210.         if translate(ans)='S' then do
  211.             DirColor='CYAN'
  212.             dok=1
  213.         end
  214.         else if datatype(ans)\='NUM' then dok=0
  215.         else if datatype(ans,'W')\=1 then dok=0
  216.         else if ans<1 | ans>8 then dok=0
  217.         else do
  218.             dok=1
  219.             DirColor=ColorID(ans)
  220.         end
  221.     end    
  222.     dok=''
  223.     do until dok=1
  224.         call SysCls
  225.         if dok=0 then do
  226.             call SysCurPos 4,0
  227.             say cstring
  228.         end
  229.         call SysCurPos 6,0
  230.         say "Choose the directory window text color from the list,"||crlf||,
  231.             "or press S to skip this choice and use the default:"
  232.         call charout ,table
  233.         ans=SysGetKey('echo')
  234.         if translate(ans)='S' then do
  235.             DirTextColor='BLACK'
  236.             dok=1
  237.         end
  238.         else if datatype(ans)\='NUM' then dok=0
  239.         else if datatype(ans,'W')\=1 then dok=0
  240.         else if ans<1 | ans>8 then dok=0
  241.         else do
  242.             dok=1
  243.             DirTextColor=ColorID(ans)
  244.             if DirTextColor=DirColor then do
  245.                 say crlf    
  246.                 say "Note:  You have chosen the same color for both the"
  247.                 say "foreground and background of the Directory window.  You"
  248.                 say "won't be able to see a damn thing unless you change it."
  249.                 say ""
  250.                 say "Press any key to continue..."
  251.                 junk=SysGetKey('noecho')
  252.             end    
  253.         end
  254.     end
  255.     do until fok=1
  256.         call SysCls
  257.         if fok=0 then do
  258.             call SysCurPos 4,0
  259.             say cstring
  260.         end
  261.         call SysCurPos 6,0
  262.         say "Choose the file window background color from the list,"||crlf||,
  263.             "or press S to skip this choice and use the default:"
  264.         call charout ,table
  265.         ans=SysGetKey('echo')
  266.         if translate(ans)='S' then do
  267.             FileColor='CYAN'
  268.             fok=1
  269.         end
  270.         else if datatype(ans)\='NUM' then fok=0
  271.         else if datatype(ans,'W')\=1 then fok=0
  272.         else if ans<1 | ans>8 then fok=0
  273.         else do
  274.             fok=1
  275.             FileColor=ColorID(ans)
  276.         end
  277.     end
  278.     fok=''
  279.     do until fok=1
  280.         call SysCls
  281.         if fok=0 then do
  282.             call SysCurPos 4,0
  283.             say cstring
  284.         end
  285.         call SysCurPos 6,0
  286.         say "Choose the file window text color from the list,"||crlf||,
  287.             "or press S to skip this choice and use the default:"
  288.         call charout ,table
  289.         ans=SysGetKey('echo')
  290.         if translate(ans)='S' then do
  291.             FileTextColor='BLACK'
  292.             fok=1
  293.         end
  294.         else if datatype(ans)\='NUM' then fok=0
  295.         else if datatype(ans,'W')\=1 then fok=0
  296.         else if ans<1 | ans>8 then fok=0
  297.         else do 
  298.             fok=1
  299.             FileTextColor=ColorID(ans)
  300.             if FileTextColor=FileColor then do
  301.                 say crlf    
  302.                 say "Note:  You have chosen the same color for both the"
  303.                 say "foreground and background of the File window.  You"
  304.                 say "won't be able to see a damn thing unless you change it."
  305.                 say ""
  306.                 say "Press any key to continue..."
  307.                 junk=SysGetKey('noecho')
  308.             end        
  309.         end
  310.     end
  311.     do until gok=1
  312.         call SysCls
  313.         if gok=0 then do
  314.             call SysCurPos 4,0
  315.             say cstring
  316.         end
  317.         call SysCurPos 6,0
  318.         say "Choose the graph window background color from the list,"||crlf||,
  319.             "or press S to skip this choice and use the default:"
  320.         call charout ,table
  321.         ans=SysGetKey('echo')
  322.         if translate(ans)='S' then do
  323.             GraphColor='BLACK'
  324.             gok=1
  325.         end
  326.         else if datatype(ans)\='NUM' then gok=0
  327.         else if datatype(ans,'W')\=1 then gok=0
  328.         else if ans<1 | ans>8 then gok=0
  329.         else do
  330.             gok=1
  331.             GraphColor=ColorID(ans)
  332.         end
  333.     end
  334.     gok=''
  335.     do until gok=1
  336.         call SysCls
  337.         if gok=0 then do
  338.             call SysCurPos 4,0
  339.             say cstring
  340.         end
  341.         call SysCurPos 6,0
  342.         say "Choose the graph window text color from the list,"||crlf||,
  343.             "or press S to skip this choice and use the default:"
  344.         call charout ,table
  345.         ans=SysGetKey('echo')
  346.         if translate(ans)='S' then do
  347.             GraphTextColor='WHITE'
  348.             gok=1
  349.         end
  350.         else if datatype(ans)\='NUM' then gok=0
  351.         else if datatype(ans,'W')\=1 then gok=0
  352.         else if ans<1 | ans>8 then gok=0
  353.         else do
  354.             gok=1
  355.             GraphTextColor=ColorID(ans)
  356.             if GraphTextColor=GraphColor then do
  357.                 say crlf
  358.                 say "Note:  You have chosen the same color for both the"
  359.                 say "foreground and background of the Graph window.  You"
  360.                 say "won't be able to see a damn thing unless you change it."
  361.                 say ""
  362.                 say "Press any key to continue..."
  363.                 junk=SysGetKey('noecho')
  364.             end        
  365.         end
  366.     end
  367.     do until freeok=1
  368.         call SysCls
  369.         if freeok=0 then do
  370.             call SysCurPos 4,0
  371.             say cstring
  372.         end
  373.         call SysCurPos 6,0
  374.         say "Choose the graph free space color from the list,"||crlf||,
  375.             "or press S to skip this choice and use the default:"
  376.         call charout ,table
  377.         ans=SysGetKey('echo')
  378.         if translate(ans)='S' then do
  379.             FreeColor='WHITE'
  380.             freeok=1
  381.         end
  382.         else if datatype(ans)\='NUM' then freeok=0
  383.         else if datatype(ans,'W')\=1 then freeok=0
  384.         else if ans<1 | ans>8 then freeok=0
  385.         else do
  386.             freeok=1
  387.             FreeColor=ColorID(ans)
  388.         end        
  389.     end
  390.     do until usedok=1
  391.         call SysCls
  392.         if usedok=0 then do
  393.             call SysCurPos 4,0
  394.             say cstring
  395.         end
  396.         call SysCurPos 6,0
  397.         say "Choose the graph used space color from the list,"||crlf||,
  398.             "or press S to skip this choice and use the default:"
  399.         call charout ,table
  400.         ans=SysGetKey('echo')
  401.         if translate(ans)='S' then do
  402.             UsedColor='GREEN'
  403.             usedok=1
  404.         end
  405.         else if datatype(ans)\='NUM' then usedok=0
  406.         else if datatype(ans,'W')\=1 then usedok=0
  407.         else if ans<1 | ans>8 then usedok=0
  408.         else do
  409.             usedok=1
  410.             UsedColor=ColorID(ans)
  411.         end        
  412.     end
  413.     do until wasteok=1
  414.         call SysCls
  415.         if wasteok=0 then do
  416.             call SysCurPos 4,0
  417.             say cstring
  418.         end
  419.         call SysCurPos 6,0
  420.         say "Choose the graph wasted space color from the list,"||crlf||,
  421.             "or press S to skip this choice and use the default:"
  422.         call charout ,table
  423.         ans=SysGetKey('echo')
  424.         if translate(ans)='S' then do
  425.             WasteColor='RED'
  426.             wasteok=1
  427.         end
  428.         else if datatype(ans)\='NUM' then wasteok=0
  429.         else if datatype(ans,'W')\=1 then wasteok=0
  430.         else if ans<1 | ans>8 then wasteok=0
  431.         else do
  432.             wasteok=1
  433.             WasteColor=ColorID(ans)
  434.         end        
  435.     end
  436.     if FreeColor=UsedColor | FreeColor=WasteColor |,
  437.         WasteColor=UsedColor then do
  438.             say crlf
  439.             say "Warning:  One or more graph colors are the same, and will"
  440.             say "inhibit the usefulness of the graph.  You should change"
  441.             say "them to different colors."
  442.             say ""
  443.             say "Press any key to continue..."
  444.             junk=SysGetKey('noecho')
  445.     end
  446.     inifile='drivechk.ini'
  447.     call SysFileDelete inifile
  448.     call lineout inifile,MainColor
  449.     call lineout inifile,MainTextColor
  450.     call lineout inifile,DirColor
  451.     call lineout inifile,DirTextColor
  452.     call lineout inifile,FileColor
  453.     call lineout inifile,FileTextColor
  454.     call lineout inifile,GraphColor
  455.     call lineout inifile,GraphTextColor
  456.     call lineout inifile,FreeColor
  457.     call lineout inifile,UsedColor
  458.     call lineout inifile,WasteColor
  459.     call lineout inifile,ScrRes     
  460.     do 5
  461.         call lineout inifile,''
  462.     end
  463.     call charout inifile,'Line 1: Background color of main window.'crlf
  464.     call charout inifile,'Line 2: Foreground color of main window.'crlf
  465.     call charout inifile,'Line 3: Background color of directory window.'crlf
  466.     call charout inifile,'Line 4: Foreground color of directory window.'crlf
  467.     call charout inifile,'Line 5: Background color of file window.'crlf
  468.     call charout inifile,'Line 6: Foreground color of file window.'crlf
  469.     call charout inifile,'Line 7: Background color of graph window.'crlf
  470.     call charout inifile,'Line 8: Foreground color of graph window.'crlf
  471.     call charout inifile,'Line 9: Free space color of graphs.'crlf
  472.     call charout inifile,'Line 10: Used space color of graphs.'crlf
  473.     call charout inifile,'Line 11: Wasted space color of graphs.'crlf
  474.     call charout inifile,'Line 12: Screen resolution.'crlf
  475.     call SysCls
  476.     call SysCurPos 12,0
  477.     say "INI file written ("||instdir||"\drivechk.ini)."
  478.     say ""
  479.     say "Press any key to continue..."
  480.     junk=SysGetKey('noecho')
  481. end
  482. if inionly=1 then exit
  483.  
  484. objmake:
  485. if objonly=1 then do
  486.     call SysCls
  487.     call SysCurPos 12,0
  488.     say "Please enter the directory where DriveCheck is located."
  489.     call charout ,': '
  490.     pull instdir
  491.     if directory(instdir)='' then do
  492.         say ""
  493.         say "Directory not found."
  494.         exit
  495.     end
  496. end        
  497.  
  498. call SysCls
  499. call SysCurPos 6,0
  500. say "We will now create a desktop object for DriveCheck.  If you don't"
  501. say "plan on using the Visual REXX portion, you're better off skipping"
  502. say "this and just running DriveCheck from the command line."
  503. say ""
  504. say "The object will be located at the center of your desktop, and its"
  505. say "object ID will be '<DriveCheck>' (case sensitive)."
  506. say ""
  507. say "Press Q to abort object creation, or any other key to continue..."
  508. ans=SysGetKey('noecho')
  509. if translate(ans)='Q' then skipobj=1
  510. else skipobj=0
  511. if skipobj=0 then do
  512.      type='WPProgram'
  513.      name='DriveCheck'
  514.      loc='<WP_DESKTOP>'
  515.      options='OBJECTID=<DriveCheck>;'                           ||,
  516.              'ICONPOS=50,50;'                                   ||,
  517.              'EXENAME='||instdir||'\drivechk.cmd;'              ||,
  518.              'ICONFILE='||instdir||'\drivechk.ico;'             ||,
  519.              'MINIMIZED=YES;'                                   ||,
  520.              'PROGTYPE=WINDOWABLEVIO'
  521.  
  522. rc=SysCreateObject(type,name,loc,options,'R')
  523. say ""
  524. if rc=1 then say "DriveCheck object successfully created."
  525. else say "Unable to create DriveCheck object."
  526. say ""
  527. if objonly=1 then exit
  528. end
  529. say ""
  530. say "DriveCheck installation is complete."
  531. exit
  532.  
  533. usage:
  534.  
  535. say ""
  536. say "DriveCheck installation program."
  537. say ""
  538. say "Usage: install.cmd [/I | /O]"
  539. say ""
  540. say "/I   -  Only prompts for information to create INI file."
  541. say "/O   -  Only creates desktop object."
  542. say ""
  543. say "Run with no parameters to copy the DriveCheck files to a specified"
  544. say "directory, create an INI file, and create a desktop object."
  545. say ""
  546. exit
  547.  
  548. /* Translate number into color */
  549. ColorID: Procedure
  550.  
  551. arg cnum
  552. if cnum=1 then cr='BLACK'
  553. if cnum=2 then cr='WHITE'
  554. if cnum=3 then cr='RED'
  555. if cnum=4 then cr='GREEN'
  556. if cnum=5 then cr='BLUE'
  557. if cnum=6 then cr='CYAN'
  558. if cnum=7 then cr='YELLOW'
  559. if cnum=8 then cr='PINK'
  560.  
  561. return cr
  562. /**/
  563.  
  564. /* Translate number into resolution */
  565. ResID: Procedure
  566.  
  567. arg rnum
  568. if rnum=1 then res='640x480'
  569. if rnum=2 then res='800x600'
  570. if rnum=3 then res='1024x768'
  571. if rnum=4 then res='1280x1024'
  572. if rnum=5 then res='1600x1200'
  573.  
  574. return res
  575. /**/
  576.