TimePlot not taking string variables

Support forum for MegunoLink
Post Reply
ceremona
Posts: 4
Joined: Sat Jun 15, 2019 12:33 am

Fri Jul 19, 2019 1:42 am

Hi

I am trying to use the TimePlot constructor to create different variable streams without putting the string directly in the Timeplot argument, sort of like so:

String tmp="blah";
TimePlot TempPlot1(tmp);

As opposed to just saying Timeplot TempPlot1("blah");

But I get a compile error. (Sorry can't easily copy the error right now). But is there anything obviously wrong with doing this? I don't see it. Do I need to do some kind of clever TempPlot1((char *) tmp) type cast to turn the string into a pointer? Because I tried that and it doesn't work.

Thanks
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Mon Jul 22, 2019 5:48 am

Hi Ceremona, we have typically chosen not to support strings as they are not great memory wise. We instead recommend the pstring library. This lets you pre-allocate memory which you can use to construct a character array. You then use this with our library. This post explores it a bit:
viewtopic.php?f=5&t=1409&hilit=pstring&start=10

You can get the library here:
http://arduiniana.org/libraries/pstring/

Have a go with that and let me know if you have any questions.
Cheers
Phil
Post Reply