Quote:
Originally Posted by
chatwizrd
Why do you need a exit, break or continue have you tried just without all those?
The reason I need to quit from the loop is because each function is required only upon the success of the previous function, so in this case, I dont want to waste the time and resources attempting to run function2 if function1 has failed, (there are many of these related functions which are all reliant on the success of the previous one but my example shows just two)
If function1 has failed (i.e. a ping check fails in the example given above) I do not want it to move on to function2 (which checks the contents of a file) but to instead quit out of that loop and move onto the next loop item which will start at function1 again
The idea being like a series of sequential tests with only the loop items that pass every function test getting to the very last function
I can achieve this successfully via a series of nested if's upon more nested if's or indeed if I place the if statements within the body of the "for" loop (as stated above)...but i dont really want to do that as I would prefer to get this all working with functions
hope that makes it clearer