home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / mkbko020.zip / MKBKOBJ.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-23  |  3KB  |  103 lines

  1. /*
  2.  
  3.    MkBkObj - create a "book"/documentation object
  4.    Version 0.2
  5.  
  6.    (C) 1994 by Ralf G. R. Bergs <rabe@pool.informatik.rwth-aachen.de>
  7.    Released as "Freeware"
  8.  
  9.    accepts as parameters path specs to doc files
  10.    creates a program object that calls VIEW.EXE if the path specs points
  11.      to an .INF files, otherwise calls E.EXE
  12.  
  13.  
  14.    History:
  15.  
  16.    0.2    10/23/94   only load 'SysCreateObject' if not yet resident
  17.                        (thanks to Jason B. Tiller
  18.                        <jtiller@ringer.jpl.nasa.gov> for suggesting this)
  19.                      use "lastpos" instead of "pos" to separate extension
  20.                        (thanks to Jason B. Tiller
  21.                        <jtiller@ringer.jpl.nasa.gov> for suggesting this)
  22.                      use "substr" with a default argument (thanks to Jason
  23.                        B. Tiller <jtiller@ringer.jpl.nasa.gov> for suggesting
  24.                        this)
  25.                      improved error check
  26.                      give usage notice if necessary
  27.  
  28.    0.1    10/17/94   added "MINIMIZED=YES" to install program (thanks to
  29.                        Don Hawkinson <don.hawkinson@twsubbs.twsu.edu>)
  30.                      corrected minor bug in calculation of "ext" when
  31.                        filename had no extension
  32.  
  33.    0.01   09/15/94   initial release
  34.  
  35.  */
  36.  
  37. '@echo off'
  38.  
  39. parse source progname
  40. progname = word( progname, 3 )
  41.  
  42.  
  43. if arg()>0 then do
  44.  
  45.   needfunc = RxFuncQuery( 'SysCreateObject' )
  46.   if needfunc then do
  47.     ret = RxFuncAdd( 'SysCreateObject', 'RexxUtil', 'SysCreateObject' )
  48.     if ret then do
  49.       say progname || ": Error: Registration of 'SysCreateObject' failed."
  50.       exit 1
  51.     end
  52.   end /* if needfunc */
  53.  
  54.   do i=1 to words( arg( 1 ) )
  55.     path = word( arg( 1 ), i )
  56.  
  57.     /* separate "stem" and extension
  58.        example:
  59.          C:\DOS\KEYB.COM: name="KEYB", ext="COM" */
  60.  
  61.     name = filespec( "name", path )
  62.     p = lastpos( ".", name )
  63.     if p>0 then do
  64.       stem = substr( name, 1, p-1 )
  65.       ext = substr( name, p+1 )
  66.     end
  67.     else do
  68.       stem = name
  69.       ext = ''
  70.     end
  71.  
  72.     if translate( ext ) = "INF" then do
  73.       viewer = "VIEW.EXE"
  74.     end
  75.     else do
  76.       viewer = "E.EXE"
  77.     end
  78.  
  79.     ret = SysCreateObject( 'WPProgram', Name, '<WP_DESKTOP>', ,
  80.         'OBJECTID=<Bk_' || Stem || '>;EXENAME=' || viewer || ';PARAMETERS=' ,
  81.         || path, 'U' )
  82.     if \ret then do
  83.       say progname || ": Error: Creation of object <Bk_" || Stem || ,
  84.                       "> failed."
  85.       exit 1
  86.     end
  87.  
  88.   end /* do i=1 to arg() */
  89.  
  90.   if needfunc then do
  91.     ret = RxFuncDrop( 'SysCreateObject' )
  92.     if ret then do
  93.       say progname || ": Error: De-registration of 'SysCreateObject' failed."
  94.       exit 1
  95.     end
  96.   end /* if needfunc */
  97.  
  98. end /* if arg()>0 */
  99.  
  100. else do
  101.   say "Usage: " || progname || " <filespec> {<filespec>}"
  102. end /* else */
  103.