Replaceable ParametersBatch programs can be passed parameters on the command line. These parameters can be referenced by using replaceable parameters. There are a maximum of 10 replaceable parameters allowed, specified by %0 through to %9 inside a batch program and the special cases %# which returns the number of parameters passed to the batch program, %* which returns the batch programs original command line tail and %~ which is a modifier. The ~ modifiers have the following syntax :-
Modifiers can be combined to get compound results, for example :-
There is no particular order the modifers need to be specified. env can be any valid environment variable, such as the PATH envirnoment variable. The ~ modifiers can not be used with %*.
For example, consider the batch program below called PARAMS.BAT. This batch program displays the total number of parameters, along with the first 10 parameters passed to the batch program with the double quotes removed from each parameter :-
ECHO %%* is %*
ECHO %%# is %#
LET num=%num% + 1
%# is 2
%0 is PARAMS
Copyright © 1995-2018 Lucien Cinc, All Rights Reserved
WinOne® is an Australian registered trademark
Go to the Australian Command Line Software web site.