0

I just inherited a Delphi 5 PASCAL code project (Windows app). I have to extract a string with multiple words and put these words in a TListBox. One word per line. How can I extract these words?

I was referred to this post as a possible answer Split a string into an array of strings based on a delimiter. However, it was not because the string contains one, two, or more randomly spaces to separate the words in the string. In addition, I have to use the old Delphi 5 compiler which does not have the built-in Split function.

I tried the answers with Delphi 5. It did not work. There was no available inline TStrings.CommaText nor TStrings.Delimiter. Please advise. Thanks!

Hai Vien
  • 1
  • 2
  • I was referred to this post as a possible answer Split a string into an array of strings based on a delimiter. However, it was not because the string contains one, two, or more randomly spaces to separate the words in the string. In addition, I have to use the old Delphi 5 compiler which does not have the built-in Split function. – Hai Vien Oct 03 '17 at 16:18
  • 2
    I don't think you read all the answers in that link. – J... Oct 03 '17 at 16:24
  • Also read help about `TStrings.CommaText` – MBo Oct 03 '17 at 16:35
  • 1
    The purpose of excersises is to learn. Don't be a copy-paste programmer. Do not search for ready made functions, but make your own. What is the string from which you need to extract the words? It is a series of non-space characters that form words and space characters that separate the words. Traverse the characters of the long string one by one. If space, skip. If not space, collate into a word until a space is found. Add complete words to a suitable list. Repeat until end of string. – Tom Brunberg Oct 03 '17 at 20:17
  • You most certainly can do it in D5. Use `StringReplace` and `TStringList` together. – Dúthomhas Oct 08 '17 at 06:18

0 Answers0