?
Solved

Comma seperated string

Posted on 2004-04-01
1
Medium Priority
?
189 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 1000 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

Industry Leaders: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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