The system I'm using is win2000
Right now I have 1.bat and 2.bat
The contents of 1.bat are:
del 1.txt
set a=10
set b=1
call 2.bat
echo end>>1.txt
The contents of 2.bat are:
echo %%%a%%%>>1.txt
set /a a=a-1
if %a% GTR 0 call 2.bat
echo %%%b%%%>>1.txt
set /a b=b+1
Execution result:
%10%
%9%
%8%
%7%
%6%
%5%
%4%
%3%
%2%
%1%
%1%
%2%
%3%
%4%
%5%
%6%
%7%
%8%
%9%
%10%
end
If I change %%%a%%% in 2.bat to %a%, and %%%b%%% to %b%
the result becomes:
10
ECHO is on.
ECHO is on.
10
end
In the black command window:
C:\>del 1.txt
C:\>set a=10
C:\>set b=1
C:\>call 2.bat
C:\>echo 10 1>>1.txt
C:\>set /a a=a-1
C:\>if 9 GTR 0 call 2.bat
C:\>echo 9>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 8 GTR 0 call 2.bat
C:\>echo 8>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 7 GTR 0 call 2.bat
C:\>echo 7>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 6 GTR 0 call 2.bat
C:\>echo 6>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 5 GTR 0 call 2.bat
C:\>echo 5>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 4 GTR 0 call 2.bat
C:\>echo 4>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 3 GTR 0 call 2.bat
C:\>echo 3>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 2 GTR 0 call 2.bat
C:\>echo 2>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 1 GTR 0 call 2.bat
C:\>echo 1>>1.txt
C:\>set /a a=a-1
C:\>if 0 GTR 0 call 2.bat
C:\>echo 1>>1.txt
C:\>set /a b=b+1
C:\>echo 2>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 3>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 4>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 5>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 6>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 7>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 8>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 9>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 10 1>>1.txt
C:\>set /a b=b+1
C:\>echo end 1>>1.txt
I don't know where it's wrong
Please help, experts
Right now I have 1.bat and 2.bat
The contents of 1.bat are:
del 1.txt
set a=10
set b=1
call 2.bat
echo end>>1.txt
The contents of 2.bat are:
echo %%%a%%%>>1.txt
set /a a=a-1
if %a% GTR 0 call 2.bat
echo %%%b%%%>>1.txt
set /a b=b+1
Execution result:
%10%
%9%
%8%
%7%
%6%
%5%
%4%
%3%
%2%
%1%
%1%
%2%
%3%
%4%
%5%
%6%
%7%
%8%
%9%
%10%
end
If I change %%%a%%% in 2.bat to %a%, and %%%b%%% to %b%
the result becomes:
10
ECHO is on.
ECHO is on.
10
end
In the black command window:
C:\>del 1.txt
C:\>set a=10
C:\>set b=1
C:\>call 2.bat
C:\>echo 10 1>>1.txt
C:\>set /a a=a-1
C:\>if 9 GTR 0 call 2.bat
C:\>echo 9>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 8 GTR 0 call 2.bat
C:\>echo 8>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 7 GTR 0 call 2.bat
C:\>echo 7>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 6 GTR 0 call 2.bat
C:\>echo 6>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 5 GTR 0 call 2.bat
C:\>echo 5>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 4 GTR 0 call 2.bat
C:\>echo 4>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 3 GTR 0 call 2.bat
C:\>echo 3>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 2 GTR 0 call 2.bat
C:\>echo 2>>1.txt
ECHO is on.
C:\>set /a a=a-1
C:\>if 1 GTR 0 call 2.bat
C:\>echo 1>>1.txt
C:\>set /a a=a-1
C:\>if 0 GTR 0 call 2.bat
C:\>echo 1>>1.txt
C:\>set /a b=b+1
C:\>echo 2>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 3>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 4>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 5>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 6>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 7>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 8>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 9>>1.txt
ECHO is on.
C:\>set /a b=b+1
C:\>echo 10 1>>1.txt
C:\>set /a b=b+1
C:\>echo end 1>>1.txt
I don't know where it's wrong
Please help, experts

