A Question

 BBS: Inland Empire Archive
Date: 04-27-92 (14:27)             Number: 94
From: JEAN CREPEAU                 Refer#: NONE
  To: SCOTT GREEN                   Recvd: NO  
Subj: A Question                     Conf: (2) Quik_Bas
In a message to ALL, SCOTT GREEN wrote:
SG=>       I wanted to back  up a random access file  before I used it.   I
    couldn't figure out  how to copy  the file to  another file with  a new
    name.  At first I tried to come up with a copy like command from basic,
    but couldn't find any.  Then I tried to  load it as a  sequential file,
    but realized, it would  still only write over  the file already on  the
    hard drive.  Then I thought with the system command I might be able  to
    write a "mini batch" command to hide within my program.

SG=>      I do not  want to have to write an exterior batch command.   It's
    not  important  enough  for  me  to  write a whole routine dedicated to
    copying the file.  But I am wondering if there was just stuff I  didn't
    know.   Are there  such commands  in basic?   Can  you have  batch like
    commands after calling the system in basic?  How do you do it?

        You  can  either  use  the  SHELL  "copy  file1  file2" which calls
COMMAND.COM and is not very clean. Otherwise, use the following subroutine:

DECLARE SUB copy (file1$, file2$)

SUB copy (file1$, file2$)
a1 = FREEFILE: OPEN file1$ FOR BINARY AS a1
a2 = FREEFILE: OPEN file2$ FOR BINARY AS a2
a& = FRE("") - 1024: IF a < 0 THEN EXIT SUB
IF a& > 32767 THEN a& = 32767
u$ = SPACE$(a&)
WHILE LOF(a1) - LOC(a1) >= a&
        GET #a1, , u$
        PUT #a2, , u$
WEND
u$ = ""
u$ = INPUT$(LOF(a1) - LOC(a1), a1)
PUT #a2, , u$
CLOSE #a1, #a2
END SUB

        Jean
---
 * Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)
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