Nested Loop Control
Run a nested FOR loop every scan in this rungs.dev Add-On Instruction and report the total inner-loop iteration count — 1001 when fully enabled.
intermediate
Parameters
| Name | Type | Usage | Description |
|---|
| In_Enable | BOOL | Input | 1 enables the loop execution logic. |
| Out_TotalIterations | DINT | Output | The total number of inner loop iterations completed in the current scan. |
Behavior
- On every scan, if In_Enable is 1, execute a nested FOR loop.
- The outer loop index 'i' ranges from 0 to 10.
- The inner loop index 'j' ranges from 10 to 100.
- An internal accumulator Count increments by 1 for every execution of the inner loop body.
- Out_TotalIterations is updated to the value of Count after the completion of the loops.
- If In_Enable is 0, Out_TotalIterations remains at 0.
- When enabled, the nested loops complete in the same scan and produce Out_TotalIterations = 1001.
Ready to start?
Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.