How to retrieve a list of used/set variables in a (running) flow

Discussion created by P_Jansen_8916 on Mar 23, 2017
Latest reply on Mar 28, 2017 by P_Jansen_8916
Is there a way to retrieve all used/set variables in a workflow.
I want to write all the used variables into an external file with the format <Var_name>:<Var_Value>
:PSET &VAR1 = "Var one"
:PSET &VAR2 = "Var two" 
:PSET etc ...

Before writing I do not know which vars are all set.
Sometime I have &VAR1# .. &VAR4# and an other time I have &VAR2# .. &VAR8#

So the question is not how to write them to a file, but the question is how to determine which vars are used/set.  

Thanks in advance