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
 combine columns into a single column

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
aliasthethird Posted - 03/28/2012 : 5:09:25 PM
Hi,
Can this really be this difficult?
I’m trying to combine n columns from a data sheet into a single column on a different sheet.
Here is my attempted. It works outside of the loop, but not inside. The loop is what I'm after.
Any ideas?
Thanks


//create data
range r1 = [Book1]Sheet1!wcol(1);
r1 = data(1,6);
for (ii=1; ii<=4; ii++)
{
range r2 = [Book1]Sheet1!wcol(ii);
r2=r1*ii;
}


//This loop is not working
range OriData = [Book1]Sheet1!;
int Start = 1;
int End = 0;
int ColN=OriData.ncols;
for (ii=1; ii<=ColN; ii++)
{
range r1 = [Book1]Sheet1!wcol(ii);
Start = ;
End = Start + r1.getsize()-1;
End=;
range r2 = [Book1]Sheet1!wcol(ColN+1)[Start:End];
r2 = r1;
Start = End+1;
}


//but this works
range r1 = [Book1]Sheet1!wcol(1);
range r2 = [Book1]Sheet1!wcol(ColN+2)[1:6];
r2 = r1;
range r1 = [Book1]Sheet1!wcol(2);
range r2 = [Book1]Sheet1!wcol(ColN+2)[7:12];
r2 = r1;
range r1 = [Book1]Sheet1!wcol(3);
range r2 = [Book1]Sheet1!wcol(ColN+2)[13:18];
r2 = r1;
range r1 = [Book1]Sheet1!wcol(4);
range r2 = [Book1]Sheet1!wcol(ColN+2)[19:24];
r2 = r1;
2   L A T E S T    R E P L I E S    (Newest First)
aliasthethird Posted - 03/29/2012 : 09:06:08 AM
Its always the little things.
Thanks you so much.
Kathy_Wang Posted - 03/29/2012 : 04:04:35 AM
Hi,

The problem occurs because in range notation, the variable "end" is by default to indicate the last row of the column. So I suggest that instead of using "end" as the variable name, you could choose other variable names. For example, I modified your script as follow and only change "Start" into "i" and "End" into "j", this shall work fine.(Origin version 8.6 SR2)


//create data
range r1 = [Book1]Sheet1!wcol(1);
r1 = data(1,6);
for (ii=1; ii<=4; ii++)
{
range r2 = [Book1]Sheet1!wcol(ii);
r2=r1*ii;
}


//This loop is now working
range OriData = [Book1]Sheet1!;
int i = 1;
int j = 0;
int ColN=OriData.ncols;
for (ii=1; ii<=ColN; ii++)
{
range r1 = [Book1]Sheet1!wcol(ii);
i = ;
j = i + r1.getsize()-1;
j =;
range r2 = [Book1]Sheet1!wcol(ColN+1)[i:j];
r2 = r1;
i = j+1;
} 



Kathy
Originlab

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