How can i use the value of a variable i created inside the template node

I am new to node red and i created a variable inside the template node and i want to use its content in another node how can i do that?
thank you in advance

I am not sure what you mean by creating a variable inside a template node, but the usual method for getting data from one node to another is to pass it in a message.

event inside a ui dashboard template node?

I assumed you meant a normal template node rather than ui-template. The ui_template code runs in the browser, not the server, so again the only way to get it back to the server is to send it back via a message.

No i mean the ui template node when i set a msg.variable it returns message undefined

[
    {
        "id": "6459ddaad53aced2",
        "type": "ui_template",
        "z": "c4c2c6195e5e2f0a",
        "g": "91c080c74028ae64",
        "group": "ba4cd6c4f1b1c4ad",
        "name": "",
        "order": 5,
        "width": 0,
        "height": 0,
        "format": " <!DOCTYPE html>\n\n<html>\n<head>\n  <title>Read File</title>\n</head>\n\n<body>\n<!-- <input type=\"file\" webkitdirectory directory multiple id=\"myFile\">\n  <button type=\"submit\" onclick=\"uploadfile()\">\n        Click to send the files\n    </button>-->\n        <input type=\"file\" id=\"myFile\" webkitdirectory directory multiple onchange=\"uploadfile()\">\n    <br><br><br>\n    <md-button ng-click=\"send({input:action()})\">\n        Click to send the files\n    </md-button>\n  <hr>\n  <textarea style=\"width:500px;height: 400px\" id=\"output\"></textarea>\n\n  <script>\n \n function uploadfile(){\n        var output = document.getElementById(\"output\");\n        let files = document.querySelector('input[type=file]').files;\n        var listsize = files.length;\n        console.log(files);\n        var chunk_size = 2000;\n        var contentarray = [];\n        //var offset = 0;\n        \n        \n        var fullsize = 0;\n        var c = 0 ;\n        while(c < listsize){\n            fullsize += files[c].size;\n            c += 1;\n        }\n        var comp = 0;\n        while(comp < listsize){\n            \n         //   console.log(files[comp]);\n         var offset = 0;\n        if (files[comp].size > 0) {\n            \n        var myFile = files[comp];\n        var size = myFile.size; //getting the file size so that we can use it for loop statement\n        var i=0;\n        console.log(\"file size \",size);\n        while( i<size){\n        var reader = new FileReader();\n        var blob = myFile.slice(offset, offset + chunk_size); //slice the file by specifying the index(chunk size)\n        var s = 0;\n        //console.log(blob);\n        reader.addEventListener('load', function (e) {\n          \n               res += btoa(e.target.result);//concatenate the output on each iteration.\n               s += e.loaded;\n              // console.log(\"s======\",s);\n              // console.log(\"////////////////////////////////////////////////\",fullsize - s == fullsize - myFile.size);\n            if (s % 2000 != 0){\n               // console.log(\"hi\");\n              //  console.log(s);\n                res += btoa(e.target.result);\n                contentarray.push(res);\n                s = 0;\n                res = '';\n                //console.log(contentarray);\n           }\n            \n           \n     //   console.log(offset);\n           \n        //   console.log(res);\n        });\n        reader.readAsBinaryString(blob);\n        offset += chunk_size; // Increment the index position(chunk) \n        i += chunk_size;\n     // Keeping track of when to exit, by incrementing till we reach file size(end of file).\n        }\n       \n      }\n      // res = res.replace('undefined','');\n        reader.addEventListener('loadend',function (e) {\n           //res = res.replace('undefined','');\n          console.log(contentarray);\n        });\n         console.log(\"*****************************************************************\",comp);\n        comp ++;\n        var res='';\n       \n        }\n    // msg.content = contentarray;\n }\n\n\n  </script>\n</body>\n</html>\n  \n",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 300,
        "y": 300,
        "wires": [
            [
                "ae07764595b20bdf"
            ]
        ]
    },
    {
        "id": "ba4cd6c4f1b1c4ad",
        "type": "ui_group",
        "name": "Default",
        "tab": "8e403f6af717befd",
        "order": 1,
        "disp": true,
        "width": 20,
        "collapse": false,
        "className": ""
    },
    {
        "id": "8e403f6af717befd",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

here is my code if it helps, i want to return the value of the content array to the next node

You can't send messages from the browser code like that, as the code is running in the browser environment, not in the node-red server.

This might be helpful

Thank you so much for the help

Could you describe what you are trying to achieve? I suspect that there may be much easier ways, it is easy as a beginner to go off down the wrong path because you do not know what can be done.

I am reading a list of files from an input the files are of big sizes that's why am splitting them and then i have to encode them and send them one by one to a http request that has an encoded file as a body

Why are you doing any of that inside a ui_template node?

because i need an input

What sort of input?

input file to choose the files

Do you mean the user enters a file name?

yes to choose a file from your local device

Please give more information, it is hard work trying to understand. What do you want to show on the dashboard and what does the user do? Select from a dropdown list for example?

choose a file or multiple files from the device they are .jt files then encode its content to b64 and then send it to the body of a http request

Where are the files? On the node-red server or on the machine running the browser?

my machine which is running the node red browser