Board index » cppbuilder » Manipulating strings in TStringList

Manipulating strings in TStringList

Hello,

let's say i have a stringlist MyStringList containing the following:

VERSIE=4.00
ICTYPE=27C4001
STATUS=NORMAL

I want to manipulate each string, resulting in the part before the '=' sign
like:

VERSIE
ICTYPE
STATUS

Am i allowed to treat each string like an ansistring. so i can use something
like this:

// remove "=4.00" from 1st string in stringlist
MyStringList->Strings[0].Delete(5, 100);

Obviously i tried the above, but it does not work. It doesnt give a compile
error, but the code simply has no affect. Am i calling the string by value ?

Grtz.. Johan Schuld

 

Re:Manipulating strings in TStringList


the function delete from an ansistring returns the new string! you have to
do something like that
MyStringList->Strings[0] = MyStringList->Strings[0].Delete(5, 100);

hope it helps :)

"Johan Schuld" <jo...@adesys.ditmoetweg.nl> schrieb im Newsbeitrag
news:a7uth6$dhe$1@news1.xs4all.nl...

Quote
> Hello,

> let's say i have a stringlist MyStringList containing the following:

> VERSIE=4.00
> ICTYPE=27C4001
> STATUS=NORMAL

> I want to manipulate each string, resulting in the part before the '='
sign
> like:

> VERSIE
> ICTYPE
> STATUS

> Am i allowed to treat each string like an ansistring. so i can use
something
> like this:

> // remove "=4.00" from 1st string in stringlist
> MyStringList->Strings[0].Delete(5, 100);

> Obviously i tried the above, but it does not work. It doesnt give a
compile
> error, but the code simply has no affect. Am i calling the string by value
?

> Grtz.. Johan Schuld

Other Threads