BBS: Inland Empire Archive Date: 07-17-92 (20:33) Number: 52 From: MATT HART Refer#: NONE To: BOB SEWELL Recvd: NO Subj: COPY command from QB Conf: (2) Quik_Bas
BS> Anyone know how to access the DOS COPY command from within QB,
' FILECOPY.BAS Matt Hart
'
' Copy a file
'
' For error trapping, compile with /X
DEFINT A-Z
'ON ERROR GOTO ErrorTrap ' Uncomment to trap disk errors
C$ = LTRIM$(RTRIM$(COMMAND$))
FromFile$ = LEFT$(C$,INSTR(C$," ")-1)
ToFile$ = MID$(C$,INSTR(C$," ")+1)
IF FromFile$ = "" OR ToFile$ = "" THEN
PRINT "To run test program:"
PRINT " C:\>filecopy fromfile tofile"
END
ENDIF
CALL FileCopy(FromFile$,ToFile$,SPACE$(4096))
Ending:
END
' Uncomment below for error trapping
'ErrorTrap:
' PRINT "Error ";Err;" has occurred."
' PRINT "Press ENTER to resume or ESC to exit"
' DO
' A$=INKEY$
' LOOP UNTIL A$=CHR$(27) OR A$=CHR$(13)
' IF A$=CHR$(13) THEN
' RESUME
' ELSE
' RESUME Ending
' ENDIF
' Buffer$ - up to 32767. Larger sizes will increase memory
' requirement but decrease copy time for large files.
SUB FileCopy(FromFile$,ToFile$,Buffer$)
FF = FreeFile
OPEN "B",FF,FromFile$
TF = FreeFile
OPEN "B",TF,ToFile$
A& = LOF(FF)
B& = LEN(Buffer$)
IF A& \ B& > 0& THEN
FOR i& = 1& TO A&\B&
GET FF,,Buffer$
PUT TF,,Buffer$
NEXT
ENDIF
B& = A& MOD B&
IF B& > 0& THEN
Buffer$ = SPACE$(B&)
GET FF,,Buffer$
PUT TF,,Buffer$
ENDIF
CLOSE TF,FF
END SUB
---
* Origin: Midnight Micro! V.32/REL (918)451-3306 (1:170/600)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET