home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / rxtt28.arj / RXTT28.ZIP / install.cmd < prev    next >
Encoding:
Text File  |  1997-10-24  |  8.3 KB  |  210 lines

  1. /* ------------------------------------------------------------------ */
  2. /* CMD to create (or update) the object for REXX Tips & Tricks        */
  3. /*                                                                    */
  4. /* The default is on the desktop, but if you have already an object   */
  5. /* for an older version of RXT&T this program will update that        */
  6. /* object.                                                            */
  7. /*                                                                    */
  8. /* Usage: INSTALL {os2BootDrive}                                      */
  9. /*                                                                    */
  10. /* where: os2BootDrive - drive specifier for the boot drive           */
  11. /*                       (e.g. C:, default: Search the boot drive)    */
  12. /*                                                                    */
  13. /*                                                                    */
  14. /* Initial Release: 26.12.1995 /bs                                    */
  15. /*                                                                    */
  16. /* Last update:     24.10.1997 /bs                                    */
  17. /*                                                                    */
  18. /*                                                                    */
  19. /* ------------------------------------------------------------------ */
  20.  
  21.                         /* check & process the parameter              */
  22.   parse arg OS2BootDrive
  23.   OS2BootDrive = substr( translate( strip( OS2BootDrive ) ),1,2 )
  24.   if OS2BootDrive <> '' then
  25.   do
  26.     if stream( OS2BootDrive || '\CONFIG.SYS', 'c', 'QUERY EXIST' ) = '' then
  27.     do
  28.                         /* show the usage                             */
  29.       say 'Usage: INSTALL {os2BootDrive}'
  30.       say ''
  31.       say 'Default: Search the OS/2 boot drive'
  32.       exit 253
  33.     end /* if stream( ... */
  34.   end /* if OS2BootDrive <> '' then */
  35.  
  36.                         /* init the return code                       */
  37.   thisRC = 255
  38.  
  39.                         /* init some global variables                 */
  40.   fileMask =          'RXTT*.INF'
  41.   fixedName =         'RXTT'
  42.   defaultTitle =      'REXX Tips & Tricks'
  43.   curObjectID =       '<RXTT>'
  44.   defaultLocation =   '<WP_DESKTOP>'
  45.  
  46.                         /* show the logo                              */
  47.   say ''
  48.   say center( 'Installation program for REXX Tips & Tricks', 79 )
  49.   say center( '===========================================', 79 )
  50.   say ''
  51.  
  52.                         /* install some error handler                 */
  53.   signal on halt name UserAbort
  54.   signal on syntax name RexxUtilNotFound
  55.  
  56.   say ' Loading REXXUTIL ... '
  57.   
  58.                         /* load REXXUTIL                              */
  59.   call rxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  60.   call SysLoadFuncs
  61.  
  62.                         /* turn on the default error handler again    */
  63.   signal off Syntax
  64.  
  65.                         /* search the OS/2 boot drive                 */
  66.   if OS2BootDrive = '' then
  67.   do
  68.     say ' Searching the boot drive. Please wait ...'
  69.     OS2BootDrive = SearchbootDrive()
  70.  
  71.     say ' ... Bootdrive "' || OS2BootDrive || '" found.'
  72.   end /* if OS2BootDrive = '' then */
  73.  
  74.  
  75.   say ' Searching the newest version of ' || defaultTitle || ' ...'
  76.  
  77.                         /* search RXTT*.INF                           */
  78.   call SysFileTree fileMask, 'infFileStem' , 'FO'
  79.  
  80.                         /* get the newest version                     */
  81.   curInfFileVersion = '00'
  82.  
  83.   do i = 1 to infFileStem.0
  84.     parse upper var infFileStem.i (fixedName) infFileVersion '.' .
  85.     if infFileVersion > curInfFileVersion then
  86.     do
  87.       curInfFile = infFileStem.i
  88.       curInfFileVersion = infFileVersion
  89.     end /* infFileVersion > curInfFileVersion then */
  90.   end /* do i = 1 to infFileStem.0 */
  91.  
  92.                         /* check, if we found a version of RXT&T      */  
  93.   if curInfFileVersion <> '00' then
  94.   do
  95.     curtitle = strip( getTitle( '"' || curInfFile || '"' ) )
  96.     curTitle = translate( curTitle, '^', ',' )
  97.  
  98.     say ' ... version "' || curTitle || '" found.'
  99.     say ''
  100.     say ' Should I create an object for "' || curTitle || '" (Y/n)? '
  101.     userResponse = substr( strip( translate( SysGetKey( 'NOECHO' ) ) ),1,1 )
  102.     if UserResponse = 'N' then 
  103.       signal UserAbort
  104.  
  105.     say ' Creating the object ...'
  106.  
  107.                         /* create the object                          */
  108.     tempRC = SysCreateObject( 'WPProgram' ,,
  109.                               curTitle ,,
  110.                               defaultLocation ,,
  111.                              'EXENAME=' || OS2BootDrive || '\OS2\VIEW.EXE;' || ,
  112.                              'PARAMETERS="' || curInfFile || '";' || ,
  113.                              'STARTUPDIR=' || OS2BootDrive || '\;' || ,
  114.                              'TITLE=' || curTitle || ';' || ,
  115.                              'OBJECTID=' || curObjectID || ';' ,,
  116.                              'U' )
  117.  
  118.     if tempRC = 1 then
  119.     do
  120.       thisRC = 0
  121.       say ' ... object created.'
  122.     end /* if tempRC = 1 then */
  123.     else
  124.       say 'Error creating the object!'
  125.  
  126.   end /* if curInfFileVersion <> '00' then */
  127.   else
  128.     say 'Error: ' || defaultTitle || ' not found!'
  129.  
  130. exit thisRC
  131.  
  132. /* ------------------------------------------------------------------ */
  133. /* function:   search the boot drive                                  */
  134. /*                                                                    */
  135. /* parameters: none                                                   */
  136. /*                                                                    */
  137. /* returns:    boot drive (e.g. "C:")                                 */
  138. /*                                                                    */
  139. SearchBootDrive: PROCEDURE 
  140.  
  141.                         /* install a local error handler              */
  142.   signal on syntax name BootDriveNotFound
  143.  
  144.                     /* try the new function from the new REXXUTIL DLL */
  145.   OS2BootDrive = SysBootDrive()
  146.  
  147. BootDriveNotFound:
  148.  
  149.   if symbol( 'OS2BootDrive' ) <> 'VAR' then
  150.   do
  151.                         /* new REXXUTIL DLL not found  --             */
  152.                         /* use the old method                         */
  153.     OS2BootDrive = substr( value( 'RUNWORKPLACE' ,, 'OS2ENVIRONMENT' ), 1,2 )
  154.  
  155.     if OS2BootDrive = '' then
  156.       OS2BootDrive = substr( value( 'COMSPEC' ,, 'OS2ENVIRONMENT' ), 1,2 )
  157.  
  158.     if OS2BootDrive = '' then
  159.       OS2BootDrive = 'C:'
  160.  
  161.   end /* if symbol( 'OS2BootDrive' ) <> 'VAR' then */  
  162. RETURN OS2BootDrive
  163.  
  164. /* ------------------------------------------------------------------ */
  165. /* function:   get the title of an INF file                           */
  166. /*                                                                    */
  167. /* parameters: fully qualified path of the INF file                   */
  168. /*                                                                    */
  169. /* returns:    the title of the INF file                              */
  170. /*                                                                    */
  171. GetTitle: PROCEDURE
  172.   parse arg '"' infFile '"'
  173.  
  174.                         /* init the return code                       */
  175.   thisTitle = ''
  176.          
  177.                         /* read the header of the INF file            */
  178.   thisRC = stream( infFile'"', 'c', 'OPEN READ' )
  179.   infHeader = charIn( infFile, 1,500 )
  180.   thisRC = stream( infFile, 'c', 'CLOSE' )
  181.  
  182.                         /* search the title                           */
  183.   startPos = x2d( '6B' )
  184.  
  185.   do i = 1 to 100
  186.     curChar = substr( infHeader, startPos+i, 1 )
  187.     if curChar = '00'x then
  188.       leave
  189.     else
  190.      thisTitle = thisTitle || curChar
  191.   end /* do i=0 to 100 */
  192.  
  193. RETURN thisTitle 
  194.  
  195. /* ------------------------------------------------------------------ */
  196. /* Error handler (called if the DLL REXXUTIL is not found)            */
  197. /*                                                                    */
  198. RexxUtilNotFound:
  199.   say ''
  200.   say 'Error: REXXUTIL.DLL not found!'
  201. exit 255
  202.  
  203. /* ------------------------------------------------------------------ */
  204. /* Error handler (called if the user presses CTRL-BREAK)              */
  205. /*                                                                    */
  206. UserAbort:
  207.   say ''
  208.   say ' Installation aborted by the user.'
  209. exit 254
  210.