IBX 2.7.2, What's wrong with my codes? lazarus / 21-General ---------------------------------------------------------------------- incendio · 2025-06-18 03:14 Hi guys, Just upgrade from Lazarus 2.2.2 to Lazarus 4.0 Windows 32 bit. Have problem with codes that work well in Lazarus 2.2.2, now not working. Here are the codes Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TMainFrm = class(TForm)    private   procedure Test(RptId : string;ColHeader : array of string);   function GetColTitleWidth(RptId : string;Coltitle : string) : integer;end; function TMainFrm.GetColTitleWidth(RptId : string;Coltitle : string) : integer;begin  ShowMessage('From get col : ' + Coltitle);  DM.Q.SQL.Clear;  DM.Q.SQL.Add('select wd from m_rpt_col where id_rpt = ' + RptId + ' and title = '''+ Coltitle + '''' );  DM.Q.Open;  Result := DM.Q.FieldByName('wd').AsInteger;end; procedure TMainFrm.Test(RptId : string;ColHeader : array of string);var  Col : string;begin  Col :=  ColHeader[i];  ShowMessage(Col);   GetColTitleWidth(RptId,Col);  Problem with Lazarus 4 is variable Col in procedure Test has a value, for exam. 'Code', but in function GetColTitleWidth a string append operation with variable not working. ShowMessage('From get col : ' + Coltitle) should be 'From get col : Code', it became 'From get col : ' if code change to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainFrm.Test(RptId : string;ColHeader : array of string);var  Col : string;begin  Col :=  'Code';   GetColTitleWidth(RptId,Col);  It worked OK. Why is that ? ---------------------------------------------------------------------- ASerge · 2025-06-18 04:21 Quote from: incendio on June 18, 2025, 05:14:10 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainFrm.Test(RptId : string;ColHeader : array of string);var  Col : string;begin  Col :=  ColHeader[i];  ShowMessage(Col);  GetColTitleWidth(RptId,Col); What is variable i? ---------------------------------------------------------------------- incendio · 2025-06-18 04:26 Quote from: ASerge on June 18, 2025, 06:21:44 amQuote from: incendio on June 18, 2025, 05:14:10 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainFrm.Test(RptId : string;ColHeader : array of string);var  Col : string;begin  Col :=  ColHeader[i];  ShowMessage(Col);  GetColTitleWidth(RptId,Col); What is variable i? Sorry, it was a part of actual code. i value is 0, type of integer. ---------------------------------------------------------------------- 440bx · 2025-06-18 04:27 Quote from: incendio on June 18, 2025, 06:26:13 ami value is 0, type of integer. Curious... is it a global variable ? ---------------------------------------------------------------------- incendio · 2025-06-18 04:29 Quote from: 440bx on June 18, 2025, 06:27:33 amQuote from: incendio on June 18, 2025, 06:26:13 ami value is 0, type of integer. Curious... is it a global variable ? No, it is a local variable. Its value from a for loop. ---------------------------------------------------------------------- 440bx · 2025-06-18 04:45 Quote from: incendio on June 18, 2025, 06:29:26 amNo, it is a local variable. Its value from a for loop. if it's a local variable then why isn't it showing as a var in TMainFrm.Test which is where it's used ? ---------------------------------------------------------------------- H₂SO₄ · 2025-06-18 04:51 Quote from: incendio on June 18, 2025, 06:29:26 amQuote from: 440bx on June 18, 2025, 06:27:33 amQuote from: incendio on June 18, 2025, 06:26:13 ami value is 0, type of integer. Curious... is it a global variable ? No, it is a local variable. Its value from a for loop. Can you post the full code? I'm sure the problem's root cause is somewhere in  TMainFrm.Test  or its callers,  but this snippet doesn't contain anything that might break due to version differences. I suspect the old code already contained a subtle bug (e.g. reliance on a certain manifestation of undefined behavior) that just happened to work until now. Does  ColHeader  have the right contents upon assignment to  Col? Have you checked with a debugger? ---------------------------------------------------------------------- incendio · 2025-06-18 05:51 Quote from: Khrys on June 18, 2025, 06:51:53 amQuote from: incendio on June 18, 2025, 06:29:26 amQuote from: 440bx on June 18, 2025, 06:27:33 amQuote from: incendio on June 18, 2025, 06:26:13 ami value is 0, type of integer. Curious... is it a global variable ? No, it is a local variable. Its value from a for loop. Can you post the full code? I'm sure the problem's root cause is somewhere in  TMainFrm.Test  or its callers,  but this snippet doesn't contain anything that might break due to version differences. I suspect the old code already contained a subtle bug (e.g. reliance on a certain manifestation of undefined behavior) that just happened to work until now. Does  ColHeader  have the right contents upon assignment to  Col? Have you checked with a debugger? Full code is quite large, beside it won't work either because it needs firebird database to be installed. Will try to make a sample project to show the problem. ---------------------------------------------------------------------- incendio · 2025-06-18 07:13 Attached is a complete sample of project. It won run without firebird database installed, but it has the same problem with string operation. The error began with this codes Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;var  Header : array of string;  i : integer;begin  i:=0;  SetLength(Header, NoOfCol);   Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;   while not(Q.EOF) do  begin    Header[i] := Q.FieldByName('title').AsString;    i := i+1;    ShowMessage('Header : ' + Header[i]); // Show Header :    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;  end;   Result := Header;end; ---------------------------------------------------------------------- rvk · 2025-06-18 07:28 Quote from: incendio on June 18, 2025, 09:13:16 amThe error began with this codes That's why you always need to post exact code and leave nothing out (unless you have tested it and made sure your shown code also contains the problem). Look at your line 16 and 17. You begin with an empty array. You set Header[0] to a fieldtitle. Then you increate i and want to display Header[1]. But Header[1] isn't filled yet so it's empty so your line 18 shows an empty text. Move the i := i + 1 to under Q.Next and it should show the correct texts. ---------------------------------------------------------------------- H₂SO₄ · 2025-06-18 07:33 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' ); What's the type of  ID_RPT? Why isn't  RptId  quoted? If the query returns no results, then  Header  will contain only empty strings. (Obligatory: Please use query parameters to save yourself from headaches and SQL injections) ---------------------------------------------------------------------- incendio · 2025-06-18 07:39 Quote from: rvk on June 18, 2025, 09:28:19 amQuote from: incendio on June 18, 2025, 09:13:16 amThe error began with this codes That's why you always need to post exact code and leave nothing out (unless you have tested it and made sure your shown code also contains the problem). Look at your line 16 and 17. You begin with an empty array. You set Header[0] to a fieldtitle. Then you increate i and want to display Header[1]. But Header[1] isn't filled yet so it's empty so your line 18 shows an empty text. Move the i := i + 1 to under Q.Next and it should show the correct texts. You were right, it was an error in this sample, but not in the real project. Take a look at line 20, showmessage showed empty string for table's record. ---------------------------------------------------------------------- incendio · 2025-06-18 07:42 Quote from: Khrys on June 18, 2025, 09:33:44 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' ); What's the type of  ID_RPT? Why isn't  RptId  quoted? If the query returns no results, then  Header  will contain only empty strings. (Obligatory: Please use query parameters to save yourself from headaches and SQL injections) Type of id_rpt is integer. Query returns with result. Line 19 show the value of the record. ---------------------------------------------------------------------- rvk · 2025-06-18 07:45 Quote from: incendio on June 18, 2025, 09:39:31 amYou were right, it was an error in this sample, but not in the real project. Take a look at line 20, showmessage showed empty string for table's record. That's why you only paste exact code. You say line 20 doesn't show Q.FieldByName('title').AsString while the line above does??? Are you absolutely sure this isn't a typo again? (just asking before trying to create a database and testing the code) ---------------------------------------------------------------------- incendio · 2025-06-18 07:48 Quote from: rvk on June 18, 2025, 09:45:04 amQuote from: incendio on June 18, 2025, 09:39:31 amYou were right, it was an error in this sample, but not in the real project. Take a look at line 20, showmessage showed empty string for table's record. That's why you only paste exact code. You say line 20 doesn't show Q.FieldByName('title').AsString while the line above does??? Are you absolutely sure this isn't a typo again? (just asking before trying to create a database and testing the code) Yes. ---------------------------------------------------------------------- rvk · 2025-06-18 08:00 Quote from: incendio on June 18, 2025, 09:48:50 amYes. I had to change the SQL and my fieldname to "NAAM" because I have other tables. But other than that... your code works fine (when moving that i := i + 1; All three showmessage show the field content. "Lazarus 4.0 (rev lazarus_4_0) FPC 3.2.2 x86_64-win64-win32/win64" with IBX installed through OPM. ---------------------------------------------------------------------- incendio · 2025-06-18 08:06 Quote from: rvk on June 18, 2025, 10:00:28 amQuote from: incendio on June 18, 2025, 09:48:50 amYes. I had to change the SQL and my fieldname to "NAAM" because I have other tables. But other than that... your code works fine (when moving that i := i + 1; All three showmessage show the field content. "Lazarus 4.0 (rev lazarus_4_0) FPC 3.2.2 x86_64-win64-win32/win64" with IBX installed through OPM. What? What is firebird version you're used? I am using firebird 5.02 and Lazarus 4 for windows 32, not sure the fpc version, not in front computer right now. ---------------------------------------------------------------------- rvk · 2025-06-18 08:20 Quote from: incendio on June 18, 2025, 10:06:30 amWhat is firebird version you're used? I am using firebird 5.02 and Lazarus 4 for windows 32, not sure the fpc version, not in front computer right now. On this machine I'm still using Firebird 2.5 (although on others 5). But that shouldn't matter. The IBX version is much more important in this case. But with both the same Q.FieldByName in the showmessage in two lines together... it should just work. In between those two lines there is nothing for it to get corrupted. BTW. You say in your code "Show correctly FieldName". But you probably meant "Show correctly the field CONTENT". With Q.FieldByName('title').AsString you don't show the FieldName but the content for field "title". ---------------------------------------------------------------------- incendio · 2025-06-18 09:31 I have change the codes (move i:= i+1) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;var  Header : array of string;  i : integer;begin  i:=0;  SetLength(Header, NoOfCol);   Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;   while not(Q.EOF) do  begin    Header[i] := Q.FieldByName('title').AsString;    ShowMessage('Header : ' + Header[i]); // Show Header :    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;    i := i+1;  end;   Result := Header;end; The result on line 17 & 19 still empty string. IBX 2.72.1650 Change code on line 16 to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Header[i] := 'abc';Line 17 and 18 showed correct result, line 19 still empty string. Could it be IBX not compatible with Firebird 5? ---------------------------------------------------------------------- Thaddy · 2025-06-18 09:39 CASEcase a case of case, maybe? ---------------------------------------------------------------------- rvk · 2025-06-18 09:40 Quote from: incendio on June 18, 2025, 11:31:35 amCould it be IBX not compatible with Firebird 5? I thought Firebird 5 wasn't a problem for IBX. Just tried it with LI-V5.0.2.1613 Firebird 5.0 without any problems. But there are potentially more problems with your code. Try removing all the Header lines (so the SetLength and the Header := and the showmessage for Header). Do the two remaining Showmessages give you problems? Probably not. You do a SetLength(Header, 12) in your code and a while not (Q.EOF) do it could potentially overflow the array. But you only retrieve one record with one field so that shouldn't be a problem. ---------------------------------------------------------------------- incendio · 2025-06-18 09:50 Tried with Firebird 3.10, same Lazarus 4 32 for Windows & IBX, problem still exist. Doubt this error cause by IBX, I think the problem is in Lazarus. This is sql for test project Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CREATE TABLE M_RPT_COL(  ID INTEGER NOT NULL,  ID_RPT INTEGER NOT NULL,  TITLE VARCHAR(60) NOT NULL,  WD SMALLINT NOT NULL,  ISTXT BOOLEAN DEFAULT TRUE NOT NULL,  CONSTRAINT INTEG_602 PRIMARY KEY (ID));  INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('120', '2664', 'Code', '15', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('121', '2664', 'Counter', '40', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('122', '2664', 'Barcode', '30', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('123', '2664', 'Brand', '35', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('124', '2664', 'Sub Category', '30', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('125', '2664', 'Art', '40', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('126', '2664', 'Color', '50', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('127', '2664', 'Size', '15', 'true');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('128', '2664', 'Sld', '15', 'false');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('129', '2664', 'HPP', '20', 'false');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('130', '2664', 'Total', '25', 'false');INSERT INTO M_RPT_COL (ID, ID_RPT, TITLE, WD, ISTXT) VALUES ('131', '2664', 'Sls Prc', '20', 'false');   Installed from lazarus-4.0-fpc-3.2.2-win32.exe ---------------------------------------------------------------------- rvk · 2025-06-18 10:00 Quote from: incendio on June 18, 2025, 11:50:26 amTried with Firebird 3.10, same Lazarus 4 32 for Windows & IBX, problem still exist. Doubt this error cause by IBX, I think the problem is in Lazarus.Did you try removing the Header array of string lines yet? ---------------------------------------------------------------------- incendio · 2025-06-18 10:03 Quote from: rvk on June 18, 2025, 11:40:23 amQuote from: incendio on June 18, 2025, 11:31:35 amCould it be IBX not compatible with Firebird 5? I thought Firebird 5 wasn't a problem for IBX. Just tried it with LI-V5.0.2.1613 Firebird 5.0 without any problems. But there are potentially more problems with your code. Try removing all the Header lines (so the SetLength and the Header := and the showmessage for Header). Do the two remaining Showmessages give you problems? Probably not. You do a SetLength(Header, 12) in your code and a while not (Q.EOF) do it could potentially overflow the array. But you only retrieve one record with one field so that shouldn't be a problem. Same problem, everytime string add to a variable, showmessage only showed string value. ---------------------------------------------------------------------- rvk · 2025-06-18 10:05 Quote from: incendio on June 18, 2025, 12:03:55 pmSame problem, everytime string add to a variable, showmessage only showed string value. So, you mean this gives you the same problem ????????? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;begin  Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;  while not(Q.EOF) do  begin    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;  end;end; ---------------------------------------------------------------------- incendio · 2025-06-18 10:10 Quote from: rvk on June 18, 2025, 12:05:44 pmQuote from: incendio on June 18, 2025, 12:03:55 pmSame problem, everytime string add to a variable, showmessage only showed string value. So, you mean this gives you the same problem ????????? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;begin  Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;  while not(Q.EOF) do  begin    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;  end;end;Yes Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;var  Header : array of string;  i : integer;begin  i:=0;  //SetLength(Header, NoOfCol);   Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  //ShowMessage(Q.SQL.Text);  Q.Open;   while not(Q.EOF) do  begin    //Header[i] := 'abc';//Q.FieldByName('title').AsString;    //ShowMessage('Header : ' + Header[i]); // Show Header :    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString + 'cv'); // Show Field :    Q.Next;    i := i+1;  end;   Result := Header;end; ---------------------------------------------------------------------- rvk · 2025-06-18 10:24 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ShowMessage('Field : ' + Q.FieldByName('title').AsString + 'cv'); // Show Field : Does that really only show Field : and not Field : cv ? ---------------------------------------------------------------------- incendio · 2025-06-18 10:38 Quote from: rvk on June 18, 2025, 12:24:03 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ShowMessage('Field : ' + Q.FieldByName('title').AsString + 'cv'); // Show Field : Does that really only show Field : and not Field : cv ? Show Field : cv Tried lazarus-4.0-fpc-3.2.2-win64.exe in virtual machine, same result, problem! ---------------------------------------------------------------------- krolikbest · 2025-06-18 12:19 Quote from: incendio on June 18, 2025, 11:31:35 amI have change the codes (move i:= i+1) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;var  Header : array of string;  i : integer;begin  i:=0;  SetLength(Header, NoOfCol);   Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;   while not(Q.EOF) do  begin    Header[i] := Q.FieldByName('title').AsString;    ShowMessage('Header : ' + Header[i]); // Show Header :    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;    i := i+1;  end;   Result := Header;end;  Maybe Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Header : array of string; and later in the code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SetLength(Header, NoOfCol); how much is NoOfCol? ---------------------------------------------------------------------- incendio · 2025-06-18 12:27 Quote from: krolikbest on June 18, 2025, 02:19:02 pmQuote from: incendio on June 18, 2025, 11:31:35 amI have change the codes (move i:= i+1) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.CreateArr(RptId: string;NoOfCol : integer) : StrArray;var  Header : array of string;  i : integer;begin  i:=0;  SetLength(Header, NoOfCol);   Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = ' + RptId + ' order by id' );  ShowMessage(Q.SQL.Text);  Q.Open;   while not(Q.EOF) do  begin    Header[i] := Q.FieldByName('title').AsString;    ShowMessage('Header : ' + Header[i]); // Show Header :    ShowMessage(Q.FieldByName('title').AsString); // Show correctly FieldName    ShowMessage('Field : ' + Q.FieldByName('title').AsString); // Show Field :    Q.Next;    i := i+1;  end;   Result := Header;end;  Maybe Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Header : array of string; and later in the code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SetLength(Header, NoOfCol); how much is NoOfCol? NoOfCol := 12, same as number of records in the table. ---------------------------------------------------------------------- bytebites · 2025-06-18 12:29 Of course you are running range check on. ---------------------------------------------------------------------- rvk · 2025-06-18 12:45 Quote from: bytebites on June 18, 2025, 02:29:54 pmOf course you are running range check on. Nope. Even debugging info was off in the test-project. ---------------------------------------------------------------------- Thaddy · 2025-06-18 15:11 So that makes this case a CASE issue?....... Now playing the Hives again. ---------------------------------------------------------------------- incendio · 2025-06-18 21:35 Quote from: Thaddy on June 18, 2025, 05:11:07 pmSo that makes this case a CASE issue?....... Now playing the Hives again. What do you mean? ---------------------------------------------------------------------- incendio · 2025-06-18 22:04 Simple procedure like this gave problem Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button2Click(Sender: TObject); begin  Q.Close;  Q.SQL.Clear;  Q.SQL.Add('select title from m_rpt_col where ID_RPT = 2664 order by id rows 1' );  Q.Open;   while not(Q.EOF) do  begin    ShowMessage('Field : ' + Q.FieldByName('title').AsString + 'cv');     Q.Next;  end;end; ShowMessage showedField : cv Don't know wtih caused the problem, Lazarus 4 32 or IBX 2.7.2.1650 ---------------------------------------------------------------------- rvk · 2025-06-18 22:13 Does it show that for all 12 records? Do you get 12 times the same result? Otherwise there just might be a record with an empty title. ---------------------------------------------------------------------- incendio · 2025-06-18 22:48 Yes, 12 times, empty. ---------------------------------------------------------------------- incendio · 2025-06-19 02:25 Testted with Lazarus 2.2.2 and IBX 2.7.2, gave same problem. With IBX 2.7.2 this code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ShowMessage('Field : ' + Q.FieldByName('wd').AsString); Gave correct result if field wd type is integer. So probably, problem in IBX? ---------------------------------------------------------------------- rvk · 2025-06-19 05:05 I was just about to suggest trying a different fields. Because when I tried it I used a different fields and it worked fine. This might not be a problem with IBX but maybe a problem with Firebird. Maybe title had become a reserved word (although not documented). You can check if the standard slqdb component from FPC/Lazarus give the same. Dus the field contain text when you use Flamerobin (or other manager) to view the table. ---------------------------------------------------------------------- incendio · 2025-06-19 05:59 I have tried with Lazarus 2.2.2 with IBX 2.7.2 from OPM and IBX 2.7.4 from github, both IBX versions gave same problem. I remembere when using Lazarus 2.2.2 and IBX (forgot the version), that codes work fine. Probably this is IBX. @rvk, you said that code work fine for you, could you share the version of IBX, fbintf, and ibcontrol you used? ---------------------------------------------------------------------- egsuh · 2025-06-19 07:14 This may not be database-related problem. Some problem in string operation, instead. Once I had similar problem but not remember exactly what it was.  I think I have posted the issue here, but cannot find it. Can you try followings, and share the results. 1) using Format, instead of + operation.     ShowMessageFmt('Field : %s cv', [Q.FieldByName('title').AsString]); 2) Use mediating variable        ts := Q.FieldByName('title').AsString;        ShowMessage('Field : ' + ts + 'cv'); 3) Using mediating variable for whole string         ts :- 'Field : ' + Q.FieldByName('title').AsString + 'cv';         ShowMessage(ts); ---------------------------------------------------------------------- incendio · 2025-06-19 10:42 Quote from: egsuh on June 19, 2025, 09:14:07 amThis may not be database-related problem. Some problem in string operation, instead. Once I had similar problem but not remember exactly what it was.  I think I have posted the issue here, but cannot find it. Can you try followings, and share the results. 1) using Format, instead of + operation.     ShowMessageFmt('Field : %s cv', [Q.FieldByName('title').AsString]); 2) Use mediating variable        ts := Q.FieldByName('title').AsString;        ShowMessage('Field : ' + ts + 'cv'); 3) Using mediating variable for whole string         ts :- 'Field : ' + Q.FieldByName('title').AsString + 'cv';         ShowMessage(ts); All failed. With previous ver of IBX, it was no problem. I have been trying to install previous ver of IBX from github with no success. ---------------------------------------------------------------------- rvk · 2025-06-19 10:57 Quote from: incendio on June 19, 2025, 07:59:48 am@rvk, you said that code work fine for you, could you share the version of IBX, fbintf, and ibcontrol you used? As I said, I didn't have your database so I used one of mine. With a table and field name NAAM it worked fine. You say that it worked with other fields. So the problem is the field name title which is probably a reserved word. Did you try another database manager to see what the table actually shows? Anyway... avoid common words like title etc. ---------------------------------------------------------------------- rvk · 2025-06-19 11:04 Quote from: rvk on June 19, 2025, 12:57:31 pmAs I said, I didn't have your database so I used one of mine. With a table and field name NAAM it worked fine. You say that it worked with other fields. So the problem is the field name title which is probably a reserved word. Did you try another database manager to see what the table actually shows? Anyway... avoid common words like title etc. Nope. Just tried it with a table you defined and that still works for me (using the field "title"). Can you share a sample database? (not the DDL and INSERT but the actual database) Only thing I can think of is that you also have a DOMAIN type title or a PROCEDURE or something. Especially because other fields work fine. *) You could try doing SELECT title as NEWFIELD from xx and then trying to read NEWFIELD *) If that doesn't work, create a second field NEWFIELD and fill it and try to use it. Just to rule out it is the "title" as fieldname problem. ---------------------------------------------------------------------- incendio · 2025-06-19 12:05 Quote from: rvk on June 19, 2025, 12:57:31 pmQuote from: incendio on June 19, 2025, 07:59:48 am@rvk, you said that code work fine for you, could you share the version of IBX, fbintf, and ibcontrol you used? As I said, I didn't have your database so I used one of mine. With a table and field name NAAM it worked fine. You say that it worked with other fields. So the problem is the field name title which is probably a reserved word. Did you try another database manager to see what the table actually shows? Anyway... avoid common words like title etc. It worked if field type is integer. This is not about reserved word. Tried to test table, field name S1, type varchar 32, same problem. Also, it worked fine in old IBX version. What about your, could you share your version of ibx, ibcontrol and fbintf so I can download these files from github. Have trouble also to get the old IBX to work. ---------------------------------------------------------------------- rvk · 2025-06-19 12:10 Quote from: incendio on June 19, 2025, 02:05:29 pmWhat about your, could you share your version of ibx, ibcontrol and fbintf so I can download these files from github. Have trouble also to get the old IBX to work. I just used the latest OPM version. On a new Lazarus 4 install on Windows 64bit. ---------------------------------------------------------------------- incendio · 2025-06-19 13:38 Quote from: rvk on June 19, 2025, 02:10:42 pmQuote from: incendio on June 19, 2025, 02:05:29 pmWhat about your, could you share your version of ibx, ibcontrol and fbintf so I can download these files from github. Have trouble also to get the old IBX to work. I just used the latest OPM version. On a new Lazarus 4 install on Windows 64bit. Installed many time in VM with Lazarus 2.2.2 and 4 and firebird 3, none works for me. Tried using IBConnection from Lazarus 2.2.2 and it worked OK! My guess is, this is caused by nrw version of IBX. ---------------------------------------------------------------------- incendio · 2025-06-19 23:46 Finally, I was able to get back to old Lazarus 2.2.2 and old ver of IBX and test this code. With Firebird 3 and IBX 2.5, it worked just expected. I suspect it will also work in Lazarus 4. It is confirmed that IBX 2.7.2, won't work, may be it is a bug? ---------------------------------------------------------------------- egsuh · 2025-06-20 05:54 I remember Firebird 4? 5? was not processed properly in my application (the same issue you have experienced), which used to have no problem with Firebird 3. I have posted the issue here --- recalled now. https://forum.lazarus.freepascal.org/index.php/topic,61144.msg459164.h tml#msg459164 As it was a development program, I kept using Firebird 3 in my main application (practically the same one as development program). Later I upgraded to Lazarus 4 and Firebird 5 and have no problem in running the development program now. ---------------------------------------------------------------------- incendio · 2025-06-20 06:25 I have tried it with Lazarus 4 with Firebird 5.02, with IBX 2.5 - OK, IBX->2.7.2, problem ---------------------------------------------------------------------- rvk · 2025-06-20 06:35 Are you still using the same database? I already asked if you could share it? If not create a new database with that take, check it and if problem persist, share it here. The problem was also with Firebird 3 and 4 with latest IBX? I'm trying to see if we can recreate this. As long as we can't recreate it, is almost impossible to find the bug I'll try again later this morning but having a database where this problem occurs could be useful. ---------------------------------------------------------------------- incendio · 2025-06-20 06:55 Quote from: rvk on June 20, 2025, 08:35:41 amAre you still using the same database? I already asked if you could share it? If not create a new database with that take, check it and if problem persist, share it here. The problem was also with Firebird 3 and 4 with latest IBX? I'm trying to see if we can recreate this. As long as we can't recreate it, is almost impossible to find the bug I'll try again later this morning but having a database where this problem occurs could be useful. Real project use firebird 5, test project use firebird 3. IBX 2.5 works OK with FB3 and FB5, IBX 2.7.2 was not. Attached is test dba with FB3. ---------------------------------------------------------------------- rvk · 2025-06-20 08:34 I can FINALLY confirm the problem. But... I think the problem may be in the 32 bit. When trying on Windows 64 bit with 64 bit Lazarus it gave me no problems. In a VM Windows 10 32 bit with 32 bit Lazarus I could confirm this problem. I would nee to dive in deeper to find the exact problem but maybe it's time to call in the expert  Any ideas @tonyw ? ---------------------------------------------------------------------- incendio · 2025-06-20 09:06 Quote from: rvk on June 20, 2025, 10:34:58 amI can FINALLY confirm the problem. But... I think the problem may be in the 32 bit. When trying on Windows 64 bit with 64 bit Lazarus it gave me no problems. In a VM Windows 10 32 bit with 32 bit Lazarus I could confirm this problem. I would nee to dive in deeper to find the exact problem but maybe it's time to call in the expert  Any ideas @tonyw ? I have to admire you to go such length to find out the problem 👍 ---------------------------------------------------------------------- rvk · 2025-06-20 09:37 Quote from: incendio on June 20, 2025, 11:06:01 amI have to admire you to go such length to find out the problem 👍 Yeah, those bugs really irk me. I even wonder if it's really a IBX problem. But it does only happen when using Firebird 3 or higher. (Maybe a big memory overwrite in IBX ?) The variable seems to contain the correct value, it's just that with showmessage and concatenation, it doesn't show. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   while not(Q.EOF) do  begin    S1 := Q.FieldByName('s1').AsString;    ShowMessage(S1);    ShowMessage('Header : ' + S1);    Q.Next;  end; On line 5 S1 stills contains the correct value but doesn't show. That does indicate the problem is not in AsString from IBX. But if I hardcode a string on line 3 then it works fine. Really weird. ---------------------------------------------------------------------- rvk · 2025-06-20 09:43 Now I can also reproduce in Lazarus 4 64 bit. The problem was that I tried it with Firebird 5 on a Linux server and there is works fine. I now have Firebird 3 64 bit in a Sandbox and use Lazarus 4 64 bit on the host and the same problem. When entering the Showmessage, the aMsg parameter is missing the content of the concatenated variable. (But only happens when using that FieldByName) When S2 is a String it craps out. When it's a ShortString it works fine. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     S1 := Q.FieldByName('s1').AsString;    ShowMessage(S1);    S2 := 'Header1 : ' + S1;    ShowMessage(S2); And using this... only shows 3 (length of S1). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     S1 := Q.FieldByName('s1').AsString;    ShowMessage(S1 + length(S1).ToString); ---------------------------------------------------------------------- rvk · 2025-06-20 10:21 This doesn't even work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     S2 := Q.FieldByName('s1').AsString;    S1 := Copy(S2,2);    ShowMessage(S1 + ' ' + length(s1).ToString);    S2 := 'Header1 : ' + S1;    ShowMessage(S2);S2 contains the content "One". I thought I would copy the string to a new string (by using Copy but making sure a new copy was made). S1 contains "ne". But still the Showmessages fail when concatenating. I'm kinda out of ideas. ---------------------------------------------------------------------- rvk · 2025-06-20 11:26 Quote from: WooBean on June 20, 2025, 01:03:12 pmJust relax. The problem is only there when filling a string with Fieldbyname.asString from IBX. Even slqdb works fine. So there is a memory problem in combination with IBX 2.7.2. ---------------------------------------------------------------------- rvk · 2025-06-20 13:30 @incendio, I think I figured it out (partly). Because when I created a table in my own existing database, there was no problem. When creating a new database with Lazarus/IBX, even with Firebird 2.5, it began having the problem. I found out the CHARACTER SET of the database is the problem. If set to NONE, this problem occurs. Here is a DDL of a problem database. Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SET SQL DIALECT 3; /* CREATE DATABASE '127.0.0.1:C:\Temp\TTT.FDB' PAGE_SIZE 4096 DEFAULT CHARACTER SET NONE */ /* Table: TBL, Owner: SYSDBA */CREATE TABLE TBL (ID BIGINT NOT NULL,        S1 VARCHAR(32),PRIMARY KEY (ID)); Same database without a problem: Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SET SQL DIALECT 3; /* CREATE DATABASE '127.0.0.1:C:\Temp\TTT2.FDB' PAGE_SIZE 4096 DEFAULT CHARACTER SET ISO8859_1 */ /* Table: TBL, Owner: SYSDBA */CREATE TABLE TBL (ID BIGINT NOT NULL,        S1 VARCHAR(32),PRIMARY KEY (ID)); (You can get the DDL with: isql -ex -u sysdba -p masterkey 127.0.0.1:C:\Temp\TTT.FDB ) Try to recreate your database with (or change) the CHARACTER SET ISO8859_1, and see if you still have the problem. Now... it still remains a question for @tonyw why a database with CHARACTER SET NONE will exibit this behavior, but at least we are a step closer. Simple console app to select the data (and create the database if not found). Note, if run inside the IDE you need to click CONTINUE on the exception, to let it create the database (or you need to disable debugging or run outside the IDE). Project > New Project > Simple project. Ctrl + A (to select all) and paste in code below. Project > Project Inspector and add ibnongui (nothing else is required) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program simple_fb; uses DB, IBDatabase, IBQuery, IB; procedure foo;const  Db = '127.0.0.1:C:\TEMP\TTT2.FDB';  Fld = 'S1';  Sql = 'SELECT S1 FROM TBL';var  IB: TIBDatabase;  IbSql: TIBQuery;   procedure Exec(Str: String);  begin    IbSql.SQL.Text := Str;    IB.DefaultTransaction.Active := true;    IbSql.ExecSQL;    if IB.DefaultTransaction.Active then IB.DefaultTransaction.Commit;  end; begin  IB := TIBDatabase.Create(nil);  IbSql := TIBQuery.Create(nil);  try    IB.DatabaseName := DB;    IB.DefaultTransaction := TIBTransaction.Create(IB);    IB.DefaultTransaction.DefaultDatabase := IB;    IB.LoginPrompt := false;    IbSql.Database := IB;    try       IB.Params.Clear;      IB.Params.Values['user_name'] := 'SYSDBA';      IB.Params.Values['password'] := 'masterkey';      IB.Params.Values['lc_ctype'] := 'NONE';      IB.Connected := True;   except      on E: EDatabaseError do      begin        if (E is EIBInterBaseError) and (EIBInterBaseError(E).IBErrorCode = 335544344) then        begin          IB.Params.Clear;          IB.Params.Add('USER ''SYSDBA''');          IB.Params.Add('PASSWORD ''masterkey''');          IB.Params.Add('PAGE_SIZE 4096');          IB.Params.Add('DEFAULT CHARACTER SET ISO8859_1');          IB.Params.Values['user_name'] := 'SYSDBA';          IB.Params.Values['password'] := 'masterkey';          IB.Params.Values['lc_ctype'] := 'ISO8859_1';          IB.SQLDialect := 3;          IB.CreateDatabase;          IB.Connected := false;         IB.Params.Clear;          IB.Params.Values['user_name'] := 'SYSDBA';          IB.Params.Values['password'] := 'masterkey';        IB.Params.Values['lc_ctype'] := 'ISO8859_1';          IB.Connected := True;           Exec('CREATE TABLE TBL (ID BIGINT PRIMARY KEY, S1 VARCHAR(32) );');          Exec('INSERT INTO TBL VALUES (1, ''One'');');          Exec('INSERT INTO TBL VALUES (2, ''Two'');');        Exec('INSERT INTO TBL VALUES (3, ''Three'');');          Exec('INSERT INTO TBL VALUES (4, ''Four'');');        end;      end;  end;     IB.DefaultTransaction.Active := true;    IbSql.SQL.Text := SQL;    IbSql.Open;    while not IbSql.EOF do    begin      writeln(IbSql.FieldByName(Fld).AsString);      writeln('Test: ' + IbSql.FieldByName(Fld).AsString);      writeln;      IbSql.Next;    end;    IbSql.Close;   finally    IbSql.Free;    IB.Free;  end; end; begin  foo;  ReadLn;end.  When using DEFAULT CHARACTER SET NONE in above code... the problem creeps up again. ---------------------------------------------------------------------- incendio · 2025-06-20 14:21 Wow, congratulation, you found the solution 👍 I never touch character set. Is it safe to change character set for an active database? Used IBX for active database, not just for testing. Will be a disaster if there are problems by changing its character set. Btw, now for real use, I am back to Lazarus 2.2.2 and IBX 2.5. Using Lazarus 4 in VM, but it also used IBX 2.5. Will try again on VM to create database with character set other than none. Thanks again for your efforts, appreciate it. ---------------------------------------------------------------------- rvk · 2025-06-20 15:22 No, I don't think there is an easy way to switch the default character set. Even if it was possible, only newly created varchar fields would have that character set. All others still have the character set from before. So only with a dump and pump to new database would be possible to change it. Now for the FPC experts... does a normal string type in FPC hold some kinda character set or encoding?? Can it be viewed? Because that's the only way I can think of that the .asString from IBX now will fill that and after that, concatenating with another string fails (when character set is none). Internally there is something weird going on. I thought a string is a string... Hardcoded or assigned via .asString should matter. But here it does. So what could IBX have some to the string to behave like that?? ---------------------------------------------------------------------- rvk · 2025-06-20 16:33 Quote from: rvk on June 20, 2025, 05:22:19 pmNow for the FPC experts... does a normal string type in FPC hold some kinda character set or encoding?? Can it be viewed? Because that's the only way I can think of that the .asString from IBX now will fill that and after that, concatenating with another string fails (when character set is none). BTW. Funny part is that this problem is only with IbSql.FieldByName(Fld).AsString Using IbSql.FieldByName(Fld).AsAnsiString will work fine.... So there is definitely something with the string going on. ---------------------------------------------------------------------- dsiders · 2025-06-20 18:58 Quote from: rvk on June 20, 2025, 06:33:35 pmQuote from: rvk on June 20, 2025, 05:22:19 pmNow for the FPC experts... does a normal string type in FPC hold some kinda character set or encoding?? Can it be viewed? Because that's the only way I can think of that the .asString from IBX now will fill that and after that, concatenating with another string fails (when character set is none). BTW. Funny part is that this problem is only with IbSql.FieldByName(Fld).AsString Using IbSql.FieldByName(Fld).AsAnsiString will work fine.... So there is definitely something with the string going on. The only funny thing going on (IMHO) is that your dev environment needs to use the same string type as the database. Lazarus strings are UTF-8. If you don't want to manually do conversions, the database should use the same. YMMV. ---------------------------------------------------------------------- rvk · 2025-06-20 19:33 Quote from: dsiders on June 20, 2025, 08:58:01 pmThe only funny thing going on (IMHO) is that your dev environment needs to use the same string type as the database. Lazarus strings are UTF-8. If you don't want to manually do conversions, the database should use the same. YMMV. Normally, and this has been the case until IBX 2.7.2, you could just use TField.asString, regardless of the string type. Conversion was done automatically. I even tried it with sqldb and there is absolutely no problem to use TField.asString, regardless of the database has NONE as character set. Besides that... The strings dus really contain the text. This is shown in the debugger and it works when using it as single parameter or string. Only when concatenating with another string or hardcoded string, things start to break But I'm not sure why it's changed in IBX 2.7.2 (or why it still works in sqldb). Maybe that's something for @tonyw ---------------------------------------------------------------------- rvk · 2025-06-24 08:38 FYI. This problem doesn't show in the trunk version of Lazarus/FPC (I just tested this). Since my test project doesn't use LCL I suspect it's an incompatibility with older FPC 3.2.2 and latest IBX 2.7.2.