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
 Convert strings to numbers when setting column val

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
vadb Posted - 10/31/2013 : 3:36:48 PM
I am trying to set the values of a column based on string parameters in a another column. For instance, in column 3 I have strings such as:
dt=50_dx=100

In column 1, I would like to extract the values of dt, so I have the following in the "set column values" field:
Mid(wcol(3),9,2)$

However, this only extracts the string. How do I convert this to a number? Is there anything like excel's value() function?

Thank you in advance!
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 9.0.0 (64-bit) SR2
Operating System: Win7 x64

6   L A T E S T    R E P L I E S    (Newest First)
vadb Posted - 10/31/2013 : 5:30:17 PM
Thanks, Hideo! Both solutions work.
greg Posted - 10/31/2013 : 5:03:34 PM
value( ) is a new function in 9.1.

Use this in the Before Formula Scripts section in older versions of Origin:

range rai = col(3);
range rao = col(extract);
loop(ii,1,rai.GetSize())
{
str$ = mid(rai[ii]$,4,2)$;
rao[ii] = %(str$);
}
vadb Posted - 10/31/2013 : 4:50:23 PM
Hi Hideo,

I was actually referring to the value() suggestion not working (I didn't see your other link until now).
Hideo Fujii Posted - 10/31/2013 : 4:43:48 PM
Hi,

Sorry! Value( ) function works in version 9.1, and seems it was not implemented in 9.0. As a work-around, after extracting the strings, you can change the column's format to "Numeric" from the default "Text & Numeric".

--Hideo Fujii
OriginLab
vadb Posted - 10/31/2013 : 4:39:49 PM
Hi Hideo,

I tried your suggestion but the resulting values in the calculated column are still strings...
Hideo Fujii Posted - 10/31/2013 : 4:15:42 PM
Hi vadb,

You can use the value(...) function to convert a string to a number such as:
value(Mid(col(3)$,9,2)$)
See the detail at: http://wikis/ltwiki/index.php?title=LabTalk%3AValue_%28function%29

Does it work in your situation?

--Hideo Fujii
OriginLab

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