Go Down

Topic: String concatenation and printing (Read 20266 times) previous topic - next topic

GoForSmoke

Thanks for all suggestions.
Eventually I found out there was no problem with the printing code, but rather with the data in the structure.
The suggested format using String concatenation is just fine, and has nothing to do with laziness.
It is a useful tool that was added to Arduino, and is the best choice.
(Such tool is available in all higher languages I know)

I use it for the simple reason that I re-use the same text in several locations, thus building a single string and re-using it is the correct approach.

In my code I use it: (and it is just fine)
String message = (String)"Rev " + configData.configVersion + "," + configData.versionDate;
Serial.println(message);
lcd.print(message);

samtal
The reason you were steered away from using String is because the ARV chips have very little RAM and the way that String works is a very bad fit that causes lots of problems that the ones of us that steer you away from the practice have helped many others fix their code.

Perhaps you did not know but that does not help YOU one bit with your code. Your ego, maybe, but that just holds YOU back.

"The suggested format using String concatenation is just fine, and has nothing to do with laziness.
It is a useful tool that was added to Arduino, and is the best choice.
(Such tool is available in all higher languages I know)"

Funny how you dismissed the reasons you were given to not use String but instead go straight to "laziness". The one thing you can object to is the thing you base your choice on.

I've typed out full explanations for why not to use String many times but I do that for people who ask in words that say they are ready to learn something. Of course it helps after they've painted themselves in a corner and are ready to learn.

A little bit of "know" lets you compare how to code modern PC's to AVR microcontrollers because languages.

I've been helping members here for over 6 years. When I tell you something is going lead you to trouble, that's because it will.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Go Up