home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / roids23.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1994-09-11  |  4KB  |  119 lines

  1. /* Roids 2.3 installation program */
  2.  
  3.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'    /* Make REXX functions available */
  4.   Call SysLoadFuncs
  5.  
  6.   Parse Arg InstallDir                         /* Command line parameter */
  7.   Signal On Halt Name ErrorHandler                   /* Error handler */
  8.  
  9.   Call SysCls
  10.   Say
  11.   Say
  12.   Say " Roids 2.3 Installation "
  13.   Say " ---------------------- "
  14.  
  15.   If InstallDir=" " Then Do                    /* If no path is given, get one from the user */
  16.     Say
  17.     Say " Please specify the name of the subdirectory to"
  18.     Say " which you would like to install Roids, hit <Enter>"
  19.     Say " to use the current directory, or type 'Q'<Enter>"
  20.     Say " to quit."
  21.     Say
  22.     Say " For Example:    C:\OS2\ROIDS<Enter>"
  23.     Say
  24.     Say " Please specify:"                    /* Prompt for input */
  25.  
  26.     Parse Value SysCurPos() with Row Col
  27.     Col=Col+17
  28.     Row=Row-1
  29.     Call SysCurPos Row, Col
  30.     Pull InstallDir
  31.     If (InstallDir="Q")|(InstallDir="q") Then Exit        /* Quit if they hit 'Q' */
  32.   End
  33.  
  34.   Say                                /* Give a nice blank line */
  35.  
  36.   CurrentDir = directory()                    /* Find the current directory */
  37.   
  38.   If (InstallDir=" ") Then InstallDir=CurrentDir        /* Set to the current directory if none given */
  39.  
  40.    If (CurrentDir\=directory(InstallDir)) Then Do                /* If installing to different dir, do copying bit */
  41.     Command = '@CD 'directory(CurrentDir)            /* Switch back to installation dir */
  42.     Command
  43.  
  44.     Call SysFileTree InstallDir, FileDirectory, 'D'        /* Search for new directory */
  45.  
  46.     If FileDirectory.0='0' Then Do                /* If not found, create it */
  47.       Say " Now creating directory "InstallDir" . . ."
  48.       rc=SysMkDir(InstallDir)
  49.       If rc\=0 Then Do
  50.     Say
  51.     Say " UURGH! Sorry, the desired directory couldn't be created,"
  52.     Say " probably because you specified an invalid directory name"
  53.     Say " or the destination disk is write-protected.  Please re-run"
  54.         Say " this command file and try again."
  55.     Exit
  56.       End
  57.     End
  58.  
  59.     Say " Now copying files to "InstallDir" . . ."                      /* Now copy files */
  60.     Call FileCopy 'INSTALL.CMD', InstallDir
  61.     Call FileCopy 'ROIDS.EXE', InstallDir
  62.     Call FileCopy 'ROIDS.HLP', InstallDir
  63.     Call FileCopy 'README.TXT', InstallDir
  64.     Call FileCopy '*.WAV', InstallDir
  65.   End
  66.  
  67.   Say " Now creating/updating WPS program object . . ."            /* Now create/update the Desktop object*/                                       
  68.  
  69.   LastChar = substr(InstallDir,length(InstallDir),1)            /* See if directory terminates in a \ */
  70.  
  71.   If LastChar = "\" Then SetupString="EXENAME="InstallDir"ROIDS.EXE;STARTUPDIR="InstallDir
  72.   Else SetupString="EXENAME="InstallDir"\ROIDS.EXE;STARTUPDIR="InstallDir
  73.  
  74.   rc=SysCreateObject("WPProgram","Roids 2.3","<WP_DESKTOP>",SetupString,UPDATE)
  75.   If rc=0 Then Do
  76.     Say
  77.     Say " HUUURK! Sorry, couldn't create the Roids program object." 
  78.     Exit  
  79.   End
  80.  
  81.   Say " Now you get to read the README.TXT file . . ."
  82.  
  83.   Command='@E README.TXT'                    /* Look at the README.TXT */
  84.   Command
  85.  
  86.   Say
  87.   Say " Hooray!  Roids 2.3 has been installed successfully!"
  88.  
  89.   Exit
  90.  
  91.  
  92. /******* FileCopy procedure */
  93.  
  94.   FileCopy: Arg FileName, Destination
  95.     
  96.     Command='@Copy 'FileName' 'Destination' >NUL'
  97.     Command
  98.     If rc\=0 Then Do                        /* Error copying file */
  99.       Say
  100.       Say " AAAGH! Error copying files. This is probably because"
  101.       Say " the destination disk is write protected (a CD-ROM, for"
  102.       Say " example) or a file is missing.  Please make sure that"
  103.       Say " this program can find all the files listed in the"
  104.       Say " README.TXT file and ensure that the destination disk"
  105.       Say " isn't write protected, and try again."
  106.       Exit
  107.     End
  108.     Return
  109.  
  110.  
  111. /******* ErrorHandler procedure */
  112.  
  113.   ErrorHandler:
  114.  
  115.     Call SysCls
  116.     Say " EEEEEH! Unknown error! - aborting installation . . ."
  117.   Exit
  118.  
  119.