Announcement

Collapse
No announcement yet.

File Manipulation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    Keith,
    Well just from looking at your code, it seems to me that you are running this from your hard disk, correct? If that is the case then under 'restoring the file' shouldn't the line of code that reads:
    OUTPUTFILE$ ="A:SCORES.DAT" ' THE DATA FILE NAME
    read this instead:
    OUTPUTFILE$ ="SCORES.DAT" ' THE DATA FILE NAME
    because it looks to me like you are restoring to the floppy instead of the original directory.
    Kevin

    ------------------
    mailto:[email protected][email protected]</A>
    :-)

    Leave a comment:


  • Keith E. Black
    started a topic File Manipulation

    File Manipulation

    I USE THIS CODE TO MAKE A DUPLICATE FILE FOR BACKUP PURPOSES.
    THIS WORKS WELL ON THE HARDDRIVE FOR BACK UP.
    WHEN I TRY TO REVERSE THE FILENAMES TO MAKE OUTPUTFILE CONTENTS INPUTFILE
    CONTENTS FROM THE A DRIVE IT DOESN'T WORK. WHAT'S WRONG.

    'BACKING UP THE FILE
    INPUTFILE$ = "SCORES.DAT" ' THE MAIN FILE NAME
    OUTPUTFILE$ ="A:SCORES.BAK" 'THE BACK UP FILE NAME
    FILE1% =FREEFILE
    OPEN INPUTFILE$ FOR BINARY AS #FILE1%
    FILE2% = FREEFILE
    OPEN OUTPUTFILE$ FOR BINARY AS #FILE2%
    BYTE$ = LOF(FILE1%)
    DO
    IF BYTE% > 245 THEN
    TPASS = BYTE&
    END IF
    BUFFER$ = SPACE$(TPASS)
    GET #FILE1%, ,BUFFER$
    PUT #FILE2%, ,BUFFER$
    BYTE& = BYTE& - TPASS
    LOOP WHILE BYTE&
    CLOSE FILE1%
    CLOSE FILE2%
    END


    'RESTORING UP THE FILE
    INPUTFILE$ = "A:SCORES.BAK" 'THE BACKUP FILE NAME
    OUTPUTFILE$ ="A:SCORES.DAT" ' THE DATA FILE NAME
    FILE1% =FREEFILE
    OPEN INPUTFILE$ FOR BINARY AS #FILE1%
    FILE2% = FREEFILE
    OPEN OUTPUTFILE$ FOR BINARY AS #FILE2%
    BYTE$ = LOF(FILE1%)
    DO
    IF BYTE% > 245 THEN '245 IS LENGTH OF FILE
    TPASS = BYTE&
    END IF
    BUFFER$ = SPACE$(TPASS)
    GET #FILE1%, ,BUFFER$
    PUT #FILE2%, ,BUFFER$
    BYTE& = BYTE& - TPASS
    LOOP WHILE BYTE&
    CLOSE FILE1%
    CLOSE FILE2%
    END

Working...
X