question

jojogomez avatar image
jojogomez asked

Error 2304 / Cannot find name 'startElement'.(2304)

Hi,

I moved my node red from the GX to an Rasperrypi and now one Function had some trouble. for serveral Commends I got the Error 2304.

I got the error for: STartElement, StopElement and outputText

Here my script:


function isNumber(value) {

return typeof value === 'number';

}

var days = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];

node.warn("i started")

if(!isNumber(msg.payload)){

node.warn("check pass")

startElement = null;

endElement = null;

outputText = "";

console.log(msg.payload.hours)

msg.payload.hours.forEach((element, idx) => {

if (element.onOff == true && startElement == null){

//console.log("i start here")

startElement = element

} else if (startElement != null && element.onOff == false){

//console.log("i stop here")

endElement = element

} else if (endElement == null && idx === msg.payload.hours.length - 1){

//console.log("i stop here bcs end of list")

endElement = element

}

if (startElement != null && endElement != null){

startDate = new Date(startElement.start)

endDate = new Date(endElement.start)

endDate.setHours(endDate.getHours() - 1)

endDate.setMinutes(59)

startHours = ("0" + startDate.getHours()).slice(-2);

startMinutes = ("0" + startDate.getMinutes()).slice(-2);

endHours = ("0" + endDate.getHours()).slice(-2);

endMinutes = ("0" + endDate.getMinutes()).slice(-2);


outputText += days[startDate.getDay()] + " von <br>" + startHours + ":" + startMinutes + " bis " + endHours + ":" + endMinutes + "<br>"

startElement = null

endElement = null

}

if(idx === msg.payload.hours.length - 1){

//console.log("i'm at the end, lets output")

//console.log(outputText)

msg.payload = outputText


}

});

return msg;

}


Anybody an idea what I need to do here?


Regards Thomas

error
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

0 Answers

Related Resources

Additional resources still need to be added for this topic