Hello there , I am new to Node-red and I`d like to know how do I can parse text from a file and display it on my dashboard ... My dashboard is ready and working but idk how to parse the "Menu1" word from my txt file ... the first node that opens the file works (the entire content of the file appears in the debug) but still cant parse a word in ...
Here is the code in my parsing node ;
if (!context.count){
context.count = 20;
}
parsed = parseInt(msg.payload);
if(parsed==1){
context.count++;
}
msg.payload = context.count;
return msg;
and here is the debug tab :
03/04/2019 à 11:02:45node: 9fb6b5f3.404608
msg.payload : string[29]
"Menu1 \t fasfdfds \t fghsd \t"
03/04/2019 à 11:02:45node: 40c35d07.249254
msg.payload.variable_1 : undefined
undefined
as you can see , it can read in the file but dont recognise the word "Menu1" in it..
Thanks for help and spending your time reading this
here is the parsing flow :
[{"id":"9aed556e.760008","type":"tab","label":"parse","disabled":false,"info":""},{"id":"b2db9145.f5b1","type":"inject","z":"9aed556e.760008","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":420,"y":80,"wires":[["a3ab124e.5f21a"]]},{"id":"a3ab124e.5f21a","type":"file in","z":"9aed556e.760008","name":"access to file","filename":"/home/pi/Desktop/sms/messages","format":"utf8","chunk":false,"sendError":true,"encoding":"utf8","x":170,"y":180,"wires":[["9fb6b5f3.404608","a8c43f28.32aed"]]},{"id":"881d70a9.606ec","type":"function","z":"9aed556e.760008","name":"recherche du mot Menu1","func":"if (!context.count){\n context.count = 20;\n}\nparsed = parseInt(msg.payload);\nif(parsed==1){\n context.count++;\n }\n\nmsg.payload = context.count;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":160,"wires":[]},{"id":"40c35d07.249254","type":"debug","z":"9aed556e.760008","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.variable_1","targetType":"msg","x":450,"y":360,"wires":},{"id":"9fb6b5f3.404608","type":"debug","z":"9aed556e.760008","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":370,"y":40,"wires":},{"id":"a8c43f28.32aed","type":"function","z":"9aed556e.760008","name":"parsing "Menu1"","func":"if (!context.count){\n context.count = 20;\n}\nparsed = parseInt(msg.payload);\nif(parsed==1){\n context.count++;\n }\n\nmsg.payload = context.count;\nreturn msg;\n","outputs":1,"noerr":0,"x":330,"y":260,"wires":[["40c35d07.249254"]]}]