Hi all,
I hope I'm missing something simple. Code like below compiles happily, and is well known in the examples and various sketches around the place
if (SD.exists("page2.htm")) {
webFile = SD.open("page2.htm"); // open web page file
Serial.println("Opening page2");
}
There, the file name is explicit as page2.htm and is in quotes.
So I thought I'd try with a filename as a variable, analogously to how one might Serial.print:
Serial.print("page2.htm");
Serial.print(myFile); // where page2.htm is already in the variable myFile.
Alas! When I try this, with the file name in a String parsed from an HTTP GET:
if (SD.exists(fileOne)) {
webFile = SD.open(fileOne); // open web page file
Serial.print("Opening ");
Serial.println(fileOne);
... the compile fails with the line if (SD.exists(fileOne)) {
highlit and the following message:
SD_file_parse.ino: In function 'void loop()':
SD_file_parse:100: error: no matching function for call to 'SDClass::exists(String&)'
C:\Program Files (x86)\Arduino\libraries\SD/SD.h:77: note: candidates are: boolean SDClass::exists(char*)
SD_file_parse:101: error: no matching function for call to 'SDClass::open(String&)'
C:\Program Files (x86)\Arduino\libraries\SD/SD.h:74: note: candidates are: File SDClass::open(const char*, uint8_t)
I have no clue what that's getting at.... =(
I'd be very surprised if there's no way to work with SD files through variables, so can anybody clue me in please?
TIA....
Jim
EDIT... is this because I have the variable in a String? Would it have worked with a char array? I have belatedly tumbled to that's what the error might mean.
MORE EDIT: I see there's a toCharArray(), I'm just going to see if that gets me out of this