Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Skip parts in Load Script

Hello together

is it possible to skip a part in a load script.

Ex: IF NOOFROWS('TEST') = 0 THEN "Skip this Sheet, or Skip this Code, or GoTo another part of Code?

This would be easier than:

IF NOOFROWS('TEST') > 0 THEN

     Here comes the Code

ENDIF;

Less Code and no nesting.

Any Idea how to?

Thanks in adv.

Ramon

1 Solution

Accepted Solutions
flipside
Specialist II
Specialist II

Hi Ramon,

Not sure if this is a solution, but would calling the code using INCLUDE statements help?  My idea is to break the code up into separate qvw documents which have their own -prj folders, so ScriptA.qvw code would be called by ScriptB.qvw ...

$(Include=ScriptA-prj\LoadScript.txt);

flipside

View solution in original post

6 Replies
Miguel_Angel_Baeyens

Hi Ramon,

If I got your question right, what you want is to prevent the execution of some part of your script depending on certain condition. Then the answer is that you must use the IF ... THEN ... END IF and all the code you want to execute (or prevent execution) in between. You can warp entire tabs, but take into account that the script, although you see it in tabs, is sequential and executed line by line and goes from the first line in the first tab at the left to the last line in the last tab on the left.

Tabs are only visual hints, the script (you will see it if you export it to a QVS file) is only one.

Feel free to create an idea to propose a new feature in the Ideas section.

Hope that makes sense.

Miguel

Not applicable
Author

Hi Miguel

Thanks for your reply.

Surely I'm familliar with the conditioinal functions like IF, SWITCH etc. but in big blocks of code you ever habe to indent. So in some cases the code will be to much nested to read. What I ment is a funcion like "Exit Script/Sub/For/Do".

In the same funcional way could be a function like "Exit IF/SWITCH".

For example:

CurrTable = 'TableName';

If Exists('DisplayName','$CurrTable)') then

     here comes the code (many lines and nests)

          ....

               ....    

                    ....

                         ....

                              ....

EndIf;

In the other case you could do it like:

If not Exists( ........) then Exit "CurrentSheet", or "Exit ....."

At the moment I solved the issue with Sub(), Exit Sub(), but it's a workarround ...

I know, it's more a nice to have issue, but if they had been a solution I had taken that. 🙂

PS: Sorry for my english 🙂

Greetings

Ramon

flipside
Specialist II
Specialist II

Hi Ramon,

Not sure if this is a solution, but would calling the code using INCLUDE statements help?  My idea is to break the code up into separate qvw documents which have their own -prj folders, so ScriptA.qvw code would be called by ScriptB.qvw ...

$(Include=ScriptA-prj\LoadScript.txt);

flipside

View solution in original post

Miguel_Angel_Baeyens

Hi Ramon,

Yes, there is a EXIT keyword to be used in the script. Check this example or this example to see how it works.

Hope that helps.

Miguel

Not applicable
Author

Hmm, got it, but with Exit Script (condition) you will kick out of the whole script, and that's not what I'm looking for. Only Jump over a passage of code.

But with the idea from flipside it work's. It's also a workarround, but to export some script in text, load it with $Include and overjump some $Included files.

That's ok for this case and the customer as well. So I can load all Files with "*.txt* and choose, which file should be loaded or should be skipped. So it's not necessary to jump into script.

If (condition) then

     $Include;

endif;

regular code ...

Thanks @Miguel and @flipside

Greetings from Switzerland

Ramon

lfg
Contributor
Contributor

Hi Ramon,

You can use a variable

For Example:

Let vLine = if(Condition,'','Exit Script');

$(vLine)

If condition is false $(vLine) will be replace with Exit Script and the Script will stop.

Greetings

Fernando