Breaking up a string array

Please discuss general Delphi programming topics here.

Breaking up a string array

Postby Christine123 » May 31st, 2007, 3:06 am

I want to first thank for that very promt reply on my first question. For all the programmers out there who know what they're doing I was wondering how you would tackle this task.

I have read a Text File and saved each line into an array of string

for example here's several lines
INTC,-0.73,1050601
INTC,0.37,1050601
INTC,0.62,1050602
INTC,0.47,1050602
INTC,0.04,1050602

There are 3 pieces of data seperated by commas. What I want is to get each piece of data into it's own array. Ideas?

Thanks
Christine123
Junior Member
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Christine123 » May 31st, 2007, 4:57 am

please do not reply to this. I figured it out. Thanks
Christine123
Junior Member
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Johnny_Bit » May 31st, 2007, 3:57 pm

Unfortunately I do want to reply, just to inform you that it is a common custom to actually inform how you solved your problem. That way whenever somebody new would come here, asking for the same thing he'll find our answer, and that is good thing to do.
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Christine123 » May 31st, 2007, 9:57 pm

I can completely understand.

Basically what I did was I ran a for loop of the string to search where the commms where. Basically when I new that I knew that I could define the data types like such

Data1, low(array) to comma1 - 1;
Data2, comma1 + 1 to comma2 - 1.

Then I used the StrToInt function to convert the strings into int values.

Hope that helps
Christine123
Junior Member
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Christine123 » May 31st, 2007, 10:02 pm

on the same note. How would I do this.

I'm reading a book to help me with this langauge. When you define an object you write. TAnimal.Create, and then when you are done with it you destroy in.

In my example I have an array of string. Then I make another array called array of integer. I have no use for the array of string anymore. Should I destory it? If so how would I do that?


Thanks
Christine123
Junior Member
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Kambiz » May 31st, 2007, 10:23 pm

You should only destroy objects. Arrays are not object in Delphi.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron