Solved

Comma seperated string

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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