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
 Accessing mulitple worksheets for manipulation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

seipher

USA
Posts

Posted - 10/09/2004 :  3:31:21 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version: 7.5817
Operating System: Win XP

I have a unique situation where I want to select a group of worksheets from the Origin Project Explorer and run a script that will manipulate each worksheet. I can't figure out a way to tell Origin each selected Worksheet should be affected by the script. At the moment I'm stuck to running the script one worksheet at a time. Any ideas would be appreciated.

Mike Buess

USA
3037 Posts

Posted - 10/10/2004 :  06:05:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin only keeps track of project explorer selections for simple window management purposes... move, delete, etc. There is no way to access the list of selected windows from Origin C or LabTalk. You're not the first to ask about this and perhaps it deserves to be an official 'feature request' for Origin 8.

Meanwhile, there are only two workarounds that I know about.

1) Move the selected worksheets to the same project folder and use the LabTalk's doc -ef or Origin C's foreach to operate on all in that folder.

2) Create a multiple selection dialog as described at http://www.nmrtools.com/labtalk/i_mlist.html . That topic describes a LabTalk implementation but same can be done in Origin C.

...Nearly forgot about a third ad hoc solution. See toolbar discussion in the topic http://www.originlab.com/forum/topic.asp?TOPIC_ID=3412 .

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/10/2004 07:36:03 AM
Go to Top of Page

seipher

USA
Posts

Posted - 10/10/2004 :  1:39:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike, I'll look into this and let you know how it goes.
Go to Top of Page

seipher

USA
Posts

Posted - 10/11/2004 :  1:33:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike,

I've tried to implement your ideas as listed below (focusing on using the foreach statement in Origin C)
quote:

1) Move the selected worksheets to the same project folder and use the LabTalk's doc -ef or Origin C's foreach to operate on all in that folder.

...See toolbar discussion in the topic http://www.originlab.com/forum/topic.asp?TOPIC_ID=3412 .



Unfortunately, I'm having a hard time linking a worksheet object to the foreach statement. Most of the examples provided deal with graph objects. The syntax I'm looking for is something like this:

foreach(step through each worksheet in the project from top to bottom in project explore) {
run script on data in each worksheet
}
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/11/2004 :  2:11:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Something like this should work...
void GetWksList(StringArray &sa)
{
Folder fld = Project.ActiveFolder();
foreach(PageBase pg in fld.Pages)
if( pg.GetType() == EXIST_WKS )
sa.Add(pg.GetName());
}

void MyWksFunction()
{
StringArray sa;
GetWksList(sa);
Worksheet wks;
for(int i=0;i<sa.GetSize();i++)
{
wks.Attach(sa[i]);
// manipulation code goes here
}
}
...Oops, the GetWksList function above only gets the worksheets in the active folder. Use this to get all worksheets in the project...
void GetWksList(StringArray &sa)
{
foreach(PageBase pg in Project.Pages)
if( pg.GetType() == EXIST_WKS )
sa.Add(pg.GetName());
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/11/2004 2:28:56 PM
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 10/11/2004 :  3:32:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can also try ...

void Test1()
{
foreach (WorksheetPage Wkp in Project.WorksheetPages)
{
Worksheet Wks(Wkp.GetName());
if(Wks.IsValid())
{
// All Worksheets in Project
}
}
}

void Test2()
{
Folder Fld=Project.ActiveFolder();
foreach (PageBase pB in Fld.Pages)
{
Worksheet Wks(pB.GetName());
if(Wks.IsValid())
{
// All Worksheets in CurrentFolder
}
}
}
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