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

ovince

Yugoslavia
Posts

Posted - 10/08/2006 :  5:09:05 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi All,

I have a worksheet "wks" with 2 columns. I have read out these columns into datasets A and B.

I would like to create 2 datasets ("D1" and "D2") from A in a such a way that D1 contains rows of A under condition B<4.5 and D2 to contain rows of A under condition B>4.5. I have started in this way but it does not work

Dataset A(wks, 0);
Dataset B(wks, 1);

Dataset D1;
Dataset D2;

int n;
n= A.GetSize();

int count1=0;
int count2=0;
for(int ii = 0; ii<n; ii++)
{
if (B[ii] < 4.5)
{
D1.Add(A[ii]);
count1++;
} else {
D2.Add(A[ii]);
count2++;
}
}

Why this does not work? And how to make realisation of this idea simpier?


Thanks
Oliver

rlewis

Canada
253 Posts

Posted - 10/08/2006 :  7:10:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Your code fails because the declarations "Dataset D1; Dataset D2;" do NOT create valid dataset objects. The simplest solution is to add the lines " D1.Create(0,1); D2.Create(0,1);" after declaring D1 and D2 as dataset objects.
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