Sorting Parameters smallest to largest

Sorting Parameters smallest to largest

Anonymous
Not applicable
604 Views
3 Replies
Message 1 of 4

Sorting Parameters smallest to largest

Anonymous
Not applicable

I am trying to sort Parameters (Width, Height, Thickness) from smallest to largest and then put that format into an iProperty.  No matter what combination of values I try it always returns the WidthxHeightxThickness combination.  

Is iLogic unable to handle these types of expressions or am I missing something very obvious?

Here is my code:

 

If Width <= Height <= Thickness = True Then
	stock = "=<Width>x<Height>x<Thickness>"
	
ElseIf Width > Height <= Thickness = True Then
	
	If Thickness > Width = True Then
		stock = "=<Height>x<Width>x<Thickness>"
		
	Else
		stock = "=<Height>x<Thickness>x<Width>"
		
	End If
	
ElseIf Width < Height > Thickness = True Then
	
	If Width < Thickness = True Then
		stock = "=<Width>x<Thickness>x<Height>"
		
	Else 
		stock = "=<Thickness>x<Width>x<Height>"
		
	End If
		
Else 
	stock = "=<Thickness>x<Height>x<Width>"
	
End If
	
iProperties.Value(doc, "Project", "Description") = stock
MessageBox.Show(stock, "Order")

  

0 Likes
Accepted solutions (1)
605 Views
3 Replies
Replies (3)
Message 2 of 4

ckeveryga
Advocate
Advocate
Accepted solution

Try this.

Dim dblLength, dblWidth, dblThickness As Double

dblHeight = Convert.ToDouble(Parameter.Param("Height").Value)
dblWidth = Convert.ToDouble(Parameter.Param("Width").Value)
dblThickness = Convert.ToDouble(Parameter.Param("Thickness").Value)

Dim dblArray() As Double = {dblHeight, dblWidth, dblThickness }
Dim strArray() As String = {"Height","Width","Thickness"}

Array.Sort(dblArray, strArray)
Array.Reverse(strArray)

iProperties.Value("Project", "Description") = "=<" & strArray(0) & ">x<" & strArray(1) & ">x<" & strArray(2) & ">"

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

This works! Only thing is the Array.Sort(dblArray, strArray) already puts the order in smallest to largest so the Array.Reverse(strArray) undoes the work.

 

Thanks a ton for your help!

 

Regarding my code is iLogic/VBA unable to handle expressions such as W<=H<=T?

0 Likes
Message 4 of 4

ckeveryga
Advocate
Advocate

Oops, thought you needed largest to smallest. 

 

Correct, you can only do one boolean expression at a time (I'm fairly certain at least). So instead of W<=H<=T, you would put:

If W <= H And H <= T Then

 

0 Likes