* backup and restore utility
ERASE
INPUT "DO YOU WISH TO BACKUP (1) OR RESTORE (2)" TO CHOICE
SET talk OFF
STORE 1 TO begin,piece,temp,length
STORE " " TO block
STORE "           " TO infile,outfile
ACCEPT "ENTER SOURCE DRIVE" TO source
ACCEPT "ENTER DESTINATION DRIVE" TO destin
SET DEFAULT TO &source
DO CASE
  CASE choice = 1
    * hard disk backup routine for dbf files
    STORE t TO check
    DO WHILE check
      ACCEPT "ENTER FILE NAME (RETURN TO EXIT)" TO filename
      IF filename= " "
        ERASE
        RETURN
      ENDIF filename= " "
      IF .not. FILE( "&FILENAME" )
        ERASE
        ? "FILE NOT FOUND PLEASE RE-ENTER" 
        ?? chr(7)
      ELSE
        STORE f TO check
      ENDIF .not. FILES
    ENDDO WHILE check
    INPUT "ENTER DISKETTE SIZE (IN THOUSANDS)" TO disksize
    INPUT "ENTER CHARACTORS PER RECORD " TO recsize
    STORE (disksize*1000)/recsize TO temp
    STORE trim(str(temp,6)) TO block
    STORE source + ":" + filename TO infile
    USE &infile
    DO WHILE .not. eof
      ? "         INSERT DISKETTE " + str(piece,1) + " INTO DRIVE " + destin
      WAIT
      RESET
      ERASE
      USE &infile
      GO begin
      STORE filename + "." + str(piece,1) TO outfile
      STORE destin + ":" + trim(outfile) TO outfile
      ? "            NOW COPYING" 
      SET talk ON
      COPY next &block TO &outfile
      SET talk OFF
      STORE piece+1 TO piece
      STORE # + 1 TO begin
      RESET
    ENDDO WHILE .not. eof
  CASE choice = 2
    * hard disk restore routine
    ERASE
    ACCEPT "ENTER FILE NAME OF FILE RESTORING FROM " TO filename
    STORE 1 TO COUNT
    STORE t TO RESTORE
    DO WHILE RESTORE
      ERASE
      STORE filename + "." + str(COUNT,1) TO infile
      STORE t TO disk:chk
      DO WHILE DISK:CHK
        IF FILE( "&INFILE" )
          STORE f TO disk:chk
        ELSE
          ERASE
          ?? chr(7)
          ? "FILE NOT FOUND PLEASE RE-ENTER"
          ?? "LOOKING FOR "
          ? "              "+infile
          WAIT
          RESET
        ENDIF .not. FILES
      ENDDO disk:chk
      STORE destin + ":" + filename TO outfile
      IF COUNT=1
        USE &infile
        ERASE
        ?  "COPYING FIRST BACK-UP DISK IN"
        SET TALK ON
        COPY TO &outfile
        SET TALK OFF
      ELSE
        USE &outfile
        SET TALK ON
        ERASE
        ?  "APPENDING TO FILE..."
        APPEND FROM &infile
        SET TALK OFF
      ENDIF COUNT=1
      ACCEPT "DO YOU HAVE ANY MORE DISKS TO RESTORE FROM (Y/N)? " TO more
      IF more= 'N' 
        STORE f TO RESTORE 
        LOOP
      ENDIF more= 'N' 
      USE
      STORE COUNT+1 TO COUNT
      ? "INSERT  DISK  " +str(COUNT,1)
      WAIT
      RESET
    ENDDO WHILE RESTORE 
ENDCASE 
RETURN
