home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1988 / 15 / filecopy.bas < prev    next >
BASIC Source File  |  1988-07-25  |  2KB  |  66 lines

  1. 'FileCopy.Bas - demonstration of the FileCopy.Asm routine
  2.  
  3. On Error Goto DiskErr                   'MUST handle critical errors and
  4.                                         '  re-call FileCopy to close source
  5.  
  6. Input "Enter the source file: ", InFile$
  7. Input "Enter the target file: ", OutFile$
  8.  
  9. Free = Fre("")                          'see how big a buffer we can make
  10. If Free > 32849 Then                    'reserve 2 * 64 bytes for file names
  11.    Buffer$ = Space$(32767)
  12. Else
  13.    Buffer$ = Space$(Free - 82)
  14. End If
  15.  
  16. Call FileCopy(InFile$, OutFile$, Buffer$, ErrCode%)
  17.  
  18. Print
  19. If ErrCode% Then                        'did FileCopy detect any errors?
  20.    Print "ERROR: ";
  21.    Select Case ErrCode%
  22.    Case 1
  23.       Msg$ = "Source path cannot be found."
  24.    Case 2
  25.       Msg$ = "Source file does not exist."
  26.    Case 4
  27.       Msg$ = "Source file is a directory."
  28.    Case 5
  29.  
  30.  Msg$ = "Source file cannot be accessed."
  31.    Case 6
  32.       Msg$ = "Target path cannot be found."
  33.    Case 7
  34.       Msg$ = "Target filename is invalid."
  35.    Case 8
  36.       Msg$ = "Target directory is full."
  37.    Case 9
  38.       Msg$ = "Target file is a directory."
  39.    Case 10
  40.       Msg$ = "Target file is read-only."
  41.    Case 11
  42.       Msg$ = "Target file cannot be accessed."
  43.    Case 12
  44.       Msg$ = "Target disk is full."
  45.    Case 13
  46.       Msg$ = "Not enough string space for copy buffer."
  47.    End Select
  48.    Print Msg$
  49. Else
  50.    Print "Successful completion."
  51. End If
  52.  
  53.  
  54. Done:
  55. Buffer$ = ""            'free up the memory used by Buffer$
  56. End
  57.  
  58.  
  59. DiskErr:                'program will arrive here if a critical error occurred
  60.                         'call FileCopy again to close any open files
  61.  
  62. Print "A DOS critical error occured - check the disk and disk drive."
  63. Call FileCopy(InFile$, OutFile$, Buffer$, -1%)
  64. Resume Done
  65.  
  66.