Hi, akerstan:
I'd like to point out some coding problem in you code before solving your problem.
You might have misused the vector<int> vecn, the problem is that vecn = vecn + 1, means that every item in vector vecn will increase by 1, e.g. {1, 2, 3} will become {2, 3, 4}.
If you want to convert a integer to a string, just assign the integer to a string variable, then Origin C can convert it automatically. I hope the following code will help you on understanding how it works.
#include <Origin.h>
#define STR_CRV_NAME_PREFIX "crv"
void dynamic_name_ex()
{
vector<string> vsCurveNames(0); //declare a string vector to store all curve names and reset it.
int nNumCrv = 0; //number of curves
//get root folder
Folder rootFdr = Project.RootFolder;
foreach(Folder SubFdr in rootFdr.Subfolders)
{
foreach(PageBase pb in SubFdr.Pages)
{
if ( pb.GetType() == EXIST_WKS )
{
WorksheetPage wksPage(pb);
foreach(Layer wkslyr in wksPage.Layers)
{
Worksheet wks(wkslyr);
//do something
//...
//add new curve name
nNumCrv++;
string strCrvName = STR_CRV_NAME_PREFIX + nNumCrv; //Origin C will convert nNumCrv to string automatically, say 2 to "2", and catenate two strings and assign to strCrvName
vsCurveNames.Add(strCrvName); //add to string vector;
}
}
}
}
}
BTW, you might have interest in how to plot all xyranges in current project on one graph, please refer to http://ocwiki.originlab.com/index.php?title=OriginC:Plot_all_worksheets_in_one_graph_layer