CopyFile()

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
IdeasVacuum
Posts: 143
Joined: Tue Feb 25, 2014 1:27 pm

CopyFile()

Post by IdeasVacuum »

Before Overwriting an existing file, it is good practice to make a copy of it (backup), so a CopyFile() function would be great......

Work-around is to read existing file-write backup file, roughly this:

Code: Select all

Procedure.i PfCopyFile(sFile1.s, sFile2.s)
;#----------------------------------------
Protected iFormat.i

              If ReadFile(1, sFile1)

                     If(Lof(1) > 1)

                            If CreateFile(2, sFile2)

                                   iFormat = ReadStringFormat(1)
                                   
                                   While Eof(1) = 0
                                   
                                           WriteStringN(2, ReadString(1, iFormat), iFormat)
                                   Wend
                                   
                                         CloseFile(2)
                                   ProcedureReturn(#True)
                            EndIf
                     EndIf

                     CloseFile(1)
              Else
                     ProcedureReturn(#False)
              EndIf
EndProcedure