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
 LabTalk Forum
 Access single columns out of a range

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
Ibex Posted - 06/12/2009 : 11:25:14 AM
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
2   L A T E S T    R E P L I E S    (Newest First)
Ibex Posted - 06/15/2009 : 09:48:21 AM
Thanks Iris, that helped a lot.
Iris_Bai Posted - 06/15/2009 : 12:11:02 AM
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

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