批处理文件:未能回声变量中环 [英] Batch File: Fails to Echo Variable Inside Loop

查看:104
本文介绍了批处理文件:未能回声变量中环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经跌到了谷底,我似乎无法得到这个工作!

  SETLOCAL EnableDelayedExpansion在(1,2,3)%% g执行(
集/ A C = %% G + 32
回声%C%
)暂停

但它说,ECHO是的,我知道这意味着它没有任何显示,但怎么会不是有什么显示?我试图改变很多事情(添加/删除例如SETLOCAL),但它不会起作用。

任何帮助是极大AP preciated!


解决方案

 在%%克(1,2,3)做(
  集/ A C = %% G + 32
  回音!c请!

设置/?撰文指出,我们应该使用这种情况。

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!

解决方案

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

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

这篇关于批处理文件:未能回声变量中环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆