Solved

Best way to access a list of items?

Posted on 1998-08-10
1
117 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
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now