home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vhelp.zip / VIEWHELP.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-25  |  2KB  |  79 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 directly modifying
  11.    the .HLP file in question.
  12.  
  13.    (c) Copyright 1994 FreeLance Programming.  All rights reserved.
  14.  
  15.    I can be contacted at:      wcdw@delphi.com
  16.                                    - or -
  17.                                1052 Utterback Store Road
  18.                                Great Falls, VA  22066
  19.    
  20.    This code (which comes with no warranties, either expressed
  21.    or implied), is hereby placed in the public domain.  Enjoy!   */
  22.  
  23. infchar = '01'x
  24. hlpchar = '10'x
  25.  
  26. call RXFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  27. call SysLoadFuncs
  28.  
  29. parse arg filename
  30. filename = strip(filename)
  31.  
  32. if filename = '' then
  33.    do
  34.    say 'Usage is: VIEWHELP <filename>'
  35.    say ' '
  36.    say '   Where <filename> = The name of the .HLP file to be viewed.  The'
  37.    say '                      .HLP extension is assumed if it is not entered'
  38.    return
  39.    end
  40.  
  41. if translate(right(filename, 4)) <> '.HLP' then
  42.   filename = filename || '.hlp'
  43.  
  44. fullname = stream(filename, 'c', 'query exists')
  45. if fullname = '' then
  46.   do
  47.   say 'The file ' || filename || ' could not be found!'
  48.   return
  49.   end
  50.  
  51. result = stream(fullname, 'c', 'open write')
  52. if left(result, 5) <> 'READY' then
  53.   do
  54.   say 'Error (' || result || ') opening file ' || fullname || '!'
  55.   return
  56.   end
  57.  
  58. left = charout(fullname, infchar, 4)
  59. clsd = stream(fullname, 'c', close)
  60.  
  61. 'VIEW.EXE ' || fullname
  62.  
  63. /* The following (_really_ crude) do..until continually tries to reset   */
  64. /* the file to its original state.  While VIEW is running, the stream    */
  65. /* command will return "NOTREADY:32", so this procedure just loops until */
  66. /* that is not true.  This may be revised in a future version, if I      */
  67. /* find a better wait to detect when VIEW has finished executing.        */
  68.  
  69. do until left(result, 3) <> 'NOT'
  70.   call SysSleep 1
  71.   result = stream(fullname, 'c', 'open write')
  72. end
  73.  
  74. fpos = charout(fullname, hlpchar, 4)
  75. clsd = stream(fullname, 'c', 'close')
  76. return
  77.  
  78.  
  79.