Can KyeFAT open files by filenumber?
Oldbitcollector (Jeff)
Posts: 8,091
I'm fighting with what should be a simple routine. I'm attempting to open files by file number (a simple trick in fsrw) using the KyeFAT driver.
The idea here is to read the directory up to the "fileNumber", then open that file. Increasing/Decreasing "fileNumber" and re-running the routine should allow me to switch to the next file or the previous.
Can someone see where I'm going wrong here?
Thanks
PUB openNextFile | i
sd.listEntries("W")
repeat i from 0 to fileNumber
repeat while(buffer := sd.listEntries("N"))
str.copy(buffer,@filename)
str.trimstring(@filename)
i++
'sd.openfile( @filename, "r")
The idea here is to read the directory up to the "fileNumber", then open that file. Increasing/Decreasing "fileNumber" and re-running the routine should allow me to switch to the next file or the previous.
Can someone see where I'm going wrong here?
Thanks

Comments
PUB openNextFile | i,data sd.listEntries("W") repeat fileNumber data := sd.listEntries("N") data := sd.listEntries("N") trimString(data) sd.openfile( data, "r") PUB trimString(characters) result := ignoreSpace(characters) characters := (result + ((strsize(result) - 1) #> 0)) repeat case byte[characters] 8 .. 13, 32, 127: byte[characters--] := 0 other: quit PRI ignoreSpace(characters) ' 4 Stack Longs result := characters repeat strsize(characters--) case byte[++characters] 8 .. 13, 32, 127: other: return characters