I adjusted the code in the examples and got results as expected in all situations.
callee.cmd:
Code: Select all
@echo off
set "$PERCENT=%%%%~$=_p1_FOR-variable_DOLLAR_is_required_while_MACRO_DEFINITION_=:$"
FOR %%$ in (DOLLAR) DO (
set "__macro= do (if /i "%$PERCENT%~A" equ "_some value" (echo("some value" detected) else (echo(incorrect value detected))"
)
%__call%("_%*") %__macro%
exit /b
When executing i get results as expected:
>callee some value
"some value" detected
>callee other value
incorrect value detected
>caller_directly.cmd some value
"some value" detected
>caller_directly.cmd other value
incorrect value detected
>caller_FOR.cmd some value
"some value" detected
>caller_FOR.cmd other value
incorrect value detected
Many thanks all for the help and very quick responses!