Forum > Beginners

Free conditions manipulating loops [SOLVED]

(1/2) > >>

pascal111:
We have in Pascal conditional loops like "while … do" and "repeat … until", but is there a free conditions manipulating loops like those of QBasic:



--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- DO WHILE (CONDITION) LOOP   DO LOOP WHILE (CONDITION)   DO UNTIL (CONDITION) LOOP    DO LOOP UNTIL (CONDITION)   

y.ivanov:
See https://wiki.freepascal.org/Basic_Pascal_Tutorial


--- Quote from: pascal111 on May 04, 2021, 12:34:31 am ---We have in Pascal conditional loops like "while … do" and "repeat … until", but is there a free conditions manipulating loops like those of QBasic:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---DO WHILE (CONDITION) LOOP
--- End quote ---


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---WHILE CONDITION DObeginend; //LOOP

--- Quote from: pascal111 on May 04, 2021, 12:34:31 am ---
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---DO LOOP WHILE (CONDITION)
--- End quote ---


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---repeat //DO until not (CONDITION);

--- Quote from: pascal111 on May 04, 2021, 12:34:31 am ---
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---DO UNTIL (CONDITION) LOOP
--- End quote ---


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---while not (CONDITION) dobeginend; //LOOP


--- Quote from: pascal111 on May 04, 2021, 12:34:31 am ---
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---DO LOOP UNTIL (CONDITION)
--- End quote ---


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---repeat //DO UNTIL (CONDITION);

jamie:
Lets not forget that you also have

CONTINUE  // Skip remaining of current iteration and jump directly to the controlling condition of the loop.
BREAK   // break out of the loop and finish early or just break out when using a WHILE TRUE do....



pascal111:
I see now @y.ivanov, freeing the limited forms by using negations and making other forms of variety. Thanks!

pascal111:

--- Quote from: jamie on May 04, 2021, 01:15:50 am ---Lets not forget that you also have

CONTINUE  // Skip remaining of current iteration and jump directly to the controlling condition of the loop.
BREAK   // break out of the loop and finish early or just break out when using a WHILE TRUE do....

--- End quote ---

Yup @jamie, these are two special additions.

Navigation

[0] Message Index

[#] Next page

Go to full version