Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello experts,
What is the best practice when it comes to whether or not to specify the loop variable name after the 'Loop' statement in the Do..Loop or after the 'Next' statement in the For..Next & For Each..Next loops. Are there scenarios that call for explicit inclusion or exclusion of the loop variable name at this position?
Thank you
In my experience it's in Qlik technically not necessary. I have a faint remembering of struggling with specifying variables by the next-statements in my first days but probably I made just stupid mistakes.
Nevertheless by using many (nested) loops over a lot of rows and/or even multiple script-tabs a specifying of the next-statements might be helpful to follow the script-stream. Personally I prefer to keep the script quite compact by using multiple layer + applications + tabs as well as outsourcing scripts in variables and routines and working with indentation and therefore I have no need for such measurements.
I think I may have figured out an answer to my question...which is Nested Loops. I am thinking they are a good example of when we need to specify the loop var names after the Loop & Next statements. Unless I am wrong somehow.
Even by nested loops it's not necessary to specify the iterator-variable by the next-statement - the parser relates to the belonging positions - for/next is like using brackets ().
I see, thank you Marcus...so does this mean specifying the iterator-variable by the next-statement is entirely optional?
In my experience it's in Qlik technically not necessary. I have a faint remembering of struggling with specifying variables by the next-statements in my first days but probably I made just stupid mistakes.
Nevertheless by using many (nested) loops over a lot of rows and/or even multiple script-tabs a specifying of the next-statements might be helpful to follow the script-stream. Personally I prefer to keep the script quite compact by using multiple layer + applications + tabs as well as outsourcing scripts in variables and routines and working with indentation and therefore I have no need for such measurements.
Ok, I see. Thank you for taking time to explain & put things into perspective. I have a better understanding now.