Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Loop Action - Nested Loops (https://www.kinook.com/Forum/showthread.php?t=4873)

joe12 06-02-2011 01:03 PM

Loop Action - Nested Loops
 
It says in the Help: A Loop action cannot be nested within another Loop action.

I have a Loop Action that iterates over an ADO record set and calls a subroutine within the loop block. In that subroutine I have another Loop Action which also loops over another ADO record set.
Nesting seems to work ok using the subroutine mechanism of nested loops.


Why does it work using the subroutine but the help says nesting is not allowed?

What is the best way to handle nesting of loop actions and why are there restrictions on nesting of loops?

kinook 06-02-2011 03:08 PM

I'm surprised that works, and I don't think it does for most types of loops. The limitation has to do with how looping is handled internally, and removing the limitation is on the todo list.

Other options for now are for one of the loops, to store the results in a macro and use a repeating build rule to iterate.
http://www.kinook.com/VisBuildPro/Ma...scriptloop.htm

Or put the inner loop in another .bld file and call it with the VisBuildPro Project action.
http://www.kinook.com/VisBuildPro/Ma...projaction.htm

joe12 06-02-2011 06:59 PM

So I changed out the Loop Action steps to just loop over a Run Script action where I use the vbld_AddDelimValue or vbld_PushDelimValue call to capture all the values I will need to loop over.

Then I use a Group step to do the looping, by using the "Repeat step..." checkbox and place my temporary macro as the condition that must be "is defined". Inside the Group step I use another Run Script action and use vbld_PopDelimValue to get one of the items to be looped over.

Doing it this way, the Loop Action step is never nested inside another Loop Action, but it does get nested inside a "repeating mode" Group step.

Note that these "repeating mode" Group steps are now being used as loops, and are nested.


I tried that and it does seem to work, is that the best way to do this?

Also, I think my implementation might not be as clean as it could be. Is the nesting of Group steps which are set to "Repeat..." with the use of the vbld_PushDelimValue and vbld_PopDelimValue calls shown in any of the example projects?

kinook 06-03-2011 11:27 AM

1 Attachment(s)
That sounds about right. I have attached a sample that demonstrates this.

kinook 02-24-2012 08:25 AM

This is supported in v8.0.


All times are GMT -5. The time now is 06:16 PM.


Copyright © 1999-2023 Kinook Software, Inc.