Steven,
Do you have any example files usign the TSDName structure? I am having a little trouble setting up a routine using this format. I don't have any "good" code to post since I am just starting out on this adventure.
TSDName???
Moderators: David Barker, Jerry Messina
This is a simple example:
Hope this helps - let me know if you need more.
Steve
Code: Select all
Device = 18F452
Clock = 20
Include "USART.bas"
Include "SDFileSystem.bas"
Dim FileName As TSDName
FileName.Name = "TESTFILE"
FileName.Extension = "TXT"
SD.Init(spiOscDiv4)
SD.NewFile(FileName)
SD.CloseFile
Steve
Steven,
I was on the right path. Here is a snippet of code that will check for a file and will skip over it until that file is not found.
I was on the right path. Here is a snippet of code that will check for a file and will skip over it until that file is not found.
Code: Select all
Sub INIT_SD_CHECK_WRITE()
Dim LOOPS_FL As Byte
Dim CHECK As Boolean
Clear(LOOPS_FL)
Repeat
Select LOOPS_FL
Case < 10
FILE.Name = "DEVXX00" + DecToStr(LOOPS_FL) 'File Name, upper case only!
Case < 100
FILE.Name = "DEVXX0" + DecToStr(LOOPS_FL) 'File Name, upper case only!
Case < 255
FILE.Name = "DEVXX" + DecToStr(LOOPS_FL) 'File Name, upper case only!
EndSelect
FILE.Extension = "GPX" 'File Ext, upper case only!
CHECK = FileExists(FILE) 'Check if file already exists
Inc(LOOPS_FL)
Until CHECK = FALSE
SD.NewFile(FILE)
SD.SaveFile()
End Sub
Hi Ryan,
Here is another version of your code that might help - I haven't compiled it, so don't know if it will actually compile to more bytes...
Regards,
Steve
OK, have now tried to compile - slightly less program bytes, but slightly more RAM - note that the code above returns a boolean (true if it's been able to open a new file).
Here is another version of your code that might help - I haven't compiled it, so don't know if it will actually compile to more bytes...
Code: Select all
Function INIT_SD_CHECK_WRITE() as Boolean
Dim LOOPS_FL As Byte
FILE.Extension = "GPX"
Clear(LOOPS_FL)
Repeat
FILE.Name = "DEVXX" + DecToStr(LOOPS_FL, 3)
Inc(LOOPS_FL)
Until SD.NewFile(FILE) = errOK or LOOPS_FL = 0
INIT_SD_CHECK_WRITE = Not(LOOPS_FL = 0)
SD.SaveFile()
End Function
Steve
OK, have now tried to compile - slightly less program bytes, but slightly more RAM - note that the code above returns a boolean (true if it's been able to open a new file).