home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / bp_6_93 / bonus / winer / copyfile.bas < prev    next >
BASIC Source File  |  1992-05-12  |  630b  |  32 lines

  1. '*********** COPYFILE.BAS - file copy subroutine
  2.  
  3. 'Copyright (c) 1992 Ethan Winer
  4.  
  5. DEFINT A-Z
  6. DECLARE SUB CopyFile (InFile$, OutFile$)
  7.  
  8. SUB CopyFile (InFile$, OutFile$) STATIC
  9.  
  10.   File1 = FREEFILE
  11.   OPEN InFile$ FOR BINARY AS #File1
  12.  
  13.   File2 = FREEFILE
  14.   OPEN OutFile$ FOR BINARY AS #File2
  15.  
  16.   Remaining& = LOF(File1)
  17.   DO
  18.     IF Remaining& > 4096 THEN
  19.       ThisPass = 4096
  20.     ELSE
  21.       ThisPass = Remaining&
  22.     END IF
  23.     Buffer$ = SPACE$(ThisPass)
  24.     GET #File1, , Buffer$
  25.     PUT #File2, , Buffer$
  26.     Remaining& = Remaining& - ThisPass
  27.   LOOP WHILE Remaining&
  28.  
  29.   CLOSE File1, File2
  30.  
  31. END SUB
  32.