Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

what is include statement ? what is use of include statement.

Hi friends

what is include statement ? what is use of include statement.

can anyone  explain the include statement . what time it will use.

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

You can add a piece of code or variable definition in a file and then use the content of the file into the script:

$(Include=..\_Common Code\Source\Variables Main.txt);

martinpohl
Partner - Master
Partner - Master

with an include you can add a script from a flie (txt or qvs) that will executed by reload the script.

It can be used by central script part eg. set colour definition or formula definition in variables or load statements which are often use in load scripts.

Regards

Peter_Cammaert
Partner - Champion III
Partner - Champion III

There are a few very interesting use cases for $(Include). These immediately come to mind:

  • Externalize Script Code - In large projects where you may work with multiple developers, editing a script in the QVW using the script editor is not the best way to coordinate efforts. As soon as projects get bigger, and on condition that their script files don't require the security that a QVW document offers, you better start to externalize script code. Makes code management a lot easier. In documents that we create for enterprise customers, the QVW load script is often reduced to a few SET/LET statements and one or more $(Include) constructs.

  • Code reuse - typical and very simple example is an OLEDB CONNECT statement with username and password. Imagine that you need the same connect string in 20+ documents. And then the password changes? You can reduce 20+ edits to a single one if your connect string is stored in a central script file that is included in these documents.

  • Code libraries - after a while, every developer has a collection of handy pieces of code. You could copy and past'em wherever there's a need, but a better solution (see also my previous example) would be to turn them into SUBs and store them in a single external script file. Then $(Include) that library file into every project. Don't worry about too many unused definitions, the fact that you can just CALL the ones you need means big savings in time and effort.

  • Change code parts - depending on the environment where your document is reloaded, you can change a piece of code into something entirely different - without making a single modification to your document's load script. Store the code in a script file, and put different versions of this file on different platforms (e.g. DEV vs PROD). Or replace a production version of a script file with a development version for testing purposes. Very handy.

  • Omit unwanted/irrelevant code - in certain environments, a specific piece of code may be unwanted. A simple example is the use of Section Access. Undesirable in Development, an absolute necessity in Production. Put the code in a script file, and add an $(Include) construct in your load script. Put the good script file in your Production environment, but place no or an empty script file in Development. The $(Include) construct will not complain about missing script files.

There are other use cases, I'm sure. And YMMV.

Best,

Peter