Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 展望未来?变量_Batch File_Variables_Lookahead - Fatal编程技术网

Batch file 展望未来?变量

Batch file 展望未来?变量,batch-file,variables,lookahead,Batch File,Variables,Lookahead,如何做到这一点 set newline=^& echo. set header=my header^%newline% %abc%^%newline%%def%^%newline%end 预期产出: my header some text some more text end my header hello there end 立即输出:(abc和def值不显示) 提前谢谢!感谢任何解决方案 更新: 我正在编写一个脚本,总结执行结果,并在输出的第一行显示它,例如 c:\>

如何做到这一点

set newline=^& echo. 
set header=my header^%newline% %abc%^%newline%%def%^%newline%end

预期产出:

my header
some text
some more text
end
my header
hello
there
end
立即输出:(abc和def值不显示)

提前谢谢!感谢任何解决方案

更新: 我正在编写一个脚本,总结执行结果,并在输出的第一行显示它,例如

c:\> myScript.bat
----------------------------------------
Execution failed with cmd1=UP, cmd2=DOWN
cmd2 failed
----------------------------------------

COMMAND: cmd1
[output of cmd1]

cmd1 result is "UP"

COMMAND: cmd2
[outout of cmd2]

cmd2 result is "DOWN"
试试这个


据我所知,这是无法实现的。是您遇到了问题(可能由解决),还是能够动态更改替换到
标题中的内容?(提示:展示你所得到的/描述它是如何错误的,以及展示你想要的/期望的)。如果是后者,我怀疑您必须将
set header=…
(可能还有一个
echo%header%
)放在
call:doheader
函数中,以便在
abc
def
更改时调用该函数。
my header
some text
some more text
end
my header
hello
there
end
my header


end
my header


end
c:\> myScript.bat
----------------------------------------
Execution failed with cmd1=UP, cmd2=DOWN
cmd2 failed
----------------------------------------

COMMAND: cmd1
[output of cmd1]

cmd1 result is "UP"

COMMAND: cmd2
[outout of cmd2]

cmd2 result is "DOWN"
@echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^


set NL=^^^%NLM%%NLM%^%NLM%%NLM%
:::::
set header=my header%NL% %abc%%NL%%def%%NL%end
setlocal EnableDelayedExpansion
(set \n=^
%=Do not remove this line=%
)

 set header=my header!\n! %abc%!\n!%def%!\n!end