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 for Programming
 LabTalk Forum
 Use of wildcard characters in long name matching

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
ds755 Posted - 10/02/2019 : 4:03:03 PM
Hello,

In my scripts I very frequently search for the existence of certain long names. I do this using a trick that I was shown in the forum:

https://my.originlab.com/forum/topic.asp?TOPIC_ID=44260

Now I find myself in a situation where I need to check if a workbook exists, whose long name partially matches a string. In a web search engine we would use the wildcard character * to mean "anything". For example, if I check that Book1* exists, then that should return a positive for Book1, Book12, Book111111 etc ("Book1" plus "anything").

How do I do this in Labtalk?

My code looks like this:

string nextmeassheetname$="%(batch$)_%(meastype$)_$(%(measNo$)+1)*";
if(exist(%(uid2name(range2uid(["%(nextmeassheetname$)"]))$))!=0)
continue; // if this is not the last measurement of its kind, then continue to the next iteration


Notice the wildcard written in $(%(measNo$)+1)*. The wildcard character * does not work in this case....


By reading the tutorials, I understood that the exist function does not support wildcard characters.


Origin Ver. and Service Release (Select Help-->About Origin): Origin 2019
Operating System: Windows 8.1
1   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 10/03/2019 : 09:39:49 AM
Hi,

You will have to loop over all workbooks and test the book name individually. Please check the script Chris gave in this forum item:
https://my.originlab.com/forum/topic.asp?TOPIC_ID=44260

You can use Find method of string for testing:
https://www.originlab.com/doc/LabTalk/ref/String-obj#Find

Thanks,
James

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