Use of .split to create an array of strings which is sent to

OctoPrint.control.sendGcode instead of a single string.
This allows multiple-line Gcode to be interpreted properly.
This commit is contained in:
James Leach 2019-02-13 10:57:21 -06:00
parent f00ea284cb
commit 5aa5400c2f
2 changed files with 5 additions and 5 deletions

View File

@ -58,7 +58,9 @@ $(function() {
if (macro.macro().match(paramObjRegex) == null) { if (macro.macro().match(paramObjRegex) == null) {
OctoPrint.control.sendGcode( OctoPrint.control.sendGcode(
macro.macro().replace(/(?:\r\n|\r|\n)/g, " ") // Use .split to create an array of strings which is sent to
// OctoPrint.control.sendGcode instead of a single string.
macro.macro().split(/\r\n|\r|\n/)
); );
} else { } else {
self.paramMacroViewModel.process(macro); self.paramMacroViewModel.process(macro);

View File

@ -60,11 +60,9 @@ $(function() {
i++; i++;
return self.parameters()[i]["value"]; return self.parameters()[i]["value"];
} }
// Use .split to create an array of strings which is sent to
// OctoPrint.control.sendGcode instead of a single string.
expanded = self.macro.replace(paramObjRegex, replaceParams) expanded = self.macro.replace(paramObjRegex, replaceParams)
// expanded = "[\"" + expanded + "\"]"
// expanded = expanded.replace(/(?:\r\n|\r|\n)/g, "\",\"");
// Split using RegEx - cleaner
expanded = expanded.split(/\r\n|\r|\n/); expanded = expanded.split(/\r\n|\r|\n/);
OctoPrint.control.sendGcode(expanded); OctoPrint.control.sendGcode(expanded);