Solved

Comma seperated string

Posted on 2004-04-01
1
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 355
can't find the executable in Simulator 1 112
How to Get Images From Server using App Tethering 11 42
shape, triangle, dbctrlgrid 3 31
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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

763 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