Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Clear variable since the script

Hello,

I've many variables in my application and I want to clear them with a loop in the script. Can you help me?

Thanks you

4 Replies
sunny_talwar

In the script you can set the variables to null by doing vVar = Null();

I usually set the variables, which I am not going to use in the front end of the application, at very end tab of my script.

HTH

Best,

Sunny

hic
Former Employee
Former Employee

If you clear the variable in the end of the script using

     Let vVariable = Null() ;

or

     Set vVariable = ;

and delete the variable in Settings > Variable Overview, the variable will be automatically deleted at the end of the script every time.

HIC

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Maybe this proves to be an interesting technique for you:

  • At the start of your script, create an INLINE table with variable names, variable values and variable assignment types (LET or SET)
  • Next add a FOR loop that walks the table rows and performs a SET or LET for each variable (put this code in a SUB)
  • At the end of your script, add another FOR loop that does what has been suggested before, SET every variable in the table to NULL() or to ... nothing. (put this code in another SUB)

This only works for variables that were not defined in the Variable Overview. Those cannot be "uncreated" in the script.

With respect to your original question, I don't know about any other LOOP-solution as QV cannot know beforehand which variables you want to drop and which ones you want to keep.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If you want a very flexible configuration in your QV documents, you could store the variable definitions in an external file (e.g. Excel)

You'll have to be careful when loading these definitions because $-sign substitution wil try to play tricks with you all the time...