Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
mirrormirror
- Posts: 129
- Joined: 08 Feb 2016 20:25
#1
Post
by mirrormirror » 24 Feb 2016 19:49
Does exiting a function/for loop/ IF statement before it completes cause any issues? Like using extra memory or other things. I may not be using the correct terminology but look at these examples to see what I mean:
Code: Select all
IF NOT DEFINED myVAR (
ECHO - error message...
GOTO :EOF
)
vs
Code: Select all
IF NOT DEFINED myVAR (
ECHO - error message...
)
IF NOT DEFINED myVAR GOTO :EOF
The FIRST example exits the IF statement before the parentheses are closed - the SECOND one does it AFTER they are closed. Are there any issues with doing it the first way - or any differences between the two methods?
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 25 Feb 2016 17:24
The first method is common and causes no issues that I'm aware of.
If you do it within a loop that is counting, then the loop doesn't return until it has finished. This just means a delay before it exits, and if the loop count is very large then the delay will be noticeable.