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
 concatenating 2 text columns is a worksheet

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
bplinder Posted - 03/18/2005 : 10:42:25 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

I have 3 text columns in my worksheet, data1_A, data1_B, and data1_C

I would like to concatenate the text in columns B and C and put the result in A.

Is there a simple 1 line code for this?
Or do I need to step through each row?
Also, if i need to loop through each row, is there a command to join the text in B and C together without writing to a temporary variable.

For instance this does not work

Data1_A[1]$ = data1_B[1]$ + data1_C[1]$;


Any help is appreciated.
4   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 11/08/2018 : 10:25:29 AM
Hi bplinder,

If you do such operation often, you can define a macro like following:
///////////////////////////////
def cattextds { // %1:ColRange1, %2:ColRange2
  int nr2=%2.getsize();
  for(ii=1; ii<=nr2; ii++) {
     %1[ii]$=%1[ii]$+%2[ii]$;
  }
}
range r1=col(1);
range r2=col(2);
cattextds r1 r2;
///////////////////////////////
Hope this helps.

--Hideo Fujii
OriginLab
bplinder Posted - 03/18/2005 : 5:07:38 PM
Thanks, you answered my question exactly.


"Note that only one cell value to string --- col(name)[row]$ --- is allowed on the right side of an equation."

This was what i was trying to do. Now I know i can't do that. I'll just code one of the loop structures. Thanks.



greg Posted - 03/18/2005 : 2:49:00 PM
I think what user bplinder wants is to concatenate across rows, as in:

get col(A) -e end;
loop(ii,1,end) {
%A=col(A)[ii]$;
%B=%A;
%A=col(B)[ii]$;
%B=%B %A;
%A=col(C)[ii]$;
%B=%B %A;
col(A)[ii]$=%B;
}

Note that only one cell value to string --- col(name)[row]$ --- is allowed on the right side of an equation. Thus the use of %A and %B to do the actual concatenation. Also, the example puts a space between each item but other examples might use ', ' :

get col(A) -e end;
loop(ii,1,end) {
%A=col(A)[ii]$;
%B=%A;
%A=col(B)[ii]$;
%B=%B, %A;
%A=col(C)[ii]$;
%B=%B, %A;
col(A)[ii]$=%B;
}

or even pseudo multiline :

get col(A) -e end;
loop(ii,1,end) {
%A=col(A)[ii]$;
%B=%A;
%A=col(B)[ii]$;
%B=%B
%A;
%A=col(C)[ii]$;
%B=%B
%A;
col(A)[ii]$=%B;
}

This last example does not display as multiple lines in a cell
(Origin doesn't do that ... yet ;)
but when copied and pasted elsewhere would behave as such.

Mike Buess Posted - 03/18/2005 : 2:09:10 PM
copy -a Data1_B Data1_A;
copy -a Data1_C Data1_A;

Mike Buess
Origin WebRing Member

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