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
 Origin Forum
 combining strings in Set Column Values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ericharley

USA
Posts

Posted - 08/11/2005 :  11:43:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): OriginPro 7.5 SR5
Operating System:Win XP Pro SP2

I'd like to combine the (string) contents of two or more label columns into one (new) column. It seems like this should be easy to do with the Set Column Values dialog box, but I'm having trouble figuring it out. I know I could do it with Origin C, but if there's a simple way to do this thing on the fly with Set Column Values I'd love to know.

Thanks

easwar

USA
1964 Posts

Posted - 08/11/2005 :  12:02:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

One way to easily do this is to use a few lines of code in the Script Window, such as:


for(i=1;i<=wks.nrows;i++)
{
%a=col(1)[i]$;
%b=col(2)[i]$;
col(3)[i]$=%a%b;
}



If you do want to use Set Col Values dialog, you could write a custom Origin C function which you can then call from your Set Col Values expression. For an example of how to do this, see the sample project:
\Samples\Programming\PassingVectors.OPJ

Easwar
OriginLab

Go to Top of Page

ericharley

USA
Posts

Posted - 08/11/2005 :  2:58:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the suggestion, easwar. The LabTalk script looks like it should work just fine. I have hesitated to learn too much about LabTalk so far and have concentrated more on Origin C. Looks like they can both be useful, though.

Where can I find a list of the %x variables that store information in Origin? I understand, for example, that %H and %Y contain information already. I'd like to know which ones are used already so that 1. I don't overwrite them and 2. I can use the information if I want. Also, are the variables local to a particular page, so that they would change depending on which page is active, or are they global for the entire project? Is there something I can use to access the worksheet label, for example?

Thanks
Go to Top of Page

easwar

USA
1964 Posts

Posted - 08/11/2005 :  3:05:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

I have hesitated to learn too much about LabTalk so far and have concentrated more on Origin C. Looks like they can both be useful, though.



Hi,

I would suggest then that you try using Origin C first. Like I mentioned, it would be easy to write an OC function that takes two columns with strings as arguments and add them and place in another column, and then you can call that function from your Set Col Values dialog, similar to how that sample OPJ manipulaes string columns.

Things like worksheet labels are also all accesible from OC.

As for LT string variables, you can look up the following section in the programming help file:
LabTalk Language Reference->Keywords->String System Variables
and the following section for general info on using string in LT:
LabTalk Langauge Reference->Substitution Notation

Easwar
OriginLab



Go to Top of Page

ericharley

USA
Posts

Posted - 08/12/2005 :  11:50:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry that this topic is gradually turning towards Origin C but isn't in that forum...

Easwar, I have actually spent some time searching through the programming help files and can't figure out how to access the worksheet label using Origin C. GetLabel() gets column labels, GetName() gets the name of a data set or column or worksheet (but not the label). What can I use to read the label?

Thanks
Go to Top of Page

easwar

USA
1964 Posts

Posted - 08/12/2005 :  12:10:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use code such as below. There are code examples in the Programming Help Files under Programming Guide, in the Langauge Reference, and also you can find some examples in forum posts in the Origin C forum and on this page of our website:
http://www.originlab.com/index.aspx?s=9&lm=71&pid=268

Easwar
OriginLab


void wks_label()
{
// Assume active layer is a worksheet
Worksheet wks = Project.ActiveLayer();
if( wks )
{
// Get the page object for this worksheet
WorksheetPage wpg = wks.GetPage();
// Set the label
wpg.Label = "This is my worksheet label";
// Turn on property to show the label in the GUI
wpg.TitleShow = WIN_TITLE_SHOW_BOTH;
// Read back the label
string strLabel;
strLabel = wpg.Label;
out_str(strLabel);
}

}


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