Hello I am trying to use the function node to modify a message from the TCP in node. I am trying to interface with a controller propitary interface. I have yet only managed to send a single value to the controller. Thats done by replying "?100=16" to the message "?100" where 16 is the value.
20:33:36.265: Tx: ?100
20:33:36.312: Rx: ?100=16
When trying to send and recieve more than one value I don't have the skills to read the message in the function node and pass the correct reply. For instance I want to assign 100 in the "!14,7,100" to a variable and reply ?14=100 to confirm to the controller that the value is recieved, wrapped up like the Rx line below:
To try and get to the crux of what you are trying to do, is it right that you have a value in a variable (which might be 100) and you want to build the string "!14,7," followed by the value of that variable? If so then you can just do answer = "!14,7," + theVariable
The fact that the first expression on the right hand side is a string will tell javascript to convert theVariable to a string and concatenate it with the first part.
Thanks I ended up using the slice function to slice out the parts with ! and ? in front and then used a split node to split it further down and then used the msg.parts.index to read out the different values. This page described everything I had to do with javascript glad I found it.