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
 Extract substring using the set values box?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

myrine

Germany
1 Posts

Posted - 03/02/2009 :  09:09:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: Origin 8G, SR2
Operating System: Windows XP Prof.

Hi,

I have a column containing string data such as p23828t281r996.8. Now I want to extract a substring from the position 1 to 5 so that my result would be 23828, and fill this data in another column of the same worksheet. I tried using the set values dialog box and the LabTalk function Mid, but didn't get it to work.

Is it possible to do what I want to do using the dialog box? Or do I have do write a script? I just started using Origin and don't really know much about Origin, LabTalk or OriginC (yet) and I'm running out of ideas, so any help is welcome!

Thanks

easwar

USA
1964 Posts

Posted - 03/02/2009 :  11:29:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Currently you can do this the following way:

Add a new column that is to contain the result, then right click on that column and open the Set Values dialog and then in the Before Formula script enter code such as this:

const nn= _ThisColNum;
range rin= wcol(nn-1), rout= wcol(nn);
for(int ir=1; ir<=rin.getsize(); ir++)
{
  string temp$= rin[ir]$;
  temp$= temp.mid(2,6)$;
  rout[ir]$= temp$;
}



In the above i am assuming the output column is to the immediate right of the input column.

In a future version we will be adding more string processing functions so you can call a suitable function in the top panel without having to write scrit in the bottom panel to loop thru.

Easwar
OriginLab
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