home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1995 December / SOFM_Dec1995.bin / pc / os2 / mathmate / mminstal.cmd < prev    next >
OS/2 REXX Batch file  |  1995-10-31  |  3KB  |  134 lines

  1. /***************************************************/
  2. /*  MMINSTAL.CMD : Build MathMate Desktop objects  */
  3. /***************************************************/
  4.  
  5. Address CMD
  6.  
  7. '@echo off'
  8.  
  9. Parse Arg target_dir .
  10.  
  11. If Pos('?',target_dir) <> 0 Then
  12.    Call Usage
  13.  
  14. If target_dir = '' Then Do
  15.    Say 'Enter path where to install MathMate'
  16.    Parse Pull target_dir .
  17.    If target_dir = '' Then Call Usage
  18. End
  19.  
  20. Call RXFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  21. Call SysLoadFuncs
  22.  
  23. Call Setlocal
  24.  
  25. Parse Source . . CmdFile .
  26. SourceFile = FileSpec("drive",CmdFile) || ,
  27.              FileSpec("path",CmdFile) || 'mmdata.exe'
  28.  
  29. If \FileExists(SourceFile) Then
  30.       Call ErrorMsg 'File "' || SourceFile || '" not found'
  31.  
  32. If LastPos("\",target_dir) <> Length(target_dir) Then
  33.    target_dir = target_dir || "\"
  34.  
  35. Parse Upper Value FileSpec("drive",target_dir) With Drive
  36.  
  37. If WordPos(Drive,SysDriveMap('C:','USED')) = 0 Then
  38.    Call ErrorMsg 'Drive "' || Drive || '" not detected'
  39.  
  40. Path = DelStr(FileSpec("path",target_dir),1,1)
  41.  
  42. Drive
  43. 'cd \'
  44.  
  45. Do Forever
  46.    Parse Var Path loc_dir '\' Path
  47.    If loc_dir = "" Then Leave
  48.    If Directory(loc_dir) <> "" Then Iterate
  49.    If SysMkDir(loc_dir) <> 0 Then
  50.       Call ErrorMsg 'Cannot create directory "' || loc_dir || '"'
  51.    Call Directory loc_dir
  52. End
  53.  
  54. /* Copy files */
  55.  
  56. Say 'Copying source files...'
  57.  
  58. SourceFile' -uo > nul'
  59. If rc <> 0 Then
  60.    Call ErrorMsg 'The source file is corrupted'
  61.  
  62. Say 'Adding Workplace Shell Objects...'
  63.  
  64. iconparm  = 'ICONFILE=' || target_dir || 'mm.ico;'
  65.  
  66. classname = 'WPFolder'
  67. title     = 'MathMate 1.1 for OS/2'
  68. location  = '<WP_DESKTOP>'
  69. setup     = 'OBJECTID=<MM_FOLDER>;' || iconparm
  70. Call SysCreateObject classname, title, location, setup, 'r'
  71.  
  72. iconparm  = 'ICONFILE=' || target_dir || 'mathmate.ico;'
  73.  
  74. classname = 'WPProgram'
  75. title     = 'MathMate 1.1'
  76. location  = '<MM_FOLDER>'
  77. setup     = 'EXENAME='target_dir'mathmate.exe;' ||,
  78.             'PROGTYPE=PM;' ||,
  79.             'STARTUPDIR=' || target_dir || ';' || iconparm
  80. Call SysCreateObject classname, title, location, setup, 'r'
  81.  
  82. classname = 'WPProgram'
  83. title     = 'MathMate Information'
  84. location  = '<MM_FOLDER>'
  85. setup     = 'EXENAME=view.exe;' ||,
  86.             'PROGTYPE=PM;' ||,
  87.             'PARAMETERS=' || target_dir || 'mathmate.inf;' ||,
  88.             'STARTUPDIR=' || target_dir || ';' 
  89. Call SysCreateObject classname, title, location, setup, 'r'
  90.  
  91. Say 'Installation complete'
  92. Say ''
  93.  
  94. Call SysDropFuncs
  95.  
  96. 'Type readme'
  97. Say ''
  98.  
  99. Call Endlocal
  100.  
  101. Exit
  102.  
  103. /*
  104.  * FileExists
  105.  */
  106.  
  107. FileExists:
  108.    return( stream( arg(1), 'c', 'query exists' ) <> '' )
  109.  
  110. /*
  111.  * Usage
  112.  */
  113.  
  114. Usage:
  115.    Say ''
  116.    Say 'Usage: mminstal [target_dir]'
  117.    Say ''
  118.    Say '   target_dir  = path where to install MathMate'
  119.    Say ''
  120.    Say 'This program builds various Workplace Shell objects'
  121.    Say 'needed to run MathMate.'
  122.    Exit
  123.  
  124. /*
  125.  * ErrorMsg
  126.  */
  127.  
  128. ErrorMsg:
  129.    Say ''
  130.    Say Arg(1)
  131.    Call Endlocal
  132.    Call SysDropFuncs
  133.    Exit
  134.