* * *

Author Topic: Simple Tstringlist question [SOLVED]  (Read 425 times)

SteveSS

  • New member
  • *
  • Posts: 26
Simple Tstringlist question [SOLVED]
« on: May 17, 2018, 11:30:43 am »
Hi All.  I am a fan of csv files for fairly small data size programs.  I have never tried this but I am sure there is a very simple answer.  If a record in a sorted stringlist, loaded from a csv file contains:

KKK_ABC,123,456,999,DDD,

will tstringlist.find('KKK_ABC',index) locate the record or do you have to supply the whole record content for the find function to work?

Thanks all,

Steve
« Last Edit: May 17, 2018, 12:10:30 pm by SteveSS »

HeavyUser

  • Full Member
  • ***
  • Posts: 157
Re: Simple Tstringlist question
« Reply #1 on: May 17, 2018, 11:38:27 am »
The complete string of the record is required for find to work or you need to write your own search function.

Thaddy

  • Hero Member
  • *****
  • Posts: 6898
Re: Simple Tstringlist question
« Reply #2 on: May 17, 2018, 12:04:33 pm »
Indeed, because only the full record can give a *full* match in the case of a simple lightweight stringlist.
But we have TBufDataset, which works also with partial matches like you describe and still quite light weight.
We have also the generic lists (in e.g. fgl, fcl-stl and rtl-generics) which you can also use but also require to write an enumerator for partial matches.
Depends in your exact requirements.

Since I understand you are basically requiring a lightweight database functionality, I suggest you try TBufDataset.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

SteveSS

  • New member
  • *
  • Posts: 26
Re: Simple Tstringlist question
« Reply #3 on: May 17, 2018, 12:06:53 pm »
Thanks HU - I new it would be a simple answer.  I was rather hoping for the other one but I guess I will have to come up with a different solution.

Steve

SteveSS

  • New member
  • *
  • Posts: 26
Re: Simple Tstringlist question SOLVED
« Reply #4 on: May 17, 2018, 12:09:50 pm »
Thanks to you Thaddy as well.  Will have a play around with BufDataset and see if it provides a simple solution.

Steve

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus