Access lines of a TStringList

Hello all!

I have a question regarding Borland C++ Builder. I am writing a program that needs to access individual lines of a TStringList and turn each line into an AnsiString. Is there a method of either TStringList or AnsiString similar to getline() but for TStringLists? Or is there another method in some other class that allows one to do this?

Thanks in advance!
I figured out the problem (kind of a roundabout way though). For anyone that needs to know how to do this, I put the steps below:

1. Make a memo (if you need it to be invisible, then you can do that.)
2. Add strings to the TStringList of the memo (via anything. Typing, file import, etc.)
3. Use the code below to turn up the number of lines in the TStringList in integers:

Memo1->Lines->Count;

4. Access each individual line using this code:

Memo1->Lines->Strings[NUMBER OF LINE]

In which the Memo1 is the name of the memo and NUMBER OF LINE is the number of the string you are trying to access.
The memo is unnecessary, as you can access the lines the same way in the original string list (StringList->Strings[index]).
Okay, I think I tried that before, but I'll give it another go now that I understand it a little better. Thanks for the reply!

Edit: Yup, Athar you're correct, you don't need to use the memo.
Last edited on
Topic archived. No new replies allowed.