Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Must_Include in FOR-EACH, and my SUBs are broken

Hello there,

I have a little "helper library" for my dashboards which is just a .qvs file, and now I want to split this file into modules so multiple colleagues could work on different topics at the same time. When I had my library as a single file, I just included it into my dashboard by using Must_Include and I was fine.

Now, with "modules" (which are also plain .qvs files), I made two solutions, but the nice one does not work.

My first solution is to have the library as a little script which is just a list of Must_include statements to include the single modules. This works well, I have all my variables, SUBs can be called from the dashboard, and code works, too. But of course it is a pity if all the modules are hard-coded in my loader library.

My second solution is to have the library as a little script again which loads the modules, but I use a FOR-EACH loop to take every file with "module" in its name that exists in a given file folder. This is more flexible when adding or removing modules.

This second solution provides me with the variables that I define there and also executes the code that is directly put in a module. But I also put some SUBs in each module, so I can call them later when I need them in my dashboard's script. I am not able to call the SUBs anymore, neither from the library nor from the dashboard script (which basically loads the library).

Have you experienced anything like this before? I know that Must_Include is a little "special" (it is also executed when it is put after a bunch of "EXIT SCRIPT"s and so on). But I hope to find a way to get the modules loaded with FOR EACH and still keep my SUBs available.

All the best,


1 Reply
Not applicable

Re: Must_Include in FOR-EACH, and my SUBs are broken

After playing around with this, I come to the conclusion that Must_Include seems to be a plain text replacement. That means, in a FOR-EACH-NEXT loop the text of the included file would be put within the loop and therefore may be forgotten outside the loop.

My expectation would be something like "import java.io.*;" in Java does. But when Must_Include is a plain text replacement, such a "module import" must be done differently.