Is there a better way to handle EStops in a nested loop?  I need to stop the loops from running if the EStop is pressed.  If I dont once the machine is returned to safe mode the Nested Loop continues to run.
Here is my VB Code:
Sub Main
If IsEStop() Then
    Print ("Estop")
    Exit Sub
Else
For r = 1 to 3
If IsEStop() Then
    Print ("Estop")
    Exit Sub
Else
Print "r=" & r
End If
For i = 1 to 10
If IsEStop() Then
    Print ("Estop")
    Exit Sub
Else
Print "i=" & i
End If
Next i
Next r
End If
End Sub