Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 3rd, 2004, 12:52 AM
talonsmail talonsmail is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 talonsmail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
comparing data in an array

Hi I have a csv containing postcodes like this:

"Perth", 6666
"Melbourne", 7777
\
etc.

I have loaded these values into an array like so.

var
i : integer;
s : string;
my_postcodes: TStringList;

begin
assign(myfile,'postcodes.csv');
reset(myfile);
my_postcodes := TStringList.Create;

while not eof(myfile) do
begin
readln(myfile, line);
my_postcodes.DelimitedText := line;


for i := 0 to my_postcodes.Count - 1 do
begin
s := my_postcodes.Strings[i];
s := my_postcodes[i]; // Same as previous line
end;

end;


Does anyone know how I can choose a certain field from the array i.e. If i want to know the postcode for perth, how do I extract that information from the array and put it into a variable. I am really stuck!! Any help appreciated.

Reply With Quote
  #2  
Old June 3rd, 2004, 05:03 AM
szgabor szgabor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Hungary
Posts: 43 szgabor User rank is Lance Corporal (50 - 100 Reputation Level)szgabor User rank is Lance Corporal (50 - 100 Reputation Level)szgabor User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 12 h 28 m 51 sec
Reputation Power: 10
For arrays you need to do almost everything yourself. Search can be done using a cycle. If you need to insert an item somewhere, you have to increase the array's length, shift all the items forward above the desired position, and finally put the new item in the array. Sounds a bit tough, but actually isn't.

Reply With Quote
  #3  
Old June 3rd, 2004, 10:54 AM
roque69 roque69 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 5 roque69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello.

If you use a TStringList you have the IndexOf and the Find methods to locate in the list.

Miguel

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > comparing data in an array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap