Backquoted parameters used in GoSub don't pass string as a single parameter

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.


[C:\Batfile]type TestParameters.btm

@echo off

GoSub TestSubParams 1stParam "2nd Param" `3rd Param`
call TestBTMParams.btm 1stParam "2nd Param" `3rd Param`


:: ========================================================
:TestSubParams [p1,p2,p3]
:: ========================================================

echo --- SubRoutine
echo --------- P1: %p1
echo --------- P1: %p2
echo --------- P3: %p3

[C:\Batfile]type TestBTMParams.btm

@echo off

echo --- Called BTM
echo --------- P1: %1
echo --------- P1: %2
echo --------- P3: %3



--- SubRoutine
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd

--- Called BTM
--------- P1: 1stParam
--------- P1: "2nd Param"
--------- P3: 3rd Param



Staff member
May 14, 2008
WAD. The single back quotes are removed by the parser before the GOSUB command is called. (They are not removed by CALL, because the parser assumes whoever is the target of the CALL will deal with quoting.)

Change your GOSUB command to escape the back quotes so they won't be removed during preprocessing:

GoSub TestSubParams 1stParam "2nd Param" ^`3rd Param^`
Perfect. Thanks for the quick response. Now that I understand how it works I see that escaping the backquotes will let me pass spaces in any parameter, not just not just the last one.
Similar threads
Thread starter Title Forum Replies Date
D Can alias pass parameters to for command? Support 3
vefatica Documentation Function parameters Support 0
vefatica Quoting @Function parameters? Support 0
vefatica Batch parameters broken? Support 2
D Arithmatic on a sub's parameters Support 4
T Fixed Problem with use of Batch parameters in the IDE Support 1
D Documentation Modifying GOSUB parameters Support 10
H UNIQUE[] without parameters gives error Support 1
vefatica Aliases ... appending unused parameters? Support 2
Jay Sage WAD Possible Bug in Batch Parameters Support 7
E Parameters dialog box problem Support 2
Rich Skorski effect of CMDVariables on parameters Support 3
D Clear alias parameters Support 7
Mordachai Help! How to set parameters for script I'm debugging?! Support 6
S Documentation Topic: Batch File Parameters Support 14
R command line parameters / file associations Support 4
Y TC Tab parameters Support 2
T Passing parameters from a file Support 4
M ANSI is used to show files instead of OEM in version 17 to 19 ! Support 5
R ffind not setting %_ffind_ vars if /f is used Support 7
D Can ANSI escape sequences be used in keystroke aliases? Support 8
Jay Sage How to Determine INI File Used by TCMD Support 6
I most used commands Support 2
R /p when used with DEL Support 1
C Does removing a registered TCMD lower the number registrations used? Support 5
D TCC can't start app if @shfolder[42] used for path Support 1
T Fixed free reports negative used amount Support 8
Q TCC: (Sys) The process cannot access the file because it is being used by another process. Support 0
Ville BUG: 'dig' of bind 9.6.0 P1 crashes when used with TC10 Support 6
S Wrong .INI file used by TCC Support 2

Similar threads