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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Convert strings to numbers when setting column val
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vadb

9 Posts

Posted - 10/31/2013 :  3:36:48 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Hideo Fujii

USA
1582 Posts

Posted - 10/31/2013 :  4:15:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Hideo Fujii on 10/31/2013 4:41:59 PM
Go to Top of Page

vadb

9 Posts

Posted - 10/31/2013 :  4:39:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,

I tried your suggestion but the resulting values in the calculated column are still strings...
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 10/31/2013 :  4:43:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Hideo Fujii on 10/31/2013 4:52:02 PM
Go to Top of Page

vadb

9 Posts

Posted - 10/31/2013 :  4:50:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,

I was actually referring to the value() suggestion not working (I didn't see your other link until now).
Go to Top of Page

greg

USA
1378 Posts

Posted - 10/31/2013 :  5:03:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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$);
}
Go to Top of Page

vadb

9 Posts

Posted - 10/31/2013 :  5:30:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, Hideo! Both solutions work.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000