home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vhelp.zip / VIEWHLP2.CMD < prev   
OS/2 REXX Batch file  |  1994-08-25  |  3KB  |  102 lines

  1. /* REXX */
  2. /*
  3.    Procedure to allow VIEW'ing of .HLP files under OS/2 2.x 
  4.  
  5.    This procedure requires that VIEW.EXE be located in a
  6.    directory which is in your PATH statement.  It works by
  7.    changing the 4th byte of the .HLP file from x'10' to
  8.    x'01', thus fooling OS/2 into thinking it is a .INF file.
  9.  
  10.    This version of the procedure works by copying the .HLP file
  11.    to a temporary file before performing any modifications.  If 
  12.    any TEMP or TMP environment variables exist, the temporary file
  13.    will be placed in the specified location.  Otherwise, it will 
  14.    be located in the current directory.  In any event, the temp
  15.    file will be deleted when VIEW is exited.
  16.  
  17.    (c) Copyright 1994 FreeLance Programming.  All rights reserved.
  18.  
  19.    I can be contacted at:      wcdw@delphi.com
  20.                                    - or -
  21.                                1052 Utterback Store Road
  22.                                Great Falls, VA  22066
  23.    
  24.    This code (which comes with no warranties, either expressed
  25.    or implied), is hereby placed in the public domain.  Enjoy!   */
  26.  
  27. infchar = '01'x
  28. hlpchar = '10'x
  29.  
  30. call RXFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  31. call SysLoadFuncs
  32.  
  33. parse arg filename
  34. filename = strip(filename)
  35.  
  36. if filename = '' then
  37.    do
  38.    say 'Usage is: VIEWHLP2 <filename>'
  39.    say ' '
  40.    say '   Where <filename> = The name of the .HLP file to be viewed.  The'
  41.    say '                      .HLP extension is assumed if it is not entered'
  42.    return
  43.    end
  44.  
  45. if translate(right(filename, 4)) <> '.HLP' then
  46.   filename = filename || '.hlp'
  47.  
  48. fullname = stream(filename, 'c', 'query exists')
  49. if fullname = '' then
  50.   do
  51.   say 'The file ' || filename || ' could not be found!'
  52.   return
  53.   end
  54.  
  55. tdir = value('temp',, 'OS2ENVIRONMENT')
  56. if tdir = '' then
  57.   do
  58.   tdir = value('tmp',, 'OS2ENVIRONMENT')
  59.   if tdir = '' then
  60.     tdir = directory()
  61.   end
  62.  
  63. tdir  = tdir || '\TEMP????.INF'
  64.  
  65. tname = SysTempFileName(tdir)
  66. '@copy ' fullname ' ' tname ' > nul '
  67.  
  68. if RC <> 0 then
  69.   do
  70.   say 'Copy failed - unable to create temporary file!'
  71.   '@del ' || tname ' > nul '
  72.   return
  73.   end
  74.  
  75. result = stream(tname, 'c', 'open write')
  76. if left(result, 5) <> 'READY' then
  77.   do
  78.   say 'Unable to open temporary file ' || tname || ' (' || result || ')!'
  79.   return
  80.   end
  81.  
  82. left = charout(tname, infchar, 4)
  83. clsd = stream(tname, 'c', close)
  84.  
  85. 'VIEW.EXE ' || tname
  86.  
  87. /* The following (_really_ crude) do..until continually tries to delete  */
  88. /* the file.  This cannot be done while VIEW is running, so this proc    */
  89. /* just loops until that is no longer true.  This may be revised in a    */
  90. /* future version, if I find a better way to detected when VIEW has      */
  91. /* finished executing.                                                   */
  92.  
  93. do until rc = 0
  94.   call SysSleep 1
  95.   rc = SysFileDelete(tname)
  96. end
  97.  
  98. return
  99.  
  100.  
  101.  
  102.