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
 Extract substring using the set values box?

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
myrine Posted - 03/02/2009 : 09:09:14 AM
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
1   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 03/02/2009 : 11:29:02 AM
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

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