By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!v:\> type deferbat.btm
defer v:\echofoo.btm
v:\> type v:\echofoo.btm
echo foo
v:\> deferbat.btm
v:\> notepad deferbat.btm
< no prompt until notepad was closed >
I think DEFER only goes back seven or eight years. I can't think of a reason one would *NEED* to DEFER anything (and if there is, I don't see why batch file should be special). DEFER seems to be just a convenience.DEFER was never intended for executing batch files, and would in fact require rewriting the parser to support that.
But since I can't think of any reason why you would need to DEFER a batch file, I don't think it's a significant limitation (and nobody has found any reason to do it for 20 years!).
v:\> type deferbat.btm
echo I am %0
defer echo arg0 = %%0
quit
I'm not sure I understand the problem -- can you provide an example?
:: ----------------------
:: %1=version, %2=appspec
:: ----------------------
set LibVersion=0.8
set AppVersion=%@REGEXSUB[1,"(\d+\.\d+(\.\d+)*|auto)","%1"]
switch "%AppVersion"
case "auto"
set MappedVersion=%LibVersion
case "0.1"
set MappedVersion=0.4
case "0.2"
set MappedVersion=0.4
default
iff "%AppVersion" eq "" then
echoerr %@upper[%@name[%0]]: version not recognized.
else
echoerr %@upper[%@name[%0]]: version %AppVersion is not supported.
echoerr Depreciated versions should adapt to the next higher supported version.
endiff
quit 1
endswitch
:: By slightly defering the chain,
defer %jpHome\Projects\TCApp\v%MappedVersion\TCApp.BTM %2$
:: you can cleanup _all_ envars.
:: In the case of MappedVersion important for reentrancy of the framework
unset AppVersion LibVersion MappedVersion
quit 0
I use this line in temporary batch files that only need to be run once:
Code:defer del %0
(That works because the %0 is expanded at the time of the DEFER command.)
:: ------
:__TmpBtm [ in_basepath _autodel ]
:: ------
set tmpFile=%@QUOTE[%@UNIQUE[%@IF["%in_basepath" eq "",%temp,%in_basepath]]]
set _TmpBtm=%%@RTRIM[.txt,%tmpFile].BTM
ren /q %tmpFile %_TmpBtm
if %_autodel==1 defer del /q %_TmpBtm
unset tmpFile
return
DEFER was never intended for executing batch files, and would in fact require rewriting the parser to support that.
But since I can't think of any reason why you would need to DEFER a batch file, I don't think it's a significant limitation (and nobody has found any reason to do it for 20 years!).
I use this line in temporary batch files that only need to be run once:
Code:defer del %0
(That works because the %0 is expanded at the time of the DEFER command.)
Really Rex, "blaming the customer" ?
You can not blame the customer for not knowing the intended use if it's not mentioned in the manual.
a "command" in the context of the help file refers only to internal or external commands, not batch files. If batch files were also supported they would be explicitly mentioned.
defer call batch_file
Anyway, what about
That seems to work just fine, even if deferred BTMs themselves use "defer call batch_file".Code:defer call batch_file
I think we're pretty used to "command" including batch files, aliases, URLs, ... anything with an association. START and DO /P, for example, handle batch files without the help explicitly saying so.