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 for Programming
 LabTalk Forum
 Use of wildcard characters in long name matching
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ds755

57 Posts

Posted - 10/02/2019 :  4:03:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Edited by - ds755 on 10/02/2019 4:17:22 PM

YimingChen

1669 Posts

Posted - 10/03/2019 :  09:39:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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