Set iLogic form box to '0' if other form box selected

Set iLogic form box to '0' if other form box selected

mark_h_ellis
Participant Participant
319 Views
1 Reply
Message 1 of 2

Set iLogic form box to '0' if other form box selected

mark_h_ellis
Participant
Participant

Hopefully someone can help me as i'm going around in circles.

I have two dummy parameters TWIST_LEFT & TWIST_RIGHT in an iLogic form that are limited to values of between 0 & 90 degrees each. What I want is if one parameter is selected and changed (within 0 & 90) then the 2nd parameter is set to 0.

I have included my code which seems to end up in a loop of setting both dummy parameters to 0 and not allowing any change then, I can see why but can't think of a solution.

Many thanks

' ******* TWIST_CHUTE_LEFT Limits *******
If TWIST_LEFT < 0 Then
	TWIST_LEFT = 0
	MessageBox.Show("The minimum value for 'CHUTE TWIST ANGLE ANTI-CLOCKWISE' is: 0 " & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	ElseIf TWIST_LEFT > 90 Then
	TWIST_LEFT = 90
	MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE ANTI-CLOCKWISE' is: 90 " & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	Else
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	If TWIST_RIGHT = 0 Then
		ELSE
		TWIST_RIGHT = 0
		End If
End If

If TWIST_RIGHT < 0 Then
	TWIST_RIGHT = 0
	MessageBox.Show("The minimum value for 'CHUTE TWIST ANGLE CLOCKWISE' is: 0 " & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	ElseIf TWIST_RIGHT > 90 Then
	TWIST_RIGHT = 90
	MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE CLOCKWISE' is: 90 " & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	Else 
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
	If TWIST_LEFT = 0 Then
		Else
		TWIST_LEFT = 0
		End If
End If
0 Likes
320 Views
1 Reply
Reply (1)
Message 2 of 2

ianteneth
Advocate
Advocate

Hi @mark_h_ellis,

 

You have probably figured this out by now, but here is my attempt to fix this code snippet. Hopefully, you or someone else can still find it helpful. Also, below is a table that shows what left and right would be depending on a few test inputs (on the left). I hope I moved the parameter setting code to the right spots, I wasn't sure what parameters were supposed to be set when. But hopefully, you can figure that out if its wrong.

I think the main issue with your original code is that last "else" statement in the twist right sections. It was responsible for setting twist left to zero even if it was in the correct range. I just removed those else statements and made a new if statement at the bottom. The new if statement is a better way to set one of the twists to zero. Anytime twist left is bigger than zero if will set the right to zero. Otherwise, it will choose twist right.

 

Screenshot 2021-08-10 142208.png

 

' Adjust twist left
If TWIST_LEFT < 0 Then
	TWIST_LEFT = 0
	MessageBox.Show("The minimum value for 'CHUTE TWIST ANGLE ANTI-CLOCKWISE' is: 0 " & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
ElseIf TWIST_LEFT > 90 Then
	TWIST_LEFT = 90
	MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE ANTI-CLOCKWISE' is: 90 " & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
End If

' Adjust twist right
If TWIST_RIGHT < 0 Then
	TWIST_RIGHT = 0
	MessageBox.Show("The minimum value for 'CHUTE TWIST ANGLE CLOCKWISE' is: 0 " & vbCr & "The value will be automatically corrected to the minimum.", "Minimum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
ElseIf TWIST_RIGHT > 90 Then
	TWIST_RIGHT = 90
	MessageBox.Show("The maximum value for 'CHUTE TWIST ANGLE CLOCKWISE' is: 90 " & vbCr & "The value will be automatically corrected to the maximum.", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
End If

' NEW IF STATEMENT
' By this point left and right are either 0, 90, or somewhere between
' Check if both are in the correct range or just one
If TWIST_LEFT > 0 Then ' Anytime twist left is not 0 choose left and set right to 0
	TWIST_RIGHT = 0
	parameter("DCHUTE_TWIST_LEFT") = TWIST_LEFT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
Else ' When left is 0, choose right
	TWIST_LEFT = 0
	parameter("DCHUTE_TWIST_RIGHT") = TWIST_RIGHT
	DCHUTE_TWIST_ANGLE1 = parameter("DCHUTE_TWIST_ANGLE1")
End If

 

0 Likes