Forum > Databases

[solved] endless loop - I feel stupid

(1/3) > >>

Nicole:
This is a question I feel very stupid to put it.
I have an endless loop. Since 2 days I simplify it and cannot see, why:



--- 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";}};} ---  ShowMessage('before');   IBSQLChart.Active:=true; // I tried both IBSQL and IBquery, so before here was ExecQuery with the same effect  while not IBSQLChart.Eof do begin   {  *simplified = set into brackets*              }     IBSQLChart.Next;  end;  ShowMessage('after');

domasz:

--- Quote from: Nicole on February 24, 2024, 10:41:39 am ---

--- 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";}};} ---  ShowMessage('before');;
--- End quote ---
Ah, Grandma's debugger, classic!

Joanna:
I’m not familiar with ibsqlchart but I’m curious what happens if you insert

ibsqlchart.First;  After line 3?

Also is there any way to trace into the code in loop to find out what it is doing?

rvk:
WHAT is IBSQLChart at the moment??
If it's a TIBQuery or TIBSQL then there is something in your code which you commented out.

Did you try to put that code in comments and see if it's still loops endlessly???

TDataset.First after setting TDataset.Active to true shouldn't make a difference because it's always at the first record after opening. That is... IF the TDataset wasn't already active before that line !!!
And that's a big if because we don't see any other code (as usual).

Just try the code exactly as you put it here in your post and report back.
If it's still happening... show us more code from before this code.

Nicole:

--- 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";}};} ---WHAT is IBSQLChart at the moment??If it's a TIBQuery or TIBSQL then there is something in your code which you commented out.
TIBQuery


--- 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";}};} ---Did you try to put that code in comments and see if it's still loops endlessly???
yes!!



--- 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";}};} ---TDataset.First after setting TDataset.Active to true shouldn't make a difference because it's always at the first record after opening. That is... IF the TDataset wasn't already active before that line !!!And that's a big if because we don't see any other code (as usual). Just try the code exactly as you put it here in your post and report back.If it's still happening... show us more code from before this code.
To make sure, I had added the line

--- 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";}};} ---IBSQLChart.Active:=false;already.
Is it good style to set the query to active? Or shall I switch something else?

Where the trouble occurs is at the end of looping. I watched the first datasets passing through and watched the "order by" criteria. It runs about to the end.
So to my mind the problem is the
.EOF, which is not triggered.

Navigation

[0] Message Index

[#] Next page

Go to full version