Following on from another thread @Huda has a Function node that works correctly but in the node-red editor it shows a yellow warning triangle which shows the error "Too many errors 70% scanned". Google suggested that this could be caused by warnings which were suppressed by the particular use case of the syntax checker. However I have fed this into an only jshint checker and it shows no problems. I thought I had seen this problem discussed here previously but I can't find it. Here is the function, it shows the warning at line 100. I am using node-red 1.2.2
//variables to be used to seperate morse words.
var word = '';
var morseText = [];
//For every letter in the received message
for (var letter=0; letter<msg.payload.length; letter++)
{
switch (msg.payload[letter])
{//if it is part of a word
case '.':
case '-':
case '>':
word = word + msg.payload[letter]; //Then add it to the variable word
break;
case '<': //if it is the end of word signal
morseText.push(word); //First, add the word to the morseText array.
morseText.push('<'); //Then, add the signal.
word = ""; //Finally, clear the word variable to start holding a new word.
break;
default:
break;
}
}
//variables to be used to transform morse words to english text.
var englishText = '';
var morseLetter = '';
//For every morse word saved in morseText array
for (var i =0; i<morseText.length; i++)
{
var morseWord = morseText[i];
//Loop through the morse signs in the word
for (var sign =0; sign<morseWord.length; sign++)
{
switch (morseWord[sign])
{
//if the sign is a dit or dah
case '.':
case '-':
morseLetter = morseLetter + morseWord[sign]; //then add it as part of a letter.
break;
//if the sign is signaling the end of a word
case '<':
englishText = englishText + ' '; //then add a space.
morseLetter = ''; //and clear the the letter variable to accept letters from the next word.
break;
//if the sign is signaling the end of the letter
case '>':
//then figure out what that letter is in English
switch (morseLetter)
{
case '.-':
englishText = englishText + 'a';
break;
case '-...':
englishText = englishText + 'b';
break;
case '-.-.':
englishText = englishText + 'c';
break;
case '-..':
englishText = englishText + 'd';
break;
case '.':
englishText = englishText + 'e';
break;
case '..-.':
englishText = englishText + 'f';
break;
case "--.":
englishText = englishText + "g";
break;
case '....':
englishText = englishText + 'h';
break;
case '..':
englishText = englishText + 'i';
break;
case '.---':
englishText = englishText + 'j';
break;
case '-.-':
englishText = englishText + 'k';
break;
case '.-..':
englishText = englishText + 'l';
break;
case '--':
englishText = englishText + 'm';
break;
case '-.':
englishText = englishText + 'n';
break;
case '---':
englishText = englishText + 'o';
break;
case '.--.':
englishText = englishText + 'p';
break;
case '--.-':
englishText = englishText + 'q';
break;
case '.-.':
englishText = englishText + 'r';
break;
case '...':
englishText = englishText + 's';
break;
case '-':
englishText = englishText + 't';
break;
case '..-':
englishText = englishText + 'u';
break;
case '...-':
englishText = englishText + 'v';
break;
case '.--':
englishText = englishText + 'w';
break;
case '-..-':
englishText = englishText + 'x';
break;
case '-.--':
englishText = englishText + 'y';
break;
case '--..':
englishText = englishText + 'z';
break;
default:
englishText = englishText;
break;
}
morseLetter = ''; //and clear the the letter variable to accept the next letter.
break;
default:
}
}
}
msg.payload = englishText;
return msg;