home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / meal186.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1997-09-24  |  4KB  |  136 lines

  1. /**********************************************************/
  2. /*                Meal Planner for OS/2                   */
  3. /*                    Version 1.85                        */
  4. /*                 Installation Program                   */
  5. /*         (C) Copyright 1997 Christopher Hodges          */
  6. /**********************************************************/
  7.  
  8. /* Load system functions. */
  9. Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  10. Call SysLoadFuncs
  11.  
  12. InstallDir = ''
  13. StartupDir = Directory()
  14.  
  15. /* Product Information */
  16. '@cls'
  17. Say 'Meal Planner for OS/2 Version 1.85'
  18. Say '(C) Copyright 1997 Christopher Hodges'
  19. Say 'All rights reserved.'
  20. /* Query installation directory. */
  21.  
  22. Call GetMPlanInstallDir
  23.  
  24. Call Install
  25.  
  26. Exit
  27.  
  28.  
  29. GetMPlanInstallDir:
  30.  
  31.     If InstallDir = '' Then Do
  32.         Say
  33.         Say 'Please enter the directory you wish to install to: '
  34.         Call CharOut, '=> '
  35.         Parse Pull InstallDir
  36.         Say
  37.     End
  38.     If InstallDir = '' Then Do
  39.         Say 'Error: Could not find installation dir.'
  40.         Exit
  41.     End
  42.  
  43.     /* Check if dir exists. */
  44.     If Stream( InstallDir, 'c', 'query exists' ) = '' Then Do
  45.         rc = SysMkDir( InstallDir )
  46.         If rc <> 0 & rc <> 5 Then Do
  47.             Say 'Error: Could not make directory ('InstallDir'), error code = ('rc')'
  48.             Exit
  49.         End
  50.         Else If rc = 0 Then
  51.             Say 'Directory ('InstallDir') created...'
  52.     End
  53.  
  54.     /* Write installation directory. */
  55.     Say 'Installation directory is ('InstallDir')'
  56.     return
  57.  
  58.  
  59. Install:
  60.  
  61.     /* Unpack files. */
  62.  
  63.         /* Unpack file to installation directory. */
  64.         Call ChangeDriveAndPath InstallDir
  65.         Say 'In install directory'
  66.         Copy StartupDir'\HEALTH.EXE' InstallDir
  67.         Copy StartupDir'\HEALTH.HLP' InstallDir
  68.         Copy StartupDir'\*.DTX'      InstallDir
  69.         Copy StartupDir'\*.DTA'      InstallDir
  70.         Copy StartupDir'\*.DOC'      InstallDir
  71.         Copy StartupDir'\*.INI'      InstallDir
  72.         Say
  73.         /* Change back to startup directory. */
  74.         Call ChangeDriveAndPath StartupDir
  75.         If FileSpec( Drive, StartupDir ) <> FileSpec( Drive, InstallDir ) Then
  76.             '@cd 'FileSpec( Drive, InstallDir )'\'
  77.  
  78.  
  79.     /* Create the object. */
  80.  
  81.         Say
  82.         Say 'Creating objects.'
  83.  
  84.         /* Create folder. */
  85.         rc = SysCreateObject(   'WPFolder',,
  86.                                 'Meal Planner',,
  87.                                 '<WP_DESKTOP>',,
  88.                                 'OBJECTID=<Meal_Planner>;',
  89.                                 ';ICONVIEWPOS=33,33,34,34;ALWAYSSORT=YES;',
  90.                                 ,,
  91.                                 'Replace' )
  92.         If rc <> 1 Then Say  'Error: could not create the Meal Planner Folder Object.'
  93.  
  94.         /* Create program. */
  95.         rc = SysCreateObject(   'WPProgram',,
  96.                                 'Meal Planner',,
  97.                                 '<Meal_Planner>',,
  98.                                 'EXENAME='InstallDir'\HEALTH.EXE;STARTUPDIR='InstallDir';OBJECTID=<MPlanner>;',,
  99.                                 'Replace' )
  100.         If rc <> 1 Then Say  'Error: could not create Meal Planner object.'
  101.     
  102.         Call SysSetObjectData '<Meal_Planner>', 'OPEN=DEFAULT;'
  103.  
  104.         say
  105.         say 'Meal Planner successfully installed...'
  106.  
  107.     return
  108.  
  109.  
  110. ChangeDriveAndPath:
  111.     Parse Arg DriveAndPath
  112.  
  113.     /* Get drive and path */
  114.     Say
  115.     Say 'Changing to 'DriveAndPath
  116.     ChangeToDrive = FileSpec( Drive, DriveAndPath )
  117.     ChangeToPath = FileSpec( Path, DriveAndPath )
  118.     ChangeToPath = Left( ChangeToPath, Length( ChangeToPath ) - 1 )
  119.  
  120.     /* Change drive and path. */
  121.     Say 'Changing drive to 'ChangeToDrive
  122.     '@'ChangeToDrive
  123.     If rc <> 0 Then Do
  124.         Say 'Error: could not change drive.'
  125.         Exit
  126.     End
  127.     Say 'Changing directory to 'ChangeToPath
  128.     '@cd 'ChangeToPath
  129.     If rc <> 0 Then Do
  130.         Say 'Error: could not change directory.'
  131.         Exit
  132.     End
  133.  
  134.     return
  135.  
  136.