1 Ucode implements C-style while loops which run as long as the condition 2 is fulfilled. 3 4 Like with for-loops, an alternative syntax form suitable for template 5 blocks is supported. 6 7 8 -- Expect stdout -- 9 A simple counting while-loop: 10 Iteration 0 11 Iteration 1 12 Iteration 2 13 Iteration 3 14 Iteration 4 15 Iteration 5 16 Iteration 6 17 Iteration 7 18 Iteration 8 19 Iteration 9 20 21 If the loop body consists of only one statement, the curly braces 22 may be omitted: 23 Iteration 0 24 Iteration 1 25 Iteration 2 26 Iteration 3 27 Iteration 4 28 Iteration 5 29 Iteration 6 30 Iteration 7 31 Iteration 8 32 Iteration 9 33 34 A counting while-loop using the alternative syntax: 35 Iteration 0 36 Iteration 1 37 Iteration 2 38 Iteration 3 39 Iteration 4 40 Iteration 5 41 Iteration 6 42 Iteration 7 43 Iteration 8 44 Iteration 9 45 -- End -- 46 47 -- Testcase -- 48 A simple counting while-loop: 49 {% 50 i = 0; 51 while (i < 10) { 52 print("Iteration "); 53 print(i); 54 print("\n"); 55 i++; 56 } 57 %} 58 59 If the loop body consists of only one statement, the curly braces 60 may be omitted: 61 {% 62 i = 0; 63 while (i < 10) 64 print("Iteration ", i++, "\n"); 65 %} 66 67 A counting while-loop using the alternative syntax: 68 {% while (x < 10): -%} 69 Iteration {{ "" + x++ }} 70 {% endwhile %} 71 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt