Solved

Best way to access a list of items?

Posted on 1998-08-10
1
122 Views
Last Modified: 2010-04-04
I need to be able to save a list of about 300 - 600 filenames(names will get added and removed). I'll need to be able to search this list for matching files. What would be the best method to get this done? Save the filenames to a text file and then load them into an array, use a database, ini file, or what. I'm not sure which is best.

Thanks
0
Comment
Question by:evel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1361854
Hi,
Use a TStringList, it's easiest.

var
  MyList: TStringList;
  iIndex: iIndex;
.
  MyList := TStringList.Create;
  MyList.Sorted := True; // optional
  MyList.Add( Filename1 );
  MyList.Add( Filename2 );
  MyList.Add( Filename3 );
  for iIndex := 1 to MyList.Count-1 do begin // only on sorted list!!!
    if CompareText( MyList[ iIndex ], MyList[ iIndex - 1 ] ) = 0
    then ... // found duplicate!
  end;
  MyList.SaveToFile( 'MyFiles.txt' ); // save list to file
  MyList.LoadFromFile( 'MyFiles.txt' ); // load list from file
  MyList.Free; // destroy list

That's it!

/// John

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question