SDFileSystemSampleCode4

SwordfishUser.SDFileSystemSampleCode4 History

Show minor edits - Show changes to markup

Added lines 1-54:

Sample Code 4 - Copy and Move

Device = 18F4620
Clock =  40
Config OSC = HSPLL

#option SD_SPI = MSSP
#option SD_SPI_SPEED = spiOscDiv4
#option SD_SUPPORT_SUB_DIRECTORIES = True
#option SD_SUPPORT_MULTIPLE_FILES = True
#option SD_MAX_FILES = 2
Include "Convert.bas"
Include "USART.bas"
Include "SDFileSystem.bas"
Include "String.bas"

Dim Response As Byte
Dim Source, Dest As TSDName
Dim MoveFile As TSDMoveFile
Dim MoveFileResponse As Boolean

// Program start...
USART.SetBaudrate(br115200)
USART.ReadTerminator = #13
DelayMS(100)

USART.Write("Insert SD/MMC:", 13, 10)

Repeat
   Response = SD.Init 
Until Response <> errNoResponse

USART.Write("Copying Started..", 13, 10)

SD.Dir(Source, dirFirst, sdFile)
Dest.Name = "COPY"
Dest.Extension = Source.Extension

SD.CopyFile(Source, Dest)

MoveFileResponse = SD.MoveFileCut(Dest, MoveFile)

SD.MkDir("COPY")
SD.ChDir("COPY")

If MoveFileResponse Then
   SD.MoveFilePaste(MoveFile)
EndIf

USART.Write("Copying Completed", 13, 10)

Repeat
Until False