本帖最后由 CrLf 于 2014-11-25 23:01 编辑
再来一种通用的:- @echo off
- setlocal EnableDelayedExpansion
- setlocal ENABLEEXTENSIONS
- setlocal
- set /a m=0
- set /a n=5
- call :EchoN
- set n=%errorlevel%
- echo !m!
- echo !n!
- endlocal
- exit /b
- @echo on
-
- :EchoN
- setlocal
- set /a n=2
- for /l %%a in (1,1,5) do (
- set /a n=!n!*2
- )
- set /a m=!n!
- for /f "delims=" %%a in ("m=!m!") do endlocal&set "%%a"
- exit /b
复制代码
|