- Jun
- 2
- 0
I'm not sure if this is a bug or WAD, but it appears that backquoted parameter strings passed to subroutines do not get treated as a single parameter with embedded spaces as they do when calling a separate batch/btm file.
I was able to get around the issue by making the last parameter for the subroutine "hungry" with a trailing "*".
Below is a a simple example which demonstrates the situation. If this is WAD, it might be worth mentioning in the help file entry for GoSub.
Thanks,
-Michael
[C:\Batfile]type TestParameters.btm
@echo off
GoSub TestSubParams 1stParam "2nd Param" `3rd Param`
call TestBTMParams.btm 1stParam "2nd Param" `3rd Param`
quit
:: ========================================================
::
:TestSubParams [p1,p2,p3]
::
:: ========================================================
echo.
echo --- SubRoutine
echo --------- P1: %p1
echo --------- P1: %p2
echo --------- P3: %p3
return
[C:\Batfile]type TestBTMParams.btm
@echo off
echo.
echo --- Called BTM
echo --------- P1: %1
echo --------- P1: %2
echo --------- P3: %3
quit
[C:\Batfile]TestParameters.btm
--- SubRoutine
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd
--- Called BTM
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd Param
[C:\Batfile]
I was able to get around the issue by making the last parameter for the subroutine "hungry" with a trailing "*".
Below is a a simple example which demonstrates the situation. If this is WAD, it might be worth mentioning in the help file entry for GoSub.
Thanks,
-Michael
[C:\Batfile]type TestParameters.btm
@echo off
GoSub TestSubParams 1stParam "2nd Param" `3rd Param`
call TestBTMParams.btm 1stParam "2nd Param" `3rd Param`
quit
:: ========================================================
::
:TestSubParams [p1,p2,p3]
::
:: ========================================================
echo.
echo --- SubRoutine
echo --------- P1: %p1
echo --------- P1: %p2
echo --------- P3: %p3
return
[C:\Batfile]type TestBTMParams.btm
@echo off
echo.
echo --- Called BTM
echo --------- P1: %1
echo --------- P1: %2
echo --------- P3: %3
quit
[C:\Batfile]TestParameters.btm
--- SubRoutine
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd
--- Called BTM
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd Param
[C:\Batfile]