Compare with wildcard

Compare with wildcard

steven.coxVCM6J
Advocate Advocate
383 Views
4 Replies
Message 1 of 5

Compare with wildcard

steven.coxVCM6J
Advocate
Advocate

Hi all,

 

This is my first try with iLogic and it does not work as expected.

I want to compare the file name with a string and if the same, add a subject in iProperties.

 

My_Expression = ThisDoc.FileName(False) 'without extension
If String.Compare(My_Expression,"01000072*") Then
iProperties.Value("Summary", "Subject") = "My Project Name"
End If

 So all parts in this project will be 01000072-##.ipt  The ## represents a unique number.

I want this rule to trigger before a save (or some point when creating the part)

 

However, what I have puts "My Project Name in all files I run even when the filename does not match.

 

What am I doing wrong?

 

Thanks, Steven

0 Likes
Accepted solutions (2)
384 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

You might want to have a look at the "Like" operator and change your rule to something like this:

My_Expression = ThisDoc.FileName(False) 'without extension
If (My_Expression Like "*01000072*") Then
	iProperties.Value("Summary", "Subject") = "My Project Name"
End If

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 5

A.Acheson
Mentor
Mentor
Accepted solution

You can check the string without a wild card using the string.contains function.

Dim FileName As String = ThisDoc.FileName(False) 'without extension
If FileName.Contains("01000072") Then
	iProperties.Value("Summary", "Subject") = "My Project Name"
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 5

steven.coxVCM6J
Advocate
Advocate

That is what I needed.  I had tried Like but did not use it correctly.

 

Thanks so much!

 

Steven

0 Likes
Message 5 of 5

steven.coxVCM6J
Advocate
Advocate

Thanks for the tip!!

 

Steven

0 Likes