IMacros: SyntaxError: missing ; before statement
IMacros: SyntaxError: missing ; before statement
当我将代码从 IIM 更改为 JS 时遇到问题我遇到此消息 "SyntaxError: missing ; before statement, line 5 (Error code: -991)"
原始代码运行完美
SET !DATASOURCE Pack_01.txt
SET !DATASOURCE_LINE 1
SET !VAR1 EVAL("var s=\"{{!COL1}}\"; s.split(\"@\")[1];")
PROMPT ID:{{!VAR1}}
但是 js 代码不适用于我的
var macro;
macro = "CODE:";
macro += "SET !DATASOURCE Pack_01.txt" + "\n";
macro += "SET !DATASOURCE_LINE 1" + "\n";
macro += "SET !VAR1 EVAL(\"var s=\"{{!COL1}}\"; s.split(\"@\")[1];")" + "\n";
macro += "PROMPT ID:{{!VAR1}}" + "\n";
iimPlay(macro);
请你帮忙!!
语法不正确,因为您的字符串包含双引号。您需要转义它们,将 " 替换为 \".
var macro;
macro = "CODE:";
macro += "SET !DATASOURCE Pack_01.txt" + "\n";
macro += "SET !DATASOURCE_LINE 1" + "\n";
macro += "SET !VAR1 EVAL(\"var s=\\"{{!COL1}}\\"; s.split(\\"@\\")[1];\")" + "\n";
macro += "PROMPT ID:{{!VAR1}}" + "\n";
iimPlay(macro);
另一种选择是使用模板文字:
var macro = `CODE:SET !DATASOURCE Pack_01.txt
SET !DATASOURCE_LINE 1
SET !VAR1 EVAL("var s=\"{{!COL1}}\"; s.split(\"@\")[1];")
PROMPT ID:{{!VAR1}}
`;
iimPlay(macro);
当我将代码从 IIM 更改为 JS 时遇到问题我遇到此消息 "SyntaxError: missing ; before statement, line 5 (Error code: -991)"
原始代码运行完美
SET !DATASOURCE Pack_01.txt
SET !DATASOURCE_LINE 1
SET !VAR1 EVAL("var s=\"{{!COL1}}\"; s.split(\"@\")[1];")
PROMPT ID:{{!VAR1}}
但是 js 代码不适用于我的
var macro;
macro = "CODE:";
macro += "SET !DATASOURCE Pack_01.txt" + "\n";
macro += "SET !DATASOURCE_LINE 1" + "\n";
macro += "SET !VAR1 EVAL(\"var s=\"{{!COL1}}\"; s.split(\"@\")[1];")" + "\n";
macro += "PROMPT ID:{{!VAR1}}" + "\n";
iimPlay(macro);
请你帮忙!!
语法不正确,因为您的字符串包含双引号。您需要转义它们,将 " 替换为 \".
var macro;
macro = "CODE:";
macro += "SET !DATASOURCE Pack_01.txt" + "\n";
macro += "SET !DATASOURCE_LINE 1" + "\n";
macro += "SET !VAR1 EVAL(\"var s=\\"{{!COL1}}\\"; s.split(\\"@\\")[1];\")" + "\n";
macro += "PROMPT ID:{{!VAR1}}" + "\n";
iimPlay(macro);
另一种选择是使用模板文字:
var macro = `CODE:SET !DATASOURCE Pack_01.txt
SET !DATASOURCE_LINE 1
SET !VAR1 EVAL("var s=\"{{!COL1}}\"; s.split(\"@\")[1];")
PROMPT ID:{{!VAR1}}
`;
iimPlay(macro);