0

我正在编辑给我的批处理文件,但我不确定以下代码行的作用:

设置 allKeys=%allKeys% !currentKey!

谢谢!

4

3 回答 3

0

It appends the run-time value of the variable currentkey after a space to the parse-time value of allkeys and assigns the result as the run-time value of allkeys - provided delayedexpansion is invoked. If delayedexpansion is not invoked, it appends the string !currentKey!, not the value of the variable currentkey.

Without any context information, we're guessing beyond that...

于 2013-06-13T15:00:42.597 回答
0

这是一个尝试的代码示例。

allkeys 设置在 for in do 循环之外。

在 for in do 循环中,它发生了变化,但由于它使用 %allkeys% ,因此变化不是累积的。

@echo off
setlocal enabledelayedexpansion
set allkeys=one
for %%a in (two three four five six) do (
set currentkey=%%a
set allKeys=%allKeys% !currentKey!
echo allkeys is now "!allkeys!"
)
echo allkeys is now "%allkeys%" outside the loop
pause

将此行更改 set allKeys=%allKeys% !currentKey! 为此并运行它以查看差异。

set allKeys=!allKeys! !currentKey!
于 2013-06-13T15:22:25.490 回答
0

有关什么是延迟扩展说明,请键入SET /?.

于 2013-08-27T11:47:14.480 回答