A question

 BBS: Inland Empire Archive
Date: 05-02-92 (14:39)             Number: 67
From: TOM HAMMOND                  Refer#: NONE
  To: SCOTT GREEN                   Recvd: NO  
Subj: A question                     Conf: (2) Quik_Bas
BC>SG-=>     I wanted to back up a random access file before I used
BC>SG-=>it.  I couldn't figure out how to copy the file to another
BC>SG-=>file with a new name.  At first I tried to come up with a

Scott, try this routine... it's fast and works quite well...

Good luck,

Tom Hammond        N0SS


DECLARE SUB FastCopy (FromFile$, ToFile$)

SUB FastCopy (FromFile$, ToFile$)
    DEFINT A-Z
    'Thanks to: MATT HART, QuickBASIC Echo

    'The larger the BlkSize%, the faster the copy
    BlkSize% = 8192     'or 1024, 2048, 4096, etc., mult. of 1kb

    OPEN "B", 1, FromFile$
    OPEN "B", 2, ToFile$
    A$ = SPACE$(BlkSize%)

    'Copy full-size blocks
    FOR i = 1 TO LOF(1) \ BlkSize% ' note backslash
        GET 1, , A$
        PUT 2, , A$
    NEXT i

    'Copy final block < BlkSize
    IF LOF(1) MOD BlkSize% > 0 THEN
        A$ = SPACE$(LOF(1) MOD BlkSize%)
        GET 1, , A$
        PUT 2, , A$
    END IF

    CLOSE 1, 2
END SUB

-----------8<----------- CUT HERE -----------8<-----------


--- WM v2.00/91-0231
 * Origin: The Modem Zone BBS (314) 893-5106 (1:289/2)
Outer Court
Echo Basic Postings

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