Recent

Author Topic: A Small problem  (Read 1941 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
A Small problem
« on: December 28, 2018, 11:05:31 pm »
Code: Pascal  [Select][+][-]
  1.    lblIn.Caption := IntToStr(Listbox1.Count);
  2.    if RCDType = RC001 then begin
  3.     //  Inc(ACCount);
  4.       ACCount := ACCount +1;
  5.       lblAirports.Caption := IntToStr(ACCount); end;
  6.    Application.ProcessMessages;    

I can't get the ACCount to increase:

This compiles fine, the statement lblIn.Caption := IntToStr(Listbox1.Count); I see the counter going from 1 to 104,632 but the ACCount post 1 stays at 1 and never changes even at the end of the function.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: A Small problem
« Reply #1 on: December 28, 2018, 11:15:29 pm »
put a breakpoint at line 4; to make sure it actually gets there, maybe RCDType never equals the variable RC001?

Without the rest of the code, its only guess work. You maybe even setting the ACCount back to one during the iteration of the loop.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: A Small problem
« Reply #2 on: December 28, 2018, 11:22:56 pm »
I did that. And it got to the line executed inside the if statement but did not Inc  ACCount.

Did a search on ACCount.

I'll run the test again to verify.

And then post the code with a small dataset.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: A Small problem
« Reply #3 on: December 28, 2018, 11:35:12 pm »
I understand it now.

I pass a record to a procedure to be added to a listbox. Increase the counter and expect it to increase. It increase from 0 to 1 with each call.

Dumb.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018