Page 1 of 1

Scratching my head with this Function behavoir....

Posted: 11 Sep 2021 08:04
by SIMMS7400
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?

Re: Scratching my head with this Function behavoir....

Posted: 11 Sep 2021 09:24
by miskox
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

Re: Scratching my head with this Function behavoir....

Posted: 11 Sep 2021 12:04
by ShadowThief
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.

Re: Scratching my head with this Function behavoir....

Posted: 12 Sep 2021 14:44
by SIMMS7400
Gotchya, Shadow. Makes sense. I'll update my script and retry.

Thank you for the feedback!