iLogic: Start a Rule Over

iLogic: Start a Rule Over

Anonymous
Not applicable
729 Views
6 Replies
Message 1 of 7

iLogic: Start a Rule Over

Anonymous
Not applicable

I have a part and I have an input box for a parameter.  That parameter has a lot of checks because it needs to be a positive integer and also cannot interfere with other features.  So in this case I have a rule with If Then Statements for being >0, An Integer, etc.  The problem is that I do not know how to "Re-Start" the rule when the parameter fails one (or more) of the If Then Statements.  As of right now if I enter a value that is wrong twice it just goes with the incorrect value.  I would like it just keep going back to the Input Box if it fails one of the Statements.

 

Thanks!!

0 Likes
Accepted solutions (2)
730 Views
6 Replies
Replies (6)
Message 2 of 7

Lewis.Young
Collaborator
Collaborator

Hello,

 

Please could you copy and paste the code here so i can have a look?

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017
3ds Max 2018

0 Likes
Message 3 of 7

lmc.engineering
Advocate
Advocate
Accepted solution

Hi @Anonymous

 

You can use a GoTo command to achieve this, such as:

 

SyntaxEditor Code Snippet

Sub Main()
	ReStartPos:
	'''Your Rule code
	''' parameter checks etc...
	
	''Check parameter fits conditions:
	If myParameter = x Then
		''Proceed
	Else
		'''Go to this location
		GoTo ReStartPos
	End If
End Sub

If this isn't easy enough to understand, post your code here and we give you a more precise answer.

0 Likes
Message 4 of 7

philip1009
Advisor
Advisor

Like @lmc.engineering suggested, you can put in Goto jumps to restart your checks.  Another solution is a Do loop that repeats code until conditions are met:

 

SyntaxEditor Code Snippet

Dim i As Integer
Do
	i = InputBox("Number must be whole and greater than 0.", "Input Number", i)
Loop Until i > 0
Message 5 of 7

Anonymous
Not applicable

Hello,

 

So my current is this:

 

SyntaxEditor Code Snippet

ReamedHoleLocation = InputBox("Enter Reamed Hole Location (Whole Number)", "Reamed Hole Location", "Reamed Hole Location")
		
If ReamedHoleLocation <> Int(ReamedHoleLocation) Then
	'Get New Input
End If
		
If ReamedHoleLocation < 1 Then
	'Get New Input
End If

 

I ask the user for an input location.  It has to be a whole number and cannot be negative (there will be several more checks other than just these two, but I have left it to these two to make it easier at the moment).  After the input my code checks the input to ensure that it is a whole number and non negative.  If the input fails the test I need the code to ask the user for another input.  I would just like to start the code over again at the input box if possible.

 

Any other way that I try I can beat the system if I just enter the same (incorrect) value twice.

 

Thanks!!

0 Likes
Message 6 of 7

Anonymous
Not applicable

Please see reply to another user for an example of my code.

 

Many Thanks!!

0 Likes
Message 7 of 7

Lewis.Young
Collaborator
Collaborator
Accepted solution

SyntaxEditor Code Snippet

RestartPosition:

ReamedHoleLocation = InputBox("Enter Reamed Hole Location (Whole Number)", "Reamed Hole Location", "Reamed Hole Location")
        
If ReamedHoleLocation <> Int(ReamedHoleLocation) Then
    Goto RestartPosition
End If
        
If ReamedHoleLocation < 1 Then
    Goto RestartPosition
End If

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017
3ds Max 2018

0 Likes