home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / mkbko021.zip / MkBkObj.cmd < prev    next >
OS/2 REXX Batch file  |  1995-03-16  |  3KB  |  111 lines

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