I am trying to save the name of a file into a variable so that I can call it in another function node later. I have read that there is a flow variable that is available in the flow scope, which is what I need. I have been trying to test the examples in the Node-RED Documentation but I can't get them to work ( I am not a programmer, so I just test until it works). The other problem is that I have been using Python3 Function nodes so I would like to continue this way for the sake of simplicity.
Can anyone tell me how to just save the name of my file "10:23.txt" into a variable and how I can call it in a Python3 function later?
The point is that I am creating a file called "test.txt". The payload will be saved in this file and name of this file is gonna be replaced with a time stamp every 5 seconds. Then the file with the time stamp name will be uploaded to the cloud. The goal is to keep deleting the files as soon as they get uploaded to the cloud. That's why I need to pass their name, so that after it gets uploaded I can delete for example the "10:23.txt"
You will have to put that in a "normal" function node return {"payload":filename} and connect it to the python node and read the payload there, probably something like msg['payload']. As I don't work with python I have no idea how it works.
the flow and global context are only available within Node-RED - when you call out to python it has no concept of them. You can pass in the variable as part of the command line parameters (as if you typed on the command line) - or indeed (very ugly but you could) create a known file name and write to that - then have the python read that file and get the variable then proceed... You're better off with the former.
@xoani based on your other posts .... you can leave your python script writing to standard-out then rely on Node-Red to write the payload to a file for you.
Here's an example of what you might want to do:
Set msg.filename (using change node)
Run the command (using exec node)
Save the out put (using file node)
Set msg.payload to the filename (using change node) -- as required by Azure blob