Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#1
Post
by SIMMS7400 » 11 Sep 2021 08:04
HI Folks -
I have the following logic:
Code: Select all
::-- Run Pre Rule(s) based on criteria --::
SET "RUN_OBJECT="
IF /I "[%POV_CNT%]"=="[0]" (
SET "RUN_OBJECT="
FOR %%A IN (%DM_D_POV_LIST:,= %) DO IF DEFINED %%~A IF /I "[%CNT%]"=="[1]" SET "RUN_OBJECT=T"
IF /I "[%%~A]"=="[DM_D_FN_POV]" SET "RUN_OBJECT=T"
FOR %%A IN (%DM_D_DCPOV_LIST:,= %) DO IF DEFINED %%~A SET "RUN_OBJECT=T"
) & IF DEFINED RUN_OBJECT CALL :RUN_OBJECT "Pre" || GOTO END
What's happening is when it comes back from :RUN_OBJECT, it always goes to the GOTO END portion to the right of the || symbols even though it was successful. Why is it doing this?
-
miskox
- Posts: 630
- Joined: 28 Jun 2010 03:46
#2
Post
by miskox » 11 Sep 2021 09:24
Maybe use parantheses:
Code: Select all
IF DEFINED RUN_OBJECT (CALL :RUN_OBJECT "Pre" || GOTO END)
Shouldn't there be only one of | ?
Guessing.
Saso
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#3
Post
by ShadowThief » 11 Sep 2021 12:04
Since you chain the two ifs together with an &, the script doesn't have a chance to update the value of the RUN_OBJECT variable so it incorrectly believes that it's still unset.
There's pretty much no reason to ever use & to combine two commands.
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#4
Post
by SIMMS7400 » 12 Sep 2021 14:44
Gotchya, Shadow. Makes sense. I'll update my script and retry.
Thank you for the feedback!