home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rio111.zip / example3.nrx < prev    next >
Text File  |  1996-07-18  |  1KB  |  48 lines

  1. /* A simple netrexx program, demonstrating the
  2.    use of charout, linein, lineout, delete 
  3.    and stream. */
  4.  
  5.  import RXFile
  6.  
  7.  File1 = RXFile()
  8.  File2 = RXFile()
  9.  stdin = RXFile() 
  10.  ok = Rexx null
  11.  
  12.  say ' '
  13.  say 'This program creates a copy of an existing'
  14.  say 'ASCII file, stripping away lines starting'
  15.  say 'with the keyword REM (as in comments).'
  16.  say 'The result file is placed in this directory,'
  17.  say 'under the name TEMP.TXT.'
  18.  loop until ok.length() \= 0
  19.    say ' '
  20.    say 'Please enter a valid file name..'
  21.    say ' '
  22.    say 'Example: c:\\config.sys'
  23.    say ' '
  24.    File1.charout("File name>")
  25.    ok = stdin.linein()
  26.    if (File1.stream(ok,"c", "query exists")).length() = 0 then
  27.    do
  28.      ok = ""
  29.      say "That file doesn't exists."
  30.    end
  31.  end
  32.  
  33.  File2.delete("temp.txt")
  34.  
  35.  File1.stream(ok, "c","open read")
  36.  File2.stream("temp.txt","c","open write")
  37.  
  38.  count = 0
  39.  
  40.  loop while File1.lines() > 0
  41.   ok = File1.linein()
  42.   count = count + 1
  43.   if ok.substr(1, 3).upper() \= 'REM' then
  44.    File2.lineout(ok)
  45.   else
  46.    say 'Line' count 'not copied> ' ok
  47.  end
  48.