I have been working on a project very recently about a card sorter for Magic - The Gathering. I have some code that reads cards from an SD card. The error seems to be coming from this chunk:
myFile=SD.open("/DATABASE/C"+String(ident)+"/NAME.TXT");
value="";
while(myFile.available()){
value=value+(char)myFile.read();
}
Serial.println("DEBUG: "+value);
myFile.close();
It reads fine, but when it reaches a quote, it doesn't know what to do. I think that's because strings have to have ' in order to make it display a quote. When it has (char)myFile.read(); it might read the backslash and put an extra \ in the name. The only thing is that the lcd screen printed a space. It worked fine before when I used the arduino to import 145 different cards and some that had quotes in them, including the one that makes the error. "Vivien s Invocation does not exist!"
Here is my full setup attached so you can see it.
Setup.txt (12.3 KB)
PierreErard:
I have been working on a project very recently about a card sorter for Magic - The Gathering. I have some code that reads cards from an SD card. The error seems to be coming from this chunk:
myFile=SD.open("/DATABASE/C"+String(ident)+"/NAME.TXT");
value="";
while(myFile.available()){
value=value+(char)myFile.read();
}
Serial.println("DEBUG: "+value);
myFile.close();
It reads fine, but when it reaches a quote, it doesn't know what to do. I think that's because strings have to have \' in order to make it display a quote. When it has (char)myFile.read(); it might read the backslash and put an extra \ in the name. The only thing is that the lcd screen printed a space. It worked fine before when I used the arduino to import 145 different cards and some that had quotes in them, including the one that makes the error. "Vivien s Invocation does not exist!"
Here is my full setup attached so you can see it.
Another thing I've noticed is that google docs and word use Non-ASCII based symbols for the " and ' symbols. I have recently had to delete and re-create lots of the text documents. I think I've fixed this problem, if I have any more problems with the SD card, I will post them here. Sorry if you clicked on this and wasted your time, I don't know how to delete it and just as a future lesson, never use google docs or word to create text documents for the SD card. (Even if you don't have access to notepad at the moment)
PierreErard:
It reads fine, but when it reaches a quote, it doesn't know what to do. I think that's because strings have to have ' in order to make it display a quote. When it has (char)myFile.read(); it might read the backslash and put an extra \ in the name.
Nonsense. You use escape characters (aka backslashes ****) when hard-coding strings, there's no problem in building a string, in runtime, with quotation marks and without escapes; even backslashes alone aren't an issue either.
Escape characters in strings only matter for the compiler, not for the running program.
PierreErard:
Another thing I've noticed is that google docs and word use Non-ASCII based symbols for the " and ' symbols. I have recently had to delete and re-create lots of the text documents.
The library actually treats files as binary, so this is why is important to use only plain text and not more sophisticated encodings such as docx, PDF, etc. It also expects standard ASCII text, thus anything else like extended ASCII and Unicode, may lead to data misinterpretation.