iLogic MultiValue.FindValue for text

iLogic MultiValue.FindValue for text

dusan.naus.trz
Advisor Advisor
599 Views
5 Replies
Message 1 of 6

iLogic MultiValue.FindValue for text

dusan.naus.trz
Advisor
Advisor

I think the functionality doesn't support text. Is it true? Not supported for text? 

 

MultiValue.SetValueOptions(True, DefaultIndex := 0)
'OK
'Try 
'	p1="test"
'	m1 = Parameter.Param(p1)
'Catch
''	Create Parameter
'	op1 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p1, 4.0, "mm")
'End Try

'MultiValue.SetList("test", 4.0, 0.75, 1.0, 1.25)
'If MultiValue.FindValue(MultiValue.List("test"), "=", 100) Then
'MessageBox.Show("Value found", "Title")
'Else
'MessageBox.Show("No match", "Title")
'End If

'BAD Try p1="test" m1 = Parameter.Param(p1) Catch ' Create Parameter op1 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByValue(p1, "red", "Text") End Try MultiValue.SetList("test", "red", "yellow") If MultiValue.FindValue(MultiValue.List("test"), "=", "red") Then MessageBox.Show("Value found", "Title") Else MessageBox.Show("No match", "Title") End If

dusannaustrz_2-1645220834760.png

It hasn't written me a mistake in English yet. 🙂 And I have an English language version.

Converting red to Boolean is not valid.

0 Likes
Accepted solutions (2)
600 Views
5 Replies
Replies (5)
Message 2 of 6

dusan.naus.trz
Advisor
Advisor

I did it differently, but I would still like to know if the functionality supports text. Back to the query at the beginning. 

 

Dim sValue As String
sValue = "red"

For Each oItem In MultiValue.List("test")
	If oItem = sValue Then
	oFlag = True
	End If
Next

If oFlag = True Then
MessageBox.Show("Bingo! " &  sValue & " is in the list.", "iLogic")
Else
MessageBox.Show("Sorry, " &  sValue & " is NOT in the list.", "iLogic")
End If

 

0 Likes
Message 3 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

try it like this:

Dim sValue As String
sValue = "red"

If (MultiValue.FindValue(MultiValue.List("test"), "=", sValue) = Nothing) Then
	MessageBox.Show("Sorry, " &  sValue & " is NOT in the list.", "iLogic")
Else
	MessageBox.Show("Bingo! " &  sValue & " is in the list.", "iLogic")	
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 4 of 6

dusan.naus.trz
Advisor
Advisor

Hi, I really like the simplicity. It is very practical. Thank you.

0 Likes
Message 5 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

to be honest, if I would see this in any code I would not be happy. Writing code is not that difficult but writing readable code is much more of a challenge. And I did not succeed here I think. The following would be much better I think.

Dim sValue As String
sValue = "Red"

If (MultiValue.List("test").Contains(sValue)) Then
	MessageBox.Show("Bingo! " &  sValue & " is in the list.", "iLogic")
Else
	MessageBox.Show("Sorry, " &  sValue & " is NOT in the list.", "iLogic")		
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 6 of 6

dusan.naus.trz
Advisor
Advisor

That's great. When the code is simple, then it is fast in greater use. Thank you for the different variants. Different perspectives on the solution are very beneficial.

0 Likes