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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Accessing mulitple worksheets for manipulation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
seipher Posted - 10/09/2004 : 3:31:21 PM
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.
5   L A T E S T    R E P L I E S    (Newest First)
rlewis Posted - 10/11/2004 : 3:32:50 PM
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
}
}
}
Mike Buess Posted - 10/11/2004 : 2:11:53 PM
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
seipher Posted - 10/11/2004 : 1:33:27 PM
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
}
seipher Posted - 10/10/2004 : 1:39:15 PM
Thanks Mike, I'll look into this and let you know how it goes.
Mike Buess Posted - 10/10/2004 : 06:05:57 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000