好的,我有一个变量,用于设置语句%nl%
以创建多行
声明,在多行语句中是变量%resultA%
我希望整个语句(包含其中的变量)在另一个变量中。
例如〜 我想要
set nl=^& echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º Player (Caesar) º%nl%º ^| º%nl%º Health ^| ÉÍÍÍÍÍÍÍ» º%nl%º ^| º%resultA%º º%nl%º ^| ÈÍÍÍÍÍÍͼ º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
看起来像
set nl=^& echo.
set MyVar="echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º Player (Caesar) º%nl%º ^| º%nl%º Health ^| ÉÍÍÍÍÍÍÍ» º%nl%º ^| º%resultA%º º%nl%º ^| ÈÍÍÍÍÍÍͼ º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%"
每当我在批处理文件中回调变量时,我都会收到错误
说明ECHO IS OFF
,当然我已经知道了这一点,但我试图将多行替换为一个变量(其中包含另一个变量),而echo则关闭...
尝试到处寻找无济于事。有线索吗?
答案 0 :(得分:3)
// Template file
#include <dir/Test1.h>
#include <dir/Test2.h>
#include <dir/Test3.h>
void function();
library(data.table)
date <- as.POSIXct('2015-01-01 14:30:00')
# appointments data table
app <- data.table(med.id = 1:10,
filial.id = rep(c(100,200), each = 5),
start.time = rep(seq(date, length.out = 5, by = "hours"),2),
end.time = rep(seq(date+3599, length.out = 5, by = "hours"),2),
A = rnorm(10))
# receptions data table
re <- data.table(med.id = c(1,11,3,4,15,6,7),
filial.id = c(rep(100, 5), 200,200),
start.time = as.POSIXct(paste(rep('2015-01-01 ',7), c('14:25:00', '14:25:00','16:32:00', '17:25:00', '16:10:00', '15:35:00','15:50:00'))),
end.time = as.POSIXct(paste(rep('2015-01-01 ',7), c('15:25:00', '15:20:00','17:36:00', '18:40:00', '16:10:00', '15:49:00','16:12:00'))),
B = rnorm(7))
app$count <- 0
for (i in 1:dim(app)[1]){
for (j in 1:dim(re)[1]){
if ((app$med.id[i] == re$med.id[j]) & # med.id is equal and
app$filial.id[i] == re$filial.id[j]) { # filial.id is equal
if ((re$start.time[j] < app$start.time[i]) & (re$end.time[j] > app$start.time[i])) { # reception starts before appointment start time and ends after appointment start time OR
app$count[i] <- app$count[i] + 1
} else if ((re$start.time[j] < app$end.time[i]) & (re$start.time[j] > app$start.time[i])) { # reception starts before appointment end time and after app. start time
app$count[i] <- app$count[i] + 1
}
}
}
}
后的所有内容都会立即进入包含=
的变量。
而是在变量之前移动开头引号:
set var=
答案 1 :(得分:2)
问题在于set nl=^&echo.
没有创建新的线条字符,而是将回声分成多个部分并独立回显每个部分,但它根本不是很稳定。
最好使用一个真正的新行字符
setlocal EnableDelayedExpansion
(set nl=^
%=DONT_CHANGE_THIS_LINE=%
)
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»!NL!º Player (Caesar) º!nl!º ^| º!nl!º Health ^| ÉÍÍÍÍÍÍÍ» º!nl!º ^| º%resultA%º º!nl!º ^| ÈÍÍÍÍÍÍͼ º!nl!ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ!nl!
此换行符只能用于延迟扩展!