Solved

Comma seperated string

Posted on 2004-04-01
1
180 Views
Last Modified: 2010-04-05
I read a text file using TStringlist,

The file contains the following string(s)

PART,1572315-111C, *,*,1,*,1572315-111C*,7

* This is where i need to add a string. e.g.

PART,1572315-111C,ss1,ss2,1,ss3,1572315-111C.ccd,7



0
Comment
Question by:Anton007
1 Comment
 
LVL 11

Accepted Solution

by:
shaneholmes earned 250 total points
ID: 10738355

 You can parse a string with the following code:

// interate through the list as such
 for I:= 0 to MyStringList.Count - 1 do

 // you can parse each string as such
  for J:= 1 to Length(MyStringList[I]) do
  //you can find the insert positon as such
   if MyStringList[I][J] = '*' then


 //or you can check for the position of a character as such
  if Pos('*', MyStringList[I]) <> 0 then


However, this is what you are most likely looking for:

 You can replace a substring of a string with:

 tmp:= MyStringList[I];
 StringReplace(tmp, '*', MyNewString, [rfReplaceAll]);
 MyStringList[I]:= tmp;


Shane
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now