COMPUND STRINGS for SERIAL.PRINT()

Hi all

I want to suggest a new function that will make a compound string out of several
sub strings including registers, ram and ports values optional formatted .

for example lets call that function comp()
it may take the following strings "reg1 is" and reg1 value
and return a compound string called for ex. st1 to be used by serial.print(st1)

Another option is to add this functionality to serial.print() or a new version of print() call it cprint()

The Idea is to avoid multiple serial.print() usage for debugging .

I hope i am clear .

Thanks
Elico

You can already use multiple serial.print() statements to achieve the output that you want, or use sprintf() to create a string to output.

You can create your own function that takes a variable number of arguments and outputs them individually.

There is also a Streaming library.

Given that there are already at least four ways to accomplish your task, I see little benefit in encumbering the Print class with more rarely used capabilities.

Serial.println(String("reg1 is ") + String(reg1));

Thanks
Elico

Note that using the String library, and/or sprintf(), and/or fprintf() (which is also possible), are all going to result in larger code and more cpu cycles used than simply calling Serial.print() multiple times.