I am writing some code to send text to a third part software. Basically each sending looks like this:
1 2 3 4 5 6 7 8 9
p << "set terminal eps\n";
p << "set output '07.eps'\n";
p << "plot '-' using ($1 == 0 ? NaN : $1) with lines linecolor 2 title 'comparison ratio', \
'-' using ($1 == 0 ? NaN : $1) with lines title 'comparison ratio'\n";
p.send(TOex_ar).send(TOnew_ar);
p << "set terminal wxt 7\n";
p << "plot '-' using ($1 == 0 ? NaN : $1) with lines linecolor 2 title 'comparison ratio', \
'-' using ($1 == 0 ? NaN : $1) with lines title 'comparison ratio'\n";
p.send(TOex_ar).send(TOnew_ar);
Each time I have to change the number "07" and "7";
decide to add or not the following parts: "using ($1 == 0 ? NaN : $1)", "with lines", "linecolor 2";
and write the title 'comparison ratio' and the name of data to send "TOex_ar" and "TOnew_ar".
Since I have to do this kind of thing 50 times in my code, and it is in the form of text, I am wondering whether in C++ we can write a template or function to simplify the program, just to input the changing parts.