home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / jsmutils.zip / os2jobj.cmd < prev    next >
OS/2 REXX Batch file  |  1998-08-01  |  9KB  |  272 lines

  1. /* OS2JOBJ.CMD - CREATE OS/2 program objects on desktop for various Java
  2.                  applications.  Copyright 1998, Charles H. McKinnis */
  3. Trace('N')
  4.  
  5. /* check for OBJREXX */
  6. Parse Version objrexx .
  7. If objrexx = 'OBJREXX' Then orexx = 1
  8. Else orexx = 0
  9.  
  10. /* load REXXUTIL functions */
  11. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  12. Call SysLoadFuncs
  13.  
  14. Parse Upper Source . . our_name .
  15. Parse Value Getpaths(our_name) With our_drive our_base our_path
  16. appl_file = Left(our_name, Lastpos('.', our_name) - 1) || '.ini'
  17. ini_info = SysIni(appl_file, 'ALL:', 'appl.')
  18. appl_ini.0 = 0
  19. Do i = 1 To appl.0
  20.    appl_ini.i = appl.i
  21.    appl_class = Strip(SysIni(appl_file, appl.i, 'applclass'), 'T', '00'x)
  22.    If appl_class <> 'ERROR:' Then Do
  23.       rc = SysFileTree(our_base || '\' || appl_class, 'applclass.', 'FSO')
  24.       If rc = 0 & applclass.0 > 0 Then Do
  25.          j = appl_ini.0
  26.          j = j + 1
  27.          appl_ini.0 = j
  28.          appl_ini.j = appl.i
  29.          appl_class.j = applclass.1
  30.          appl.j = Strip(SysIni(appl_file, appl_ini.j, 'objtitle'), 'T', '00'x)
  31.          appl.j = Translate(appl.j, ' ', '^')
  32.       End
  33.    End
  34. End
  35. If appl_ini.0 > 0 Then Do
  36.    Say 'Select the application to be installed from the following list'
  37.    Do i = 1 To appl_ini.0
  38.       Say i || '. ' appl.i
  39.    End
  40. End
  41. Else Do
  42.    Say 'No applications were found to install'
  43.    Call Exit
  44. End
  45. Do Until 0 < answer <= appl_ini.0
  46.    Parse Upper Pull answer
  47. End
  48.  
  49. appl = appl.answer
  50. appl_ini = appl_ini.answer
  51. appl_class = appl_class.answer
  52. Say 'Do you wish to install' appl '(y,N)?'
  53. Parse Upper Pull answer
  54. If \Abbrev(answer, 'Y') Then call Exit
  55.  
  56. classes.0 = 0
  57. ini_info = Strip(SysIni(appl_file, appl_ini, 'classes'), 'T', '00'x)
  58. Do i = 1 To Words(ini_info) By 2
  59.    j = classes.0
  60.    j = j + 1
  61.    classes.0 = j
  62.    classes.j = Subword(ini_info, i, 2)
  63.    rc = SysFileTree(our_base || '\' || Word(classes.j, 2), 'class.', 'FSO')
  64.    If Word(classes.j, 1) = 1 Then Do
  65.       If rc <> 0 | class.0 = 0 Then Do
  66.          class.1 = SysSearchPath('PATH', Word(classes.j, 2))
  67.          If class.1 <> '' Then classes.j = 1 class.1
  68.          Else Do 
  69.             Say 'Required class' Word(classes.j, 2) 'not found'
  70.             Call Exit
  71.          End
  72.       End
  73.       Else classes.j = 1 class.1
  74.    End
  75.    Else Do
  76.       If rc = 0 & class.0 > 0 Then classes.j = 1 class.1
  77.       Else Do
  78.          class.1 = SysSearchPath('PATH', Word(classes.j, 2))
  79.          If class.1 <> '' Then classes.j = 1 class.1
  80.          Else classes.j = 0 Word(classes.j, 2)
  81.       End
  82.    End
  83. End
  84.  
  85. If orexx Then Do
  86.    file_sys = SysFileSystemType(our_drive)
  87.    If file_sys = 'HPFS' | file_sys = 'FAT' Then Say 'Found' our_path 'on an' file_sys 'drive'
  88.    Else Do
  89.       Say appl 'needs to run from an HPFS or FAT drive'
  90.       Say 'Found' our_path 'on a' file_sys 'drive'
  91.       Call Exit
  92.    End
  93.    boot_drive = SysBootDrive()
  94. End
  95. Else Do
  96.    Say 'Unable to check the file system for' appl
  97.    Say 'If' our_path 'is on an HPFS drive,'
  98.    Say 'enter "HPFS" or "FAT" to continue, or any other answer to quit'
  99.    Parse Upper Pull file_sys .
  100.    If \Abbrev(file_sys, 'HPFS') & \Abbrev(file_sys, 'FAT') Then Call Exit
  101.    boot_drive = Filespec('D', SysSearchPath('PATH', 'PMSHELL.EXE'))
  102. End
  103. ini_info = Strip(SysIni(appl_file, appl_ini, 'hpfs'), 'T', '00'x)
  104. If ini_info & file_sys <> 'HPFS' Then Do
  105.    Say appl 'must run from an HPFS drive'
  106.    Call Exit
  107. End
  108.  
  109. new_queue = Rxqueue('Create')
  110. old_queue = Rxqueue('Set', new_queue)
  111. '@JAVA -fullversion 2>&1|RXQUEUE' new_queue
  112. Parse Pull . 'JDK' java_lvl 'IBM build' java_build .
  113. java_lvl = Space(java_lvl)
  114. java_build = Strip(Space(java_build), , '"')
  115. new_queue = Rxqueue('Set', old_queue)
  116. new_queue = Rxqueue('Delete', new_queue)
  117. If java_lvl < '1.1.4' Then Do 
  118.    Say 'You must be at Java level 1.1.4 or above'
  119.    Call Exit
  120. End
  121. Else Say 'OS/2 Java' java_lvl 'at level' java_build 'detected'
  122.  
  123. ini_info = Strip(SysIni(appl_file, appl_ini, 'objicon'), 'T', '00'x)
  124. obj_icon = our_path || '\' || Word(ini_info, 1)
  125. obj_icon_pos = Subword(ini_info, 2)
  126. startpath = our_path
  127.  
  128. java_name = SysSearchPath('PATH', 'JAVA.EXE')
  129. Parse Value Getpaths(java_name) with java_drive java_base java_path
  130. java_class = 'classes.zip'
  131. rc = SysFileTree(java_base || '\' || java_class, 'class.', 'FSO')
  132. If rc = 0 & class.0 > 0 Then Do
  133.    java_class = class.1
  134.    Say 'Using JAVA class -' java_class
  135. End
  136. Else Do
  137.    Say java_class 'not found under' java_base
  138.    Call Exit
  139. End
  140.  
  141. config = boot_drive || '\CONFIG.SYS'
  142. rc = SysFileSearch('SET CLASSPATH=', config, 'cp.')
  143. If rc = 0 & cp.0 > 0 Then Do i = 1 To cp.0
  144.    testcp = Translate(cp.i)
  145.    If Abbrev(testcp, 'REM') Then Iterate
  146.    Else config_classpath = cp.i
  147. End
  148. Else Do
  149.    Say 'Unable to locate SET CLASSPATH= in' config
  150.    Call Exit
  151. End
  152.  
  153. ini_info = Strip(SysIni(appl_file, appl_ini, 'hotjava'), 'T', '00'x)
  154. If Word(ini_info, 1) Then Do
  155.    Say 'Do you want to use the Hot Java Browser (y,N)?'
  156.    Parse Upper Pull answer .
  157.    If Abbrev(answer, 'Y') Then Do
  158.       hot_java = 1
  159.       If file_sys = 'HPFS' Then hot_java_jar = our_path || '\' || Word(ini_info, 2)
  160.       Else Do
  161.          'RENAME' Word(ini_info, 2) Word(ini_info, 3) 
  162.          hot_java_jar = our_path || '\' || Word(ini_info, 3)
  163.       End
  164.    End
  165.    Else hot_java = 0
  166. End
  167. Else hot_java = 0
  168.  
  169. classpath = ''
  170. If Pos(appl_class, config_classpath) = 0 Then Do
  171.    classpath = appl_class || '^;'
  172.    Say 'Setting class -' appl_class
  173. End
  174. Else Say 'Found' appl_class 'in' config 'CLASSPATH'
  175. Do i = 1 To classes.0
  176.    If Word(classes.i, 1) Then Do
  177.       Say 'Using' appl 'class -' Word(classes.i, 2)
  178.       If Pos(Word(classes.i, 2), config_classpath) = 0 Then Do
  179.          Say 'Setting class -' Word(classes.i, 2)
  180.          classpath = classpath || Word(classes.i, 2) || '^;'
  181.       End
  182.       Else Say 'Found' Word(classes.i, 2) 'in' config 'CLASSPATH'
  183.    End
  184. End
  185. If hot_java Then Do
  186.    If Pos(hot_java_jar, config_classpath) = 0 Then Do
  187.       Say 'Setting class -' hot_java_jar
  188.       classpath = classpath || hot_java_jar || '^;'
  189.    End
  190.    Else Say 'Found' hot_java_jar 'in' config 'CLASSPATH'
  191. End
  192. If Pos(java_class, config_classpath) = 0 Then Do
  193.    Say 'Setting class -' java_class
  194.    classpath = classpath || java_class || '^;'
  195. End
  196. Else Say 'Found' java_class 'in' config 'CLASSPATH'
  197. If classpath <> '' Then classpath = '-classpath' classpath
  198.  
  199. parameters = ''
  200. appl_name = Strip(SysIni(appl_file, appl_ini, 'applname'), 'T', '00'x)
  201. obj_parm = Strip(SysIni(appl_file, appl_ini, 'objparm'), 'T', '00'x)
  202. If Word(obj_parm, 1) Then Do
  203.    obj_parm = Subword(obj_parm, 2)
  204.    our_home_pos = Pos('&ourhome', obj_parm)
  205.    If our_home_pos > 0 Then Do
  206.       Parse Var obj_parm part_1 '&ourhome' part_2
  207.       obj_parm = part_1 || our_base || part_2
  208.    End
  209.    java_home_pos = Pos('&javahome', obj_parm)
  210.    If java_home_pos > 0 Then Do
  211.       Parse Var obj_parm part_1 '&javahome' part_2
  212.       obj_parm = part_1 || java_base || part_2
  213.    End
  214.    appl_name = obj_parm appl_name
  215. End
  216. If classpath <> '' Then parameters = classpath appl_name
  217. Else parameters = appl_name
  218. ini_info = Strip(SysIni(appl_file, appl_ini, 'jit'), 'T', '00'x)
  219. If ini_info Then Do
  220.    Say 'Do you want to disable the JIT compiler (y,N)?'
  221.    Parse Upper Pull answer .
  222.    If Abbrev(answer, 'Y') Then Do 
  223.       If java_lvl >= '1.1.6' Then parameters = '-nojit' parameters
  224.       Else parameters = '-Djava.compiler=xxx' parameters
  225.    End
  226. End
  227.  
  228. obj_class = Strip(SysIni(appl_file, appl_ini, 'objclass'), 'T', '00'x)
  229. obj_title = Strip(SysIni(appl_file, appl_ini, 'objtitle'), 'T', '00'x)
  230. obj_loc = Strip(SysIni(appl_file, appl_ini, 'objloc'), 'T', '00'x)
  231. obj_id = Strip(SysIni(appl_file, appl_ini, 'objid'), 'T', '00'x)
  232. obj_id = 'OBJECTID=<' || obj_id || '>;'
  233. exec = 'EXENAME=' || java_name || ';'
  234. parm = 'PARAMETERS=' || parameters || ';'
  235. startdir = 'STARTUPDIR=' || startpath || ';'
  236. window = 'PROGTYPE=WINDOWABLEVIO;CCVIEW=NO;'
  237.  
  238. Say 'Do you want to run with the Java console window minimized (Y,n)?'
  239. Parse Upper Pull answer .
  240. If Abbrev(answer, 'N') Then window = window || 'MINIMIZED=NO;'
  241. Else window = window || 'MINIMIZED=YES;'
  242.  
  243. Say 'Do you want to close the Java window when' appl 'ends (Y,n)?'
  244. Parse Upper Pull answer .
  245. If Abbrev(answer, 'N') Then window = window || 'NOAUTOCLOSE=YES;'
  246. icon = 'ICONFILE=' || obj_icon || ';ICONPOS=' || obj_icon_pos || ';'
  247. setup = obj_id || exec || parm || startdir || window || icon
  248.  
  249. If SysCreateObject(obj_class, obj_title, obj_loc, setup, 'U') Then
  250.    Say appl 'program object created or updated'
  251. Else Say 'Failed to create or update' appl 'program object'
  252. Call Exit
  253.  
  254. Exit:
  255.    Procedure
  256.    Call SysDropFuncs
  257.    Exit
  258. Return
  259.  
  260. Getpaths:  /* Get drive, base, and path */
  261.    Procedure
  262.    Parse Arg path
  263.    drive = Filespec('D', path)
  264.    path = Filespec('P', path) 
  265.    path = Strip(Filespec('P', drive || path), 'T', '\')
  266.    base = path
  267.    Do While Lastpos('\', base) > 1
  268.       base = Strip(Filespec('P', base), 'T', '\')
  269.    End
  270.    base = drive || base
  271.    path = drive || path
  272.    Return drive base path