Recent

Author Topic: Locked in a Loop Don't understand why  (Read 3408 times)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Locked in a Loop Don't understand why
« Reply #15 on: May 26, 2019, 10:13:05 pm »
I don't really know what data you are working with, and what validating it involves.
Is invalid  data simply discarded, and valid data retained?

Do you have a summary of what task(s) your program is designed to accomplish, and perhaps a limited set of data to test it on?

Once an algorithm for doing what you want is debugged and working correctly, it can then be scaled up to deal with the megabytes that listboxes can't handle. Perhaps TStringLists are all that is needed. Or perhaps a 'proper' database is called for to facilitate the data storage, editing and browsing.

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: Locked in a Loop Don't understand why
« Reply #16 on: May 26, 2019, 10:15:04 pm »
I know nothing about databases but read here and there this: mORMot + MongoDB = NoSQL
Obviously there is a way ...  good luck ...  :)


This is funny:
Quote
abusing listboxes to do this.
Yes, you son of a gun... don't abuse anybody, especially not listboxes .... that's not fair !!!  :D

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Locked in a Loop Don't understand why
« Reply #17 on: May 26, 2019, 10:58:44 pm »
@Raw

Read Where? Did you forget the link?
@howard
Yes, I have a limited test data set and I know what it's suppose to do.

On the limited data set it works just fine. 30 to 100 records. but anything large it blows up.

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

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: Locked in a Loop Don't understand why
« Reply #18 on: May 27, 2019, 12:15:14 am »
Quote
Read Where? Did you forget the link?
NO!  :)

If you need a link, aunt google is your best friend ...

for example: http://blog.synopse.info/post/2014/05/07/MongoDB-database-access

jamie

  • Hero Member
  • *****
  • Posts: 7693
Re: Locked in a Loop Don't understand why
« Reply #19 on: May 27, 2019, 12:50:43 am »
Its really a bad idea doing what you are...

 ListBox, Combo are user interfaces design to view moderate loads of data.

 The listBox currently has a limit of 32767 items because back in the old days that is all it supported.

 With the beginning of W2k that changed but the LCL/Lazarus didn't, which they have corrected somewhat.

 But really, I wouldn't be loading those controls like that. A Database handles the load while the GRID used on the
database basically shows you groups of data.

 
 If you want to continue with the ListBox, then load all your data into a TStringList using basically the same functions
as you are now, use a TlistBox to show groups of data.. In otherwords, the ListBox is just for scrolling through the StringList
you have listed.
 
 Put a couple of buttons somewhere around the Listbox used to page the contents of the list box, each time you page up or
page down, you reload the list box from the contents of the stringlist. use a group index.

 For example the group index could be in segments of 10 and the list box only shows 10 items each time. When you page
up/down, you reload the list box with a fresh list of 10 items only..

  I think you get the picture, if not I can draft you out a simple example.
The only true wisdom is knowing you know nothing

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Locked in a Loop Don't understand why
« Reply #20 on: May 27, 2019, 03:57:52 am »
@ jamie

Thanks for the offer. Actually I'm thinking of abandoning the project. I think the best way of doing it is with a SQLLite but the learning curve on a database is pretty steep and I haven't been able to find a good example to start with.

 
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

440bx

  • Hero Member
  • *****
  • Posts: 6462
Re: Locked in a Loop Don't understand why
« Reply #21 on: May 27, 2019, 04:57:08 am »
Actually I'm thinking of abandoning the project. I think the best way of doing it is with a SQLLite but the learning curve on a database is pretty steep and I haven't been able to find a good example to start with.
Here is a suggestion which I don't really know how well it fits your requirements but, I am under the impression that you're trying to "massage" a whole lot of data until you get it the way you need it.  If that is correct, you'd probably be well off installing a SQL based database system (such as Postgres), create simple programs to load the data into database tables and use SQL, first to see how all that data fits together and, finally generate an output file that is clean, easy to parse and, just the way you want it using SQL.  Once you're there, writing a program that uses a clean, well organized and complete data file is often easy.

SQL is a powerful language, you can do in a few lines what would take hundreds, even thousands sometimes, of lines of Pascal code.

Yes, you'll spend a month (maybe a little more) getting a reasonable idea of how to use SQL but, overall, it's easy, interactive and, you can _see_ the results quickly.  You can try a lot of things until you find the one way that works best. 

A lot of programmers get trapped in the "when all you've got is a hammer, everything looks like a nail".  Don't write code you don't need.  Between AWK, SQL and a few custom little FPC programs you'd surprised how easily, quickly and little effort it may require to get to the final product.

Moral of that somewhat "lecture" is, add tools to your toolbox.  You're having a hard time because of the method you've chosen.  Don't give up on the goal, give up on the method.  Time for a better one.

HTH.



FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Locked in a Loop Don't understand why
« Reply #22 on: May 27, 2019, 05:49:50 am »
Thank you for the advice. I'm sure SQL is the way to go. Have to give it some thought.
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

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Locked in a Loop Don't understand why
« Reply #23 on: May 27, 2019, 07:00:49 pm »
Thank you for the advice. I'm sure SQL is the way to go. Have to give it some thought.
Others mentioned TStringList before though, that works like TListBox but doesn't have the max limitation (ok there is but somewhere at the 4GB or much more depending on OS and if your app fully supports 64-bit). You just have to create it in code and seeing its contents will take some extra effort and a different visual component. But it's almost definitely the fastest to do workaround.
« Last Edit: May 27, 2019, 07:02:57 pm by User137 »

 

TinyPortal © 2005-2018