Receiving strings in F() as parameters.

Hi

As part of a bigger project, I want to save my programs' general output strings to a text file on the SD card instead of sending it down Serial all the time. Doing this is straightforward:

#include <SPI.h> // for SD storage
#include <SD.h> // for SD storage
File blackBox;

void addToBlackBox(char* in)
{
  blackBox = SD.open("BB.TXT", FILE_WRITE);
  blackBox.println(in);
  blackBox.close();  
}

This function works for well enough, but I need to save memory because of my elaborate program. The idea that seemed the simplest was to put all the non-changing strings I wanted on the SD card in F(), the flash memory. So I tried this:

addToBlackBox(F("hello"));

, but the compiler complained about my parameter type in addToBlackBox(), claiming that it should be a const_FlashStringHelper* . So I changed it to that in the parameters, but then the compiler complained even more, claiming that "variable or field 'addToBlackBox' declared void". I tried poking around the class files of classes that had built-in print()s and println()s, but I couldn't really find out why println() doesn't care about whether it's arguments are in F() or not. Googling it didn't help much either, since I could find little documentation on F() itself.

Please share some experience. Maybe I should approach the entire situation differently? How can I allow addToBlackBox() to accept its' argument from the flash memory?

PS I'm using a Seeeduino Stalker V2.3, and I got my libraries for SD from here:
Google Code Archive - Long-term storage for Google Code Project Hosting..

This worked for me. I just did what it told me to do.

void addToBlackBox(const __FlashStringHelper* in)
{
  blackBox = SD.open("BB.TXT", FILE_WRITE);
  blackBox.println(in);
  blackBox.close();  
}

BTW, that is a double underscore preceeding FlashStringHelper.

but I couldn't really find out why println() doesn't care about whether it's arguments are in F() or not.

Because the Print class overloads print() and println() to take strings in SRAM or strings in flash memory (those wrapped in F()).

How can I allow addToBlackBox() to accept its' argument from the flash memory?

You need two versions - one defined each way, as in the Print class.

Thanks guys! My mistake was extremely dumb. I left out a space when I inserted the new data type, so the compiler didn't recognize it as valid data type. damn typo