You can pass a string to a called routine and have it return an environment variable whose name is the string.
Example:
If you wish to determine how many parameters your batch file was passed, and return the results in a environment variable
named
answer, include the following statement in your batch:
call cntargs answer %*
NOTE: The variable answer need not be defined.
The cntargs batch file could contain:
@echo off
if {%1}{} endlocal&set /a %1=%numargs%&goto :EOF
set /a numargs=%numargs% + 1
shift /2
goto numloopAfter the
call cntargs answer %* statement, you can use the
answer environment variable, as
in
@echo My batch was passed %answer% parameters.