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

  1. /* A simple netrexx program, demonstrating the
  2.    use of binary file oriented charin/charout.
  3.    There is a corresponding OS/2 REXX example2.cmd
  4.    for a simple evaluation of the effort to spend 
  5.    in the port REXX --> NetREXX. */
  6.  
  7.  import RXFile
  8.  
  9.  File1 = RXFile()
  10.  File2 = RXFile()
  11.  stdin = RXFile() 
  12.  ok = Rexx null
  13.  bytes = Rexx null
  14.  fname = Rexx null
  15.  
  16.  say ' '
  17.  say 'This program creates a copy of an existing'
  18.  say 'binary file.'
  19.  say 'The result file of the copy is placed in'
  20.  say 'this directory, under the name TEMP.BIN.'
  21.  say ' '
  22.  say 'WARNING! This example takes forever to execute'
  23.  say 'with large files..'
  24.  loop until fname.length() \= 0
  25.    say ' '
  26.    say 'Please enter a valid file name..'
  27.    say ' '
  28.    say 'Example: c:\\filename.exe'
  29.    say ' '
  30.    ok = File1.charout("File name>")
  31.    fname = stdin.linein()
  32.    if (File1.stream(fname,"c", "query exists")).length() = 0 then
  33.    do
  34.      fname = ""
  35.      say "That file doesn't exists."
  36.    end
  37.  end
  38.  
  39.  File2.delete("temp.bin")
  40.  
  41.  ok = File1.stream(fname, "c","open read")
  42.  ok = File2.stream("temp.bin","c","open write") 
  43.  
  44.  count = 0
  45.  
  46.  loop while File1.chars() > 0
  47.   bytes = File1.charin()
  48.   count = count + 1
  49.   ok = File2.charout(bytes)
  50.  end
  51.  say count 'bytes copied.'
  52.