Hello, I realized that I had put it in the wrong category, I could not delete it and I ended up doing a new post in the right category. I'm sorry if that little mistake has caused you any discomfort.
Just like everyone else I tried to help my problem.
arduino_new:
It's not clear what you are trying to do or what your problem was. Please describe agian.
Thanks for looking for me.
Basically I have several strings that have been defined by #define to avoid memory usage.
I do not know if it's the best way, but it's how it's implemented.
#define EmailReboot "System was Reboted {DateTime}"
I have a function that sends emails, I'm using Lib Gsender.
boolean SendEmail(String Subject, String EmailTo, String Mensage)
What I was trying to do was this, but it does not work:
SendEmail(EmailSubjectReboot, System.MailTo, String(EmailReboot).replace("{DateTime}", "XX") );
Laercionit:
Basically I have several strings that have been defined by #define to avoid memory usage.
That's a false premise. All #define does is simple character substitution. If you end up using the symbol that you #define(d) -- say in a print statement or call to SendEmail() -- then it's the same as using the literal string itself.
Think about it, that symbol that you #define(d) only exists in the compiler (EDIT: actually, I think it only exists in the pre-processor). The processor will know nothing about it once your code is compiled. If you use a string it has to be stored SOMEWHERE -- could be RAM, PROGMEM, SD Card, etc. There's no free lunch.
Yep. In addition, the preprocessor does all it's work BEFORE the compiler does its thing, which happens before the linker does its thing, which happens before avrdude uploads to the Arduino, which happens long before runtime.
Using #define to define a value to be substituted at run time just is not possible.