Solved

Comma seperated string

Posted on 2004-04-01
1
179 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

11 Experts available now in Live!

Get 1:1 Help Now