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
 Array of worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

icefox

Germany
2 Posts

Posted - 08/27/2012 :  04:33:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.6.0G and Service Release Sr3
Operating System: WinXP

Hello,

my problem might be trivial to you - but I can´t get it work, there is always a failure when SensNr > 0.

Can´t I create an array of worksheets like
Worksheet wksa[6];

and later in code create one by one like
for (int SensNr = 0 ; SensNr <= 5 ; SensNr++ )
{
   wksa[SensNr].Create("Origin.otw", CREATE_VISIBLE);
}


Could anyone give me a hint what i´m doing wrong?

Thanks,

icefox

______
Icefox

rlewis

Canada
253 Posts

Posted - 08/27/2012 :  05:04:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You coulduse Origin's Array class ..
Try something like


void UsingWorksheetPageArray(int NumPages)
 {
 	Array<PageBase&> wPages;
 	if(PopulatePageArray(wPages,NumPages)==NumPages)
 	{
 		for(int i=0;i<NumPages;i++)
 		{
 			WorksheetPage wPg=wPages.GetAt(i);
 			if(wPg.IsValid()==true)
 			{
 				out_str(wPg.GetName());
 			}
 		}
 		out_str("Success");
 	}
 	else
 	{
 		out_str("Failure");
 	}
 }



int PopulatePageArray(Array<PageBase&> &wPages, uint NumPages)
{
	wPages.SetSize(0);
	for(int i=0;i<NumPages;i++)
	{
		WorksheetPage wPg;
		wPg.Create("Origin.otw",CREATE_HIDDEN);
		if(wPg.IsValid()==true)
		{
			WorksheetPage *pwPg;
			pwPg=new WorksheetPage(wPg);
			wPages.Add(*pwPg);
		}
	}
	return (wPages.GetSize());
}
Go to Top of Page

Penn

China
644 Posts

Posted - 08/27/2012 :  05:57:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

When using the Array class, please remember to include the header file.

#include <Array.h>


Penn
Go to Top of Page

icefox

Germany
2 Posts

Posted - 08/27/2012 :  09:45:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

thanks for your answers.

But isn´t this a little bit complicated?

I thought i could get my worksheets in a simple array like i can work with Dataset-Arrays (which works fine)

Dataset DS_Mode[6];		      
for (int SensNr = 0 ; SensNr <= 5 ; SensNr++ )
{
 DS_Mode[SensNr].Attach(strPageName + "_S" + (SensNr+1) + "Mode"); DS_Mode[SensNr].SetSize(nRows);     
}


(Please note: I´m only a occasional user...)

But thanks for your answers,

icefox

______
Icefox
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