Recent

Author Topic: A Small problem  (Read 729 times)

JLWest

  • Hero Member
  • *****
  • Posts: 545
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.
JLWEST
Lazuras ver 2.0.2 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
3952 GB (1.5 SSD)

josh

  • Hero Member
  • *****
  • Posts: 746
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.

Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

JLWest

  • Hero Member
  • *****
  • Posts: 545
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.
JLWEST
Lazuras ver 2.0.2 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
3952 GB (1.5 SSD)

JLWest

  • Hero Member
  • *****
  • Posts: 545
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.
JLWEST
Lazuras ver 2.0.2 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
3952 GB (1.5 SSD)