home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / os2games.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1994-12-21  |  9KB  |  316 lines

  1. /****************************************************
  2.  *      Copyright (c) IBM Corporation, 1994         *
  3.  *              All Rights Reserved                 *
  4.  ****************************************************
  5.  *                                                  *
  6.  *               32 bit Games Installation          *
  7.  *   HISTORY:                                       *
  8.  *   Version 1.0  20 Dec 94 - Doug Azzarito         *
  9.  ****************************************************/
  10.  
  11.    '@echo off'
  12.    trace off
  13.    PARSE VALUE 1 0 WITH True False .
  14.  
  15.    /* Load in function library */
  16.  
  17.    Call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  18.    Call SysLoadFuncs
  19.  
  20.    /* Tell the user what we're doing */
  21.  
  22.    Say '┌────────────┤ OS/2 32-bit Game Installation ├───────────┐'
  23.    Say '│ This program will replace the Klondike and Chess games │'
  24.    Say '│ with updated, 32-bit versions of these games.  The old │'
  25.    Say '│ versions will be erased.                               │'
  26.    Say '└────────────────────────────────────────────────────────┘'
  27.    Say 'Do you wish to continue? (Y or N)'
  28.    PARSE PULL Answer
  29.  
  30.    if (TRANSLATE(LEFT(Answer,1)) \='Y') then
  31.      do
  32.        Say 'Install cancelled at your request.'
  33.        exit
  34.      end
  35.  
  36.    /* Parse Call Path Info (ignore OS/2 and call type, just get path */
  37.  
  38.    Parse Source . . callPath
  39.  
  40.    /* Strip program name, leaving source path */
  41.  
  42.    rcp = REVERSE(callPath)
  43.    SrcPath = REVERSE(substr(rcp,POS("\",rcp)+1))
  44.  
  45.    /* Define list of files to be copied and deleted */
  46.  
  47.    PgmFiles. = ""
  48.    PgmFiles.0 = 5
  49.    PgmFiles.1 = "OS2CHESS.EXE"
  50.    PgmFiles.2 = "KLONDIKE.EXE"
  51.    PgmFiles.3 = "OS2CHESS.BIN"
  52.    PgmFiles.4 = "CARDSYM.FON"
  53.    PgmFiles.5 = "GAMEREAD.ME"
  54.  
  55.    DllFiles. = ""
  56.    DllFiles.0 = 1
  57.    DllFiles.1 = "CHESSAI.DLL"
  58.  
  59.    HlpFiles. = ""
  60.    HlpFiles.0 = 2
  61.    HlpFiles.1 = "OS2CHESS.HLP"
  62.    HlpFiles.2 = "KLONDIKE.HLP"
  63.  
  64.    DelFiles. = ""
  65.    DelFiles.0 = 3
  66.    DelFiles.1 = "DLL\KLONBGA.DLL"
  67.    DelFiles.2 = "KLONDIKE.INI"
  68.    DelFiles.3 = "OS2CHESS.INI"
  69.  
  70.    /* find "OS2\APPS" in path, to see what drive the apps are on */
  71.  
  72.    PathStr = TRANSLATE(VALUE("PATH",,"OS2ENVIRONMENT"))
  73.    InsPathPos = POS(":\OS2\APPS;",PathStr)
  74.    if (InsPathPos \= 0) then
  75.      do
  76.        InsPath = Substr(PathStr,InsPathPos-1,11)
  77.  
  78.        /* Make sure this guy exists - create if not.*/
  79.  
  80.        rc = SysFileTree(InsPath,"dirfind","DO")
  81.        if (dirfind.0 = 0) then
  82.          do
  83.            rc = SysMkDir(InsPath)
  84.            if rc \= 0 then
  85.              do
  86.                Say 'ERROR: The target directory, 'InsPath' could not be created.'
  87.                Say '       Installation is aborted.'
  88.                Call Done
  89.              end
  90.          end          /* end if dirfind.0 = 0 */
  91.      end              /* end if InsPathPos \=0 */
  92.    else do
  93.    /* \OS2\APPS is a required path directory! */
  94.  
  95.      Say 'ERROR: The PATH statement does not include "\OS2\APPS."'
  96.      Say '       OS/2 Installation creates this directory and places it in the'
  97.      Say '       PATH environment (in CONFIG.SYS) when you install the original'
  98.      Say '       OS/2 game applets.  To correct this error, use "Selective Install"'
  99.      Say '       to install the original OS/2 game applets.  Then retry this'
  100.      Say '       installation.'
  101.      call Done
  102.    end
  103.  
  104.    /* Look for a \DLL subdirectory inside the APPS subdirectory */
  105.  
  106.    rc = SysFileTree(InsPath||"\DLL","dirfind","DO")
  107.    if (dirfind.0 = 1) then
  108.      do
  109.        InsDllPath = dirfind.1
  110.      end
  111.    else do
  112.      Say 'ERROR: The directory "\OS2\APPS\DLL" was not found.'
  113.      Say '       OS/2 Installation creates this directory and places it in the'
  114.      Say '       LIBPATH environment (in CONFIG.SYS) when you install the original'
  115.      Say '       OS/2 game applets.  To correct this error, use "Selective Install"'
  116.      Say '       to install the original OS/2 game applets.  Then retry this'
  117.      Say '       installation.'
  118.      call Done
  119.    end
  120.  
  121.    /* Look for \OS2\HELP in the HELP environment variable */
  122.  
  123.   HelpWarn = False
  124.    PathStr = TRANSLATE(VALUE("HELP",,"OS2ENVIRONMENT"))
  125.    HlpPathPos = POS(":\OS2\HELP;",PathStr)
  126.    if (HlpPathPos \= 0) then
  127.      do
  128.        InsHlpPath = Substr(PathStr,HlpPathPos-1,11)
  129.        /* Make sure this guy exists - create if not.*/
  130.  
  131.        rc = SysFileTree(InsHlpPath,"dirfind","DO")
  132.        if (dirfind.0 = 0) then
  133.          do
  134.            rc = SysMkDir(InsHlpPath)
  135.            if rc \= 0 then
  136.              do
  137.                Say 'ERROR: The target directory, 'InsHlpPath' could not be created.'
  138.                Say '       Installation is aborted.'
  139.                Call Done
  140.              end
  141.          end          /* end if dirfind.0 = 0 */
  142.      end              /* end if HlpPathPos \=0 */
  143.    else do
  144.      InsHlpPath = InsPath            /* Put HELP in pgm directory */
  145.  
  146.      Say 'WARNING: The HELP statement does not include "\OS2\HELP."'
  147.      Say '         OS/2 installation creates the \OS2\HELP subdirectory, and adds'
  148.      Say '         a SET HELP statement to CONFIG.SYS.  All standard help files'
  149.      Say '         (including the original game help files) should be here.'
  150.      Say '         The new HELP files will be placed in 'InsHlpPath'.  You should'
  151.      Say '         either move them to a directory in your HELP path, or add'
  152.      Say '         'InsHlpPath' to your HELP path.  Your current HELP path is:'
  153.      Say PathStr
  154.      Say ''
  155.      HelpWarn = True
  156.    end
  157.  
  158.    /* Verify Source Files */
  159.  
  160.    do i = 1 to PgmFiles.0
  161.      rc = VerifySourcePath( SrcPath||'\'||PgmFiles.i )
  162.      if ( rc == 1 ) then
  163.        call Done
  164.    end
  165.  
  166.    do i = 1 to DllFiles.0
  167.      rc = VerifySourcePath( SrcPath||'\'||DllFiles.i )
  168.      if ( rc == 1 ) then
  169.        call Done
  170.    end
  171.  
  172.    do i = 1 to HlpFiles.0
  173.      rc = VerifySourcePath( SrcPath||'\'||HlpFiles.i )
  174.      if ( rc == 1 ) then
  175.        call Done
  176.    end
  177.  
  178.    /* Copy files
  179.    */
  180.    do i = 1 to PgmFiles.0
  181.      success = CopyFiles(PgmFiles.i, SrcPath, InsPath)
  182.      if ( success \= 0 ) then
  183.        call Done
  184.    end
  185.  
  186.    do i = 1 to DllFiles.0
  187.      success = CopyFiles(DllFiles.i, SrcPath, InsDllPath)
  188.      if ( success \= 0 ) then
  189.        call Done
  190.    end
  191.  
  192.    do i = 1 to HlpFiles.0
  193.      success = CopyFiles(HlpFiles.i, SrcPath, InsHlpPath, HelpWarn)
  194.      if ( success \= 0 ) then
  195.        call Done
  196.    end
  197.  
  198.    do i = 1 to DelFiles.0
  199.      success = DeleteFiles(DelFiles.i, InsPath)
  200.    end
  201.  
  202.    if (success == 0) then
  203.      call UpdateWPShell InsPath
  204.  
  205.    Say '32-bit game installation complete.'
  206. Done:
  207.    exit
  208.  
  209. /* Procedures and Functions
  210. */
  211.  
  212. VerifySourcePath: Procedure
  213.  
  214.    Parse Arg file;
  215.  
  216.    fExists = Stream(file,'c','query exists')
  217.    if (fExists == "")
  218.      then do
  219.        Say 'ERROR: The file 'file' does not exist.'
  220.        Say '       This file is required to install the 32-bit games.'
  221.        Say '       To correct this error, place ALL 32-bit game files in the same'
  222.        Say '       directory and restart this installation.'
  223.        return 1
  224.      end
  225.  
  226. return 0
  227.  
  228. CopyFiles: Procedure expose True False
  229.  
  230.    Parse Arg FileName, SrcPath, TargetPath, Warning;
  231.  
  232.    copystr = SrcPath||"\"||FileName||" "||TargetPath||" > nul 2>&1"
  233.    If (Warning = True) then
  234.      MsgStr = ' copied.  (should be in the HELP path)'
  235.    else
  236.      MsgStr = ' copied.'
  237.  
  238.    'copy 'copystr
  239.  
  240.    if (rc \= 0) then
  241.      do
  242.        Say 'ERROR: Could not copy 'FileName' from'
  243.        Say '       'SrcPath' to 'TargetPath'.'
  244.        Say '       Installation is aborted.'
  245.        return 1
  246.      end
  247.      else Say TargetPath||"\"||FileName||msgstr
  248.  
  249. return 0
  250.  
  251. DeleteFiles: Procedure
  252.  
  253.    Parse Arg FileName, SrcPath;
  254.  
  255.    delstr = SrcPath||"\"||FileName||" > nul 2>&1"
  256.  
  257.    'del 'delstr
  258.  
  259.    if (rc = 0) then
  260.        Say SrcPath||"\"||FileName' deleted.'
  261.  
  262. return 0
  263.  
  264. UpdateWPShell: Procedure
  265.  
  266.    Parse Arg InsPath;
  267.  
  268.   /* delete the ORIGINAL games if they exist */
  269.  
  270.    Say 'Deleting old program objects'
  271.    rc = SysDestroyObject("<WP_KLDK>")
  272.    rc = SysDestroyObject("<WP_CHESS>")
  273.  
  274.    /* Create Program Object in the "Games" Folder */
  275.    pgmpath   = InsPath||'\OS2CHESS.EXE'
  276.    classname = 'WPProgram'
  277.    title     = '32-Bit Chess'
  278.    location  = '<WP_GAMES>'
  279.    setup     = 'OBJECTID=<WP_CHESS_32>;'||,
  280.                'EXENAME='||pgmpath||';'||,
  281.                'PROGTYPE=PM;'
  282.  
  283.    Say 'Creating 32-bit Chess object'
  284.    rc = SysCreateObject(classname, title, location, setup, 'replace')
  285.  
  286.    pgmpath   = InsPath||'\KLONDIKE.EXE'
  287.    classname = 'WPProgram'
  288.    title     = '32-Bit Solitaire'
  289.    location  = '<WP_GAMES>'
  290.    setup     = 'OBJECTID=<WP_KLDK_32>;'||,
  291.                'EXENAME='||pgmpath||';'||,
  292.                'PROGTYPE=PM;'
  293.  
  294.    Say 'Creating 32-bit Solitaire object'
  295.    rc = SysCreateObject(classname, title, location, setup, 'replace')
  296.  
  297.    pgmpath   = InsPath||'\GAMEREAD.ME'
  298.    classname = 'WPShadow'
  299.    title     = 'GAMEREAD.ME'
  300.    location  = '<WP_GAMES>'
  301.    setup     = 'OBJECTID=<WP_GAMEREAD>;'||,
  302.                'SHADOWID='||pgmpath||';'
  303.  
  304.    Say 'Creating Read-Me object'
  305.    rc = SysCreateObject(classname, title, location, setup, 'replace')
  306.  
  307.    /* Open "Games" Folder
  308.    */
  309.    object    = '<WP_GAMES>'
  310.    setup     = 'OPEN=DEFAULT'
  311.  
  312.    rc = SysSetObjectData(object, setup)
  313.  
  314. return
  315.  
  316.