home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / HLP2INF.CMD < prev    next >
OS/2 REXX Batch file  |  1992-02-25  |  1KB  |  46 lines

  1. /* Copy and convert a *.HLP file to an *.INF file readable by VIEW.EXE */
  2. /* Lee S. Fields */
  3.  
  4. /* get input and output file names */
  5. /* get input file parameter */
  6. arg inparm
  7. if inparm=''
  8. then do
  9.   call instruct
  10.   exit
  11. end
  12.  
  13. inparm = strip(inparm)
  14. /* check if HLP extension is specified */
  15. extension=lastpos('.HLP',inparm)
  16. /* if not, then add .HLP to input file name and .INF to output file name */
  17. if extension=0
  18. then do
  19.   infile = inparm'.hlp'
  20.   outfile = inparm'.inf'
  21. end
  22. /* else remove and add .INF to output file name */
  23. else do
  24.   infile = inparm
  25.   outfile = substr(inparm,1,extension - 1)'.inf'
  26. end
  27. say 'Creating 'outfile' from 'infile
  28.  
  29. /* copy file but change 4th byte to 0x01 */
  30. /* read first 4 characters, but keep only first three */
  31. buffer=substr(charin(infile,1,4),1,3)
  32. /* write first 3 characters */
  33. call charout outfile,buffer,1
  34. /* write 4 character as 0x01 */
  35. call charout outfile,X2C('1'),4
  36. /* loop through rest of file, reading and writing 4K blocks */
  37. do while chars(infile) \= 0
  38.   buffer = charin(infile,,min(4096, chars(infile)))
  39.   call charout outfile, buffer
  40. end
  41. exit
  42.  
  43. instruct:
  44. say 'HLP2INF.CMD - Creates INF files from HLP files'
  45. say 'Format: HLP2INF filename[.hlp]'
  46. return