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
 Origin Forum
 Join String Operation in "Set columns"

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
premiumxy Posted - 09/15/2010 : 04:12:40 AM
Dear all,

I have a - to my opinion - simple problem: I have two columns, containing numbers. I want to combine these numbers with a string operation in a third column (and later use this column as a label-column).

Example:

ColA ColB ColC
1 5 15

How can I (1) convert numbers to string, and (2) join these strings?
5   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 09/17/2010 : 12:10:38 AM
Hi Stefan,

Actually, you don't need to use $() notation for ii from Origin 8. So you can just use the script like:

for(ii=1; ii<=wks.maxrows; ii++)
{
	string str1$ = $(col(a)[ii]);
	string str2$ = $(col(b)[ii]);
	col(c)[ii]$ = str1$+str2$;
}


Penn
premiumxy Posted - 09/16/2010 : 11:44:42 AM
Thanks a lot!
Penn Posted - 09/15/2010 : 10:52:51 PM
Hi Stefan,

For 1st question:
The $() notation is used for numeric to string conversion. This notation evaluates the given expression at run-time, converts the result to a numeric string, and then substitutes the string for itself. Please refer to substitution notation.

For 2nd question:
This is about how to access column object. Please refer to this page.

Penn
premiumxy Posted - 09/15/2010 : 06:52:19 AM
Thank you very much, Penn. Problem solved to 100%! :-)

May I still ask two little things (giving me a link for further reading is also ok), since I am new to LabTalk:

(1) Why do you use $(ii) instead of just ii to reference to the variable ii?
(2) I tried to change the type of the column to "label" via
wks.col3.type = 5;
It only worked for "col3" but not for col(c). In your example, col(c) did also work. Why?

Thanks a lot,
Stefan
Penn Posted - 09/15/2010 : 05:34:13 AM
Hi,

About how to convert numeric to string, please refer to this page. For your case, you need a loop structure to go through all the rows. You can put the following script in the Before Formula Scripts panel of the Set Values dialog and have a try.

for(ii=1; ii<=wks.maxrows; ii++)
{
	string str1$ = $(col(a)[$(ii)]);
	string str2$ = $(col(b)[$(ii)]);
	col(c)[$(ii)]$ = str1$+str2$;
}


Penn

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