home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / om9701.zip / os2minst.cmd < prev    next >
OS/2 REXX Batch file  |  1994-09-07  |  7KB  |  205 lines

  1. /***************************************************************************/
  2. /* OS2MInst.Cmd                                                            */
  3. /*                                                                         */
  4. /* Installs the "OS/2 Magazine Article Database"                           */
  5. /*                                                                         */
  6. /* Revisions:                                                              */
  7. /*     09/07/94 1.0 - Created.                                             */
  8. /***************************************************************************/
  9.  
  10.    objectid = '<MA9409>'
  11.  
  12.    FATname = 'OS2MAGS'
  13.    INFname = 'OS!2 Magazine Article Database'
  14.    targetdir = 'OS!2 Mags'
  15.    FATdir = 'OS!2MAGS'
  16.  
  17. /* Load REXX Utility Functions */
  18.  
  19.    if AddRexxUtil( 'SysCreateObject' ) then signal ERROR
  20.    if AddRexxUtil( 'SysFileTree' ) then signal ERROR
  21.    if AddRexxUtil( 'SysSetObjectData' ) then signal ERROR
  22.  
  23. /* Get arguments */
  24.  
  25.    parse upper arg targetdrive sourcepath location extra
  26.  
  27. /* Verify target drive argument */
  28.  
  29.    do forever
  30.    /* Make sure the target drive is a drive letter "d" or "d:" */
  31.       if LENGTH( targetdrive ) > 2 then
  32.          say 'Too many characters - enter a drive letter'
  33.       else if LENGTH( targetdrive ) > 0 then do
  34.          if DATATYPE( SUBSTR( targetdrive, 1, 1 ), 'Mixed case' ) = 0 then
  35.             say 'First character must be a drive letter'
  36.          else do
  37.             if LENGTH( targetdrive ) = 1 then do
  38.                targetdrive = targetdrive':'
  39.                leave
  40.             end  /* Do */
  41.             else do
  42.                if SUBSTR( targetdrive, 2, 1 ) = ':' then
  43.                   leave
  44.                else do
  45.                   say 'Second character must be : or omitted'
  46.                end  /* Do */
  47.             end  /* Do */
  48.          end  /* Do */
  49.       end  /* Do */
  50.    /* Get the target drive */
  51.       say 'Enter drive where OS/2 Magazine Article Database is to be installed:'
  52.       pull targetdrive
  53.    end /* do */
  54.  
  55. /* Verify source path argument */
  56.  
  57.    do forever
  58.    /* Default to current directory */
  59.       if sourcepath = '' then
  60.          sourcepath = '.'
  61.    /* See if the .INF file exists in the given path */
  62.       filespec = sourcepath'\'FATname'.INF'
  63.       fullpath = stream( filespec, 'c', 'query exists' )
  64.       if fullpath = '' then do
  65.          if sourcepath = '.' then
  66.             sourcepath = directory()
  67.          say 'File' FATname'.INF not found in' sourcepath
  68.       end  /* Do */
  69.       else
  70.          leave
  71.    /* Get the path */
  72.       say 'Enter path where installation files are located [.]:'
  73.       pull sourcepath
  74.    end /* do */
  75.  
  76. /* See if the .INF file exists in the given path */
  77.  
  78.    filespec = sourcepath'\'FATname'.ICO'
  79.    iconfull = stream( filespec, 'c', 'query exists' )
  80.    if iconfull = '' then do
  81.       if sourcepath = '.' then
  82.          sourcepath = directory()
  83.       say 'File' FATname'.ICO not found in' sourcepath
  84.    end  /* Do */
  85.  
  86. /* If no location specified, put it on the desktop */
  87.  
  88.    if location = '' then
  89.       location = '<WP_DESKTOP>'
  90.  
  91. /* Suppress command display */
  92.  
  93.    '@echo off'
  94.  
  95. /* See if directory already exists */
  96.  
  97.    curdir = directory()
  98.    newdir = targetdrive'\'targetdir
  99.    if directory( newdir ) = newdir then do
  100.       say 'Directory "'targetdrive'\'targetdir'" (HPFS) already exists'
  101.    /* Change back to original directory */
  102.       call directory curdir
  103.    end  /* Do */
  104.    else do
  105.    /* Create directory */
  106.       'md "'targetdrive'\'targetdir'"'
  107.       if rc = 0 then
  108.          say 'Directory "'targetdrive'\'targetdir'" (HPFS) created'
  109.       else do
  110.       /* Try FAT file system */
  111.          targetdir = FATdir
  112.          INFname = FATname
  113.          newdir = targetdrive'\'targetdir
  114.          if directory( newdir ) = newdir then do
  115.             say 'Directory "'targetdrive'\'targetdir'" (FAT) already exists'
  116.          /* Change back to original directory */
  117.             call directory curdir
  118.          end  /* Do */
  119.          else do
  120.          /* Create FAT directory */
  121.             'md "'targetdrive'\'targetdir'"'
  122.             if rc = 0 then
  123.                say 'Directory "'targetdrive'\'targetdir'" (FAT) created'
  124.             else do
  125.                say 'Unable to create directory on' targetdrive
  126.                signal ERROR
  127.             end  /* Do */
  128.          end  /* Do */
  129.       end  /* Do */
  130.    end  /* Do */
  131.  
  132. /* Check the directory */
  133.  
  134.    rc = SysFileTree( newdir, 'files', 'D', '*+***' )
  135.  
  136.    if rc then do
  137.       say 'SysFileTree command was not successful'
  138.       signal ERROR
  139.    end  /* Do */
  140.  
  141. /* Make sure directory was found */
  142.  
  143.    if files.0 = 0 then do
  144.       say 'Directory' newdir 'was not found'
  145.       say 'This should not occur, since the directory is being created'
  146.       signal ERROR
  147.    end  /* Do */
  148.  
  149. /* Copy the .INF file to the specified directory */
  150.  
  151.    'copy' fullpath '"'targetdrive'\'targetdir'\'INFname'.Inf"' '/v'
  152.    if rc = 0 then
  153.       say INFname'.Inf copied to "'targetdrive'\'targetdir'"'
  154.    else do
  155.       say 'Unable to copy' INFname'.Inf to "'targetdrive'\'targetdir'"'
  156.       signal ERROR
  157.    end  /* Do */
  158.  
  159. /* Create the program object */
  160.  
  161.    classname = 'WPProgram'
  162.    title     = 'OS/2 Magazine^Article Database'
  163.    setup     = 'OBJECTID='objectid';' || ,
  164.                'EXENAME=VIEW.EXE;' || ,
  165.                'PARAMETERS="'targetdrive'\'targetdir'\'INFname'" ABOUT;' || ,
  166.                'ICONFILE='iconfull';' || ,
  167.                'PROGTYPE=PM;'
  168.  
  169.    result = SysCreateObject( classname, title, location, setup, 'f' )
  170.    if result = 1 /* created */ then
  171.       say 'Program object created'
  172.    else do
  173.    /* See if object already exists */
  174.       result = SysSetObjectData( objectid, setup )
  175.       if result = 1 /* updated */ then
  176.          say 'Program object already exists'
  177.       else do
  178.          say 'Unable to create program object'
  179.          signal ERROR
  180.       end  /* Do */
  181.    end  /* Do */
  182.  
  183. /* Exit the REXX procedure */
  184.  
  185.    exit x2d(0000)
  186.  
  187. ERROR:
  188.    exit x2d(1604)
  189.  
  190. /* AddRexxUtil procedure */
  191.  
  192. AddRexxUtil: procedure
  193.  
  194.    parse arg name
  195.  
  196.    if RxFuncQuery( name ) \= 0 /* not registered */ then do
  197.       if RxFuncAdd( name, 'RexxUtil', name ) \= 0 /* not successful */ then do
  198.           say 'Unable to register REXX Utility Function' name
  199.           return 1  /* failure */
  200.       end  /* Do */
  201.    end  /* Do */
  202.  
  203.    return 0  /* success */
  204.  
  205.