 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rory Walsh Guest
|
Posted: Mon Dec 05, 2005 8:36 pm Post subject: string problem.. |
|
|
Can anyone see why I only get the first five words of the string to
appear when I run this function?
function....
{
TMemo* temp;
temp = new TMemo(Form1);
temp->Top =600;
temp->Visible = false;
temp->Parent = Form1;
temp->Text = ";scrollbar Name, width, height, top, left, kind,
min, max";
ShowMessage(temp->Lines->Strings[0]);
TStringList* words = new TStringList;
words->Delimiter = ',';
words->DelimitedText = temp->Lines->Strings[0];
for(int i=0;i<words->Count;i++)
{
ShowMessage(words->Strings[i]);
}
}
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Mon Dec 05, 2005 8:55 pm Post subject: Re: string problem.. |
|
|
Rory Walsh <rorywalsh (AT) ear (DOT) ie> wrote:
| Quote: |
Can anyone see why I only get the first five words [...]
|
TMemo will break the lines according to what it visually
displays. If you change it's Width, say to 500, you'll get
close to the expected results.
In the alternative, replace:
| Quote: | words->DelimitedText = temp->Lines->Strings[0];
|
with:
words->DelimitedText = temp->Text;
If you look closely at the results, you'll see that part of
the string is broken where you don't expect it. ';scrollbar
Name' is seperated into 2 words because a space is also
considered a delimiter.
If you format the string as such:
"scrollbar Name","width","height","top","left","kind","min","max"
the rest of the string can also include any of the several
other delimiters and TStringList's CommaText method will deal
with it nicely.
To help facilitate formatting the string, look at
AnsiQuotedStr.
~ JD
|
|
| Back to top |
|
 |
Rory Walsh Guest
|
Posted: Mon Dec 05, 2005 10:09 pm Post subject: Re: string problem.. |
|
|
Cheers, I never would have figured that out! I was also using
temp->Lines->Strings[0]; as I have more than one line to parse this way.
Thanks for the help,
Rory
| Quote: | TMemo will break the lines according to what it visually
displays. If you change it's Width, say to 500, you'll get
close to the expected results.
In the alternative, replace:
words->DelimitedText = temp->Lines->Strings[0];
with:
words->DelimitedText = temp->Text;
|
|
|
| Back to top |
|
 |
Liz Albin Guest
|
Posted: Tue Dec 06, 2005 2:18 am Post subject: Re: string problem.. |
|
|
On Mon, 05 Dec 2005 20:36:45 +0000, Rory Walsh wrote:
| Quote: | appear when I run this function?
|
is wordwrap on?
is there a reason you only go after the first line?
--
liz
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|