Solved

Best way to access a list of items?

Posted on 1998-08-10
1
121 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 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