Batch File: Fails to Echo Variable Inside Loop

孤街醉人 提交于 2020-01-03 17:43:33

问题


I've hit rock bottom, I can't seem to get this work!

setlocal EnableDelayedExpansion

for %%g in (1,2,3) do (
set /a c=%%g+32
echo %c%
)

pause

But it says ECHO is on, I know this means that it has nothing to display, but how couldn't it have something to display? I tried changing many things (adding/removing setlocal for example) but it won't work.

Any help is GREATLY appreciated!


回答1:


for %%g in (1,2,3) do (
  set /a c=%%g+32
  echo !c!
)

In set /? written that we should use ! for this situation.



来源:https://stackoverflow.com/questions/11571926/batch-file-fails-to-echo-variable-inside-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!