|Best I can do is give a simplified example. You can probably google for more accurate and robust coverage of batch. Much is provided simply by: FOR /?|
from the cmd window. The following tries to demonstrate nested FOR, and calls to external routines which can get around the delayedexpansion:
@echo off & setlocal enabledelayedexpansion
for /l %%a in (1 1 5) do (
for /l %%b in (100 1 105) do (
:: set a "regular" variable to a "system" var value
:: show result using both notations
echo outer: %%a inner: %%b *** b to v... v: perc: %v% exclm: !v!
:: call out to external subroutine with no arguments
:: this is much easier
call :bb %%a %%b
echo now in subrutine aa, v is: perc: %v% exclm: !v!
for %%z in (1) do (
echo system var.s recovered in sub aa: ---a: %%a ---b: %%b
echo subrtn bb, input values: %1 ***** %2