My concern is that using ProcedureReturn in that case will leave cruft behind due to loop initialization data, etc, not being cleaned up. So, ideally the documentation should be perfectly clear on whether or not using ProcedureReturn from within a loop is valid.
The current docs say:-
Which tells me nothing about whether or not it is a valid thing to do. Assuming calling it within a loop is valid then I'd rather it say:-A call of ProcedureReturn exits immediately the procedure, even when its called inside a loop.
Assuming calling it within a loop is not valid then I'd rather it say:-A call to ProcedureReturn immediately exits the procedure, even when it's called inside a loop. Note that calling ProcedureReturn from within a loop is valid, as all resources are cleaned up and no issues can arise from this approach.
Because I'm unsure which approach is valid I find myself using code such as that below.A call to ProcedureReturn immediately exits the procedure, even when it's called inside a loop. Note that calling ProcedureReturn from within a loop is NOT valid, as some resources are not properly cleaned up and issues can arise from this approach.
Code: Select all
; Ensure that the nodes do not have an existing straight connection between them.
abort = 0
ForEach StraightPathList()
If ( *node1 = StraightPathList()\node1 And *node2 = StraightPathList()\node2 ) Or ( *node2 = StraightPathList()\node1 And *node1 = StraightPathList()\node2 ) ; If the nodes are connected in either order.
abort = 1 ; Flag that the function should abort and return a zero to indicate that the nodes can't connect.
Break
EndIf
Next
If abort : ProcedureReturn 0 : EndIf