Implementing virtual Serial port communication: java with node-red (The Figures are attached in subsequent postings)

Using SPLIT to separate two parts of a message, so we can send only one part to a PLC

How can we use the Split function to separate the two parts of a message so that we can send only one part of the message to a PLC?

Our project has a total of 18 variables. Each variable must have a different value. My GUI must identify each variable, extract its corresponding value from the created GUI, and send it to a PLC. Here we share part of the code for 4 of the 18 variables.

if (msg.payload == 1)
{
    msg.payload = {opcuaCommand:"addVariable"}
    msg.topic = "ns=4;s=torque_peak;datatype=Double;value=4.04";
}
else if (msg.payload == 2)
{
    msg.payload = {opcuaCommand:"addVariable"}
    msg.topic = "ns=4;s=rValuePOT1;datatype=Double;value=1.01";
}
else if (msg.payload == 3)
{
    msg.payload = {opcuaCommand:"addVariable"}
    msg.topic = "ns=4;s=TQ1_ftlbs;datatype=Double;value=2.02";
}
else if (msg.payload == 4)
{
    msg.payload = {opcuaCommand:"addVariable"}
    msg.topic = "ns=4;s=KEB_torque_calc;datatype=Double;value=3.03";
}
else
{
    msg.payload={}
    msg.topic=""
}
return msg;

The GUI works in JAVA using Netbeans and we have created a String which we split with a &; the first word must identify the variable and the second give the value of the variable, example: variable1&value1. We have achieved this successfully and node-red reads it as it is sent using a virtual serial port.
This is the command used to send the message through the virtual serial port

String datainn=dataintxt.getText(); // datainn=50
serialtest.sendData("true"+"&"+datainn+"\n");

The problem we have now is being able to properly separate the String; the Split block perfectly divides my information into VARIABLE1 and its VALUE1 to be able to identify the variable on which we must act and give it its value. What we can't get is to get the function block sending the VALUE1 separately to the PLC.

When we execute the Split, the VARIABLE1 identifies the IF loop but it does not give us the value of VALUE1. We have even tried that the GUI send two separate messages: the first message to identify the variable and the second for its value, but it only takes the variable name and its value is left up in the air.

if (msg.payload == "true")
{
    msg.topic = "ns=4;s=TQ1_ftlbs;datatype=Double;value= "+msg.payload;
    msg.payload = {opcuaCommand:"addVariable"}
   
    return msg;
}    

ezgif.com-gif-maker-2

How can we use the Split function to separate the two parts of the message so that I can send only one part of the message to the PLC?