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
 Access single columns out of a range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Ibex

Germany
14 Posts

Posted - 06/12/2009 :  11:25:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Pro 8 SR5
Operating System:Win XP

I'm trying to access single columns in a multi column range. I have a simple LabTalk script, where I first run a Xfunction to select a Range like this:
GetRanges -d;
range rin=GetRanges.ra$;

After that rin=[Book1]Sheet1!((A,C1,D1),(B,C,D)) for example.
So I have there two ranges with X,Y,and Y-Error.

I now want to determine the Number of Ranges in "rin" and want to access the columns.

How can I do that?
Thanks
Ibex

Iris_Bai

China
Posts

Posted - 06/15/2009 :  12:11:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ibex,

I suggest you use Origin C DataRange and XYRange class to get number of XY ranges and access columns in range, since there are many useful range relative functions in Origin C.

ra is a Range variable in GetRanges XFunction, right? If so, please change variable type to XYRange, and type "I:40" in Option String column in XFunction builder for this variable. I:40 use to specified this XYRange to support multiple XY ranges and Y error. More about Option String please refer to X-Function programming Help -> Create New X-Function in X-Function Builder -> Optional Strings page.

The following Origin C code shows how to get the number of XY ranges, get the columns index from range and get x, y, yErr numeric data from ranges. Copy codes to XFunction GetRanges function body and compile.


	
	DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
	
	int num = ra.GetNumData(dwRules);
	
	for(int nRange = 0; nRange < num; nRange++)
	{
		DataRange 	drSub;	
		DWORD 		dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;	
		ra.GetSubRange(drSub, dwRules, nRange);
		if( drSub )
		{			
			// example to the index of column X, Y, Y error
			int nXCol, nYCol, nYErrCol; 
			
			Worksheet 	wks;
			int 		r1, c1, r2, c2;			
			drSub.GetRange("X", r1, c1, r2, c2, wks);
			nXCol = c1;
			
			drSub.GetRange("Y", r1, c1, r2, c2, wks);
			nYCol = c1;
			
			drSub.GetRange("ED", r1, c1, r2, c2, wks);
			nYErrCol = c1;	
			
			// example to show how to get data
			vector 	vx, vy, verr;
			drSub.GetData(dwRules, 0, NULL, NULL, &vy, &vx, NULL, NULL, NULL, &verr);
		}		
	}




Iris
Go to Top of Page

Ibex

Germany
14 Posts

Posted - 06/15/2009 :  09:48:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Iris, that helped a lot.
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