做批处理文件支持多行变量 [英] Do Batch files support multiline variables
本文介绍了做批处理文件支持多行变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果又如何?
是的,批处理文件是瘸腿的,但我不能使用PowerShell的,我不喜欢写一个真正的应用程序做这个简单的任务....
修改
我要的是沿
行财产以后 组VAR =这是一个
多
线
字符串
解决方案
也可以创建一个真实的换行符。
SETLOCAL enableDelayedExpansion
设置NL = ^
REM需要两个空行
呼应第一行!NL!第二行
设置多1号线=!NL!2号线
设置多=!多!NL!3号线
回音!多!
通过这种变异的新行是一个正常的角色在字符串中,因此变量通常采取行动,你可以将它们分配给另一个变量,这是不可能的&放大器;回声
绝招(这简单的任务是非常有用的)。
If so How?
Yes, batch files are lame, but I cannot use powershell, and I don't feel like writing a real app to do this simple task....
edit
What i want is somthing along the lines of
set var="this is a
multi
line
string "
解决方案
Or you can create a "real" newline character.
setlocal enableDelayedExpansion
set NL=^
rem two empty line required
echo first line !NL! second line
set multi=Line1!NL!Line2
set multi=!multi!!NL!Line3
echo !Multi!
With this variant the newline is a "normal" character in the string, so the variables act normally and you can assign them to another variable, this is not possible with the &echo.
trick (which is useful for simple tasks).
这篇关于做批处理文件支持多行变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文