The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 strcat and rename a graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

yulisunflower

USA
Posts

Posted - 11/03/2009 :  1:20:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 7.6 SR6
Operating System: Vista
Hi,

I asked in this forum a few days ago about how to change the name of a graph to the name of the column. Sometimes I need to fit the same data with different models and compare them. So I want to append a "_2" after the name of the column to name the new graph. I tried strcat and it didn't work. I cannot give the name of the column,which is a string, to a character array. Anyone knows how to solve this problem? Thanks a lot.

Best
Yu

Sophy

China
Posts

Posted - 11/03/2009 :  9:33:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Yu:

I suggest that you use Origin string object to construct a new name in this case. Please refer to the following code:

void str_cat()
{
	string strColName = "A";
	
	strColName = strColName + "_2"; //no need to use strcat here.
	
	GraphPage gp;
	gp.Create("Origin");
	gp.Rename(strColName);
	
	return;
}

Edited by - Sophy on 11/03/2009 10:28:17 PM
Go to Top of Page

Iris_Bai

China
Posts

Posted - 11/03/2009 :  10:26:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In Origin C, you can:

int n = 2;
string str = "abc_" + n;

Or

string str;
int n = 2;
str.Format("%s_%d", "abc", n);


Iris
Go to Top of Page

yulisunflower

USA
Posts

Posted - 11/04/2009 :  1:01:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That is easy and works well. Thank you for both of you.

Yu
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000