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
 finding current worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

nbo10

USA
Posts

Posted - 07/12/2006 :  10:54:59 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

HI I need some help.

I want to write a script that will find the current worksheet and add Columns to it. I can write a script to add columns but it starts a new worksheet. Thanks

easwar

USA
1965 Posts

Posted - 07/12/2006 :  11:03:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi nbo10,

Not sure if you were looking for LabTalk script or Origin C code for this, so here is solution for both:

Easwar
OriginLab


// LabTalk Script
if(2 == exist(%h))
{
// active window is a worksheet;
// add columns etc using wks object;
wks.addcol(somename);
// see wks object for more methods/properties
}



// Origin C code
void add_col_current_sheet()
{
Worksheet wks = Project.ActiveLayer();
if( wks )
{
wks.AddCol("somename");
wks.GetPage().Refresh();
// see Worksheet class for more methods and properties
}
}



Go to Top of Page

nbo10

USA
Posts

Posted - 07/12/2006 :  11:17:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, That works get.

One more question. I can't seem to find a function to change the name of worksheets, I can wks.GetName(). Is there a methond to do this? I'm using OriginC.
Go to Top of Page

easwar

USA
1965 Posts

Posted - 07/12/2006 :  11:22:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi nbo10,

You need to change the page name and not the sheet name. In 7.5 there is only one sheet per page and the sheet name is something internal and is not used for display etc.

So try

WorksheetPage wpg=wks.GetPage();
wpg.Rename("newname");


Easwar
OriginLab

Go to Top of Page

nbo10

USA
Posts

Posted - 07/12/2006 :  1:20:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,
One last question.

After I add the columns I then create a GraphPage & GraphLayer & Curve and this plot is maximized. I want the worksheet to stay maximized. I've searched through the help but can't find the right method. Thanks
Go to Top of Page

easwar

USA
1965 Posts

Posted - 07/12/2006 :  1:30:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can search the programming help file with key words to find topics. For controlling window status, please look at the Window class under User Interface Controls. There is a ShowWindow method that has options to minimize, maximize, hide etc.

Easwar
OriginLab




Edited by - easwar on 07/12/2006 1:32:10 PM
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