home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / inetlg71.zip / EOF2CRLF.CMD < prev    next >
OS/2 REXX Batch file  |  2000-02-07  |  1KB  |  59 lines

  1. /* EOF2CRLF.CMD         Jerry Levy    18 Mar 95
  2.    Replaces E-O-F's (26 decimal or 1A hex or Control-Z)
  3.    by a carriage return+linefeed
  4.    Syntax:
  5.       eof2crlf inputfile outputfile */
  6.  
  7. eof = D2c(26)
  8. cr = D2c(13)
  9. lf = D2c(10)
  10. found = 0
  11.  
  12. Parse Arg inputfile outputfile
  13. Call File_cmd inputfile, 'R'
  14. Call File_cmd outputfile, 'W'
  15.  
  16. Do While Chars(inputfile) > 0
  17.    datachar = Charin(inputfile)
  18.    If datachar = eof Then
  19.       Do
  20.          found = found + 1
  21.          datachar = cr
  22.          Call Charout outputfile, datachar
  23.          datachar = lf
  24.       End
  25.    Call Charout outputfile, datachar
  26. End
  27. Call File_cmd inputfile, 'C'
  28. Call File_cmd outputfile, 'C'
  29. Say 'EOF characters found =' found
  30. Exit
  31.  
  32. /* performs common Stream commands and returns 1 if successful */
  33. File_cmd:
  34. Procedure
  35. trace_value = Trace()
  36. Trace 'N'
  37. Parse Arg file_name, command
  38. Select
  39.    When command = 'X' Then
  40.       action = 'QUERY EXISTS'
  41.    When command = 'C' Then
  42.       action = 'CLOSE'
  43.    When command = 'W' Then
  44.       action = 'OPEN WRITE'
  45.    When command = 'R' Then
  46.       action = 'OPEN READ'
  47.    Otherwise Return 0
  48. End
  49. Call Stream file_name, 'C', action
  50. If command = 'X' Then
  51.    answer = Value(result <> '')
  52. Else
  53.    answer = Abbrev(result,'READY')
  54. Trace (trace_value)
  55. Return answer
  56.  
  57.  
  58.  
  59.