again:
listing = DRIVEMAP(, 'FIXED')
SAY 'Which drive do you wish to backup?'
i = 1
DO UNTIL listing == ""
PARSE VAR listing drives.i listing
SAY i '=' drives.i
i = i + 1
END
SAY i '= All drives'
SAY i + 1 '= Quit'
PULL answer
IF DATATYPE(answer, 'W') == 0 | answer > i THEN RETURN
SAY 'Enter backup directory (ie, E:\) >'
PULL destination
IF answer \= i THEN DO
i = answer
answer = 1
END
ELSE DO
answer = answer - 1
i = answer
END
DO answer
filename = drives.i || 'backup.txt'
IF STREAM(filename, 'C', 'OPEN READ') == 'READY:' THEN DO
SIGNAL ON NOTREADY NAME badread
CALL LOADTEXT('mybackup.', filename, 'TLB')
DO p = 1 TO mybackup.0
IF LEFT(mybackup.p, 1) \== ';' THEN DO
SAY 'Copying "' || drives.i || mybackup.p || '" to "' || destination || mybackup.p || '"'
ERROR = DIR(destination || mybackup.p)
IF ERROR \== "" THEN SIGNAL copyerr
IF RIGHT(mybackup.p, 1) == '\' THEN
ERROR = copyfolder(drives.i || mybackup.p, destination || mybackup.p, 1)
ELSE
ERROR = COPYFILE(drives.i || mybackup.p, destination || mybackup.p, 'R')
IF ERROR \== "" THEN DO
copyerror: SAY ERROR
SIGNAL done
END
END
END
CALL STREAM(filename, 'C', 'CLOSE')
END
ELSE SAY STREAM(filename, 'D')
i = i - 1
END
done:
CALL BEEP(1000, 500)
SIGNAL again
badread:
CALL CONDITION('M')
CALL STREAM(filename, 'C', 'CLOSE')
SIGNAL done
copyfolder: PROCEDURE
ERROR = COPYFILE(ARG(1), ARG(2), 'R')
IF ERROR \== "" THEN RETURN ERROR
DO UNTIL ERROR \== ""
ERROR = MATCHNAME(ARG(3), 'name', ARG(1), 'D')
IF ERROR == "" THEN DO
ERROR = DIR(ARG(2) || '\' || name)
IF ERROR \== "" THEN DO
badcopyfolder:
CALL MATCHNAME()
RETURN ERROR
END
ERROR = copyfolder(ARG(1) || '\' || NAME, ARG(2) || '\' || NAME, ARG(3) + 1)
IF ERROR \== "" THEN SIGNAL badcopyfolder
END
END
IF ERROR == 'DONE' THEN ERROR = ""
RETURN ERROR |