Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Delete variables in loading scripts

Hi all,

Is there a way to do the same thing than the following macro by the very beginning of the loading script?

 

Sub cleanVariables
     Set VariableCollection = ActiveDocument.GetVariableDescriptions
     For i = 0 to VariableCollection.Count - 1
          Set tempVar = VariableCollection.Item(i)
          tempVarName = tempVar.Name
     ActiveDocument.RemoveVariable tempVarName
     Next
End sub

The idea is to flush the application from every variable when the reload button is engaged.

Thanks in advance.

Tags (3)
8 Replies
Not applicable

Re: Delete variables in loading scripts

VarName =;

or

VarName = null();

Regards,

Ricardo

Not applicable

Re: Delete variables in loading scripts

Hi Ricardo,

this will flush a known variable, but will not do the same thing than the macro.

The macro is looking for any existing variable in the document then remove it.

dimitri_obrant
Contributor

Re: Delete variables in loading scripts

Hi,

I use the commands above to delete the temp variables in loading script (QV 11.0 SR2). The values of the variables will be deleted, but the empty variables stay in the Variable Overview.

This is a datamart and the variables will be not used in frontend.

How can I delete the variables in Variable Overview with loading script?

Thanks

MVP
MVP

Re: Delete variables in loading scripts

Hi

If the following conditions are met, the variable will not persist into the front end:

  • The variable does not exist before the reload (in other words it is created by the load script)
  • The variable is set to null before the load script is terminated (eg Set vVar=; )

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
dimitri_obrant
Contributor

Re: Delete variables in loading scripts

ok, if the script runs some times variables exist already. This sentence was helpfull:

"The variable does not exist before the reload (in other words it is created by the load script)"

Thanks

bimartingo
New Contributor

Re: Delete variables in loading scripts

In any case, you need to (eg)  set vVar=;

this leads me to another possible situation: suppose you create the variable declaring it on the script but forget to assign the empty value and after loading and using the frontend, you save the document, storing the variable into it. In this case, I think, whether you insert the [ set vVar=; ] statement in the script, you ought to delete it from the document using the Document Property window.

Not applicable

Re: Delete variables in loading scripts

You are correct Martin. You created variable in the script and refresh the app. So you can see the the variable on the Variable window (Ctrl+Alt+v). If you delete the variable from application, you need to assign null or nothing in the script. If the variables already on UI, you shouldd have to delete from UI as well.

stantrolav
Contributor II

Re: Delete variables in loading scripts

Here is my script that dont creates variables in Application after script ends. Try it in your case.

Now = Now();

ReloadTime = ReloadTime();

DocumentPath = DocumentPath();

DocumentTitle = DocumentTitle();

LOAD * INLINE [

    AppPath, AppReloadTime, AppDocumentPath, AppDocumentName

    $(QvWorkPath), $(Now), $(ReloadTime), $(DocumentPath), $(DocumentTitle)];

Now = Null();

ReloadTime = Null();

DocumentPath = Null();

DocumentTitle = Null();

Community Browser