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
 LabTalk Forum
 if condition for data extraction
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

maric001

Germany
5 Posts

Posted - 10/06/2014 :  04:22:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.1 SR3
Operating System: Win7

Hi there!

I have written a simple script to extract my data according to two ID values:

win -o Samples {
for (ii=0; ii<=9; ii++) {
wxt test:="Col(C6)=$(ii)" iw:=[Samples]Samples! ow:=[Samples]productID$(ii);
for (kk=0; kk<=5; kk++) {
wxt test:="Col(C7)=$(kk)" iw:=[Samples]productID$(ii)! ow:=[productID$(ii)]measureID$(kk);
};
};
};

Script works, but the values for "productID"(Col C6) and "measureID" (Col C7) can be different in different datasets, but always have a maximum range from 0-9 and 0-5, respectively. My script will produce a lot of workbooks/worksheets with no content at all, if or example only productID 0 and 2 are there, since it creates a worksheet for ProductIDs 0-9 all the time.

How can i implement an if condition, that only extracts the data if the product ID is existent in the data? Same for the downstream process of extracting measureID?

Thanks for your help guys!

greg

USA
1378 Posts

Posted - 10/06/2014 :  09:06:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use the vfind X-Function to test if a value exists in a dataset:

dataset dsIndex;
vfind ix:=col(C6) value:=$(ii) ox:=dsIndex;
if(dsIndex.GetSize() > 0)
{
// code to run when you find a value
}
else
{
// code to run when value not found
}
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