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
 Set Value and extracting numbers from strings

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
evansti4 Posted - 05/11/2012 : 4:37:05 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.6
Operating System: XP

Hi,

I have a worksheet where the first column is a list of file names and I have been trying to use the set column value scripting area to take those file names and cut out the numbers in them and then put the numbers back together into a value. For example in column A I might have tth2p500.lvm and I would like to cut out the 2 and the 500 and put them back together in the next column as 2.500. Now I've been able to get it to work for a single number with

%a = %([Book]Worksheet,Column,Row)
%n = %[%a,>'p']
%n = %[%n,'.']
%m = %[%a,>'h']
%m = %[%m,'p']

and then in the formula area putting col(B) = %m + %n/1000.

I can't figure out how to assign %a so that it corresponds to whatever the file name is in that row not just the one I manually assign it by putting ([Book]Worksheet,1,1) for the first value. I would greatly appreciate any help.

-Tim
4   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 05/14/2012 : 09:33:42 AM
Hi evansti4,

FYI, here is a list of string functions available in ver. 8.0(SR6) or later:

http://wiki.originlab.com/~originla/ltwiki/index.php?title=Category:String_and_Characters_%28Labtalk%29

--Hideo Fujii
OriginLab
evansti4 Posted - 05/11/2012 : 6:17:10 PM
Thank you so much, Hideo that worked perfectly. And Easwar, that is much more readable. We just upgraded from 7 so I'll have to brush up on new notation and syntax. Thanks again, both of you.
easwar Posted - 05/11/2012 : 6:08:56 PM
Hi,

Version 8.x has better string processing capability in script, and the code could be written the following way using new methods, and perhaps is more "readable" than the old % notation.

Easwar
OriginLab


range rin=1, rout=2;
string str$, str1$, str2$;
for(int irow=1; irow<=rin.GetSize(); irow++)
{
   str$=rin[irow]$;
   str1$=str.Between("h","p")$;
   str2$=str.Between("p",".")$;
   rout[irow]=%(str1$) + %(str2$)/1000;
}  
Hideo Fujii Posted - 05/11/2012 : 4:57:55 PM
Hi Tim,

For ii-th row, the assignment %a=col(1)[ii]$; should work to set %a.
Thus, maybe your code would look like:
for(ii=1; ii<=wks.maxRows; ii++) {
  %a=col(1)[ii]$;
  %n = %[%a,>'p'];
  %n = %[%n,'.'];
  %m = %[%a,>'h'];
  %m = %[%m,'p'];
  col(B)[ii]= %m + %n/1000.;
}
--Hideo Fujii
OriginLab

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