Home » Community » Newbie corner » docEdit /lineEdit to array
Re: docEdit /lineEdit to array [message #38338 is a reply to message #38309] |
Tue, 11 December 2012 14:26   |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
Hi!
I don't know if there's a ready function for that in U++.
But this is how I would do this:
1) Read the full contents of the docedit into a String.
2) Create a function to go concatenating characters until it finds \n. Then it adds this line to the array. Do this until the_string.GetLegnth() is reached. At the end return the array.
Here's the sample code:
// Adds each line of a DocEdit to an array
Array<String> DocEdit2Array(DocEdit& d)
{
String s = d.GetData();
Array<String> result;
String line = "";
for(int i = 0; i < s.GetLength(); i++)
{
if(s[i] != '\n')
line += s[i];
else
{
result.Add(line);
line="";
}
}
result.Add(line);
return result;
}
// Event of button click to test the function
void test::ButtonClicked()
{
Array<String> a = DocEdit2Array(docedit1);
for(int i=0; i < a.GetCount(); i++)
{
DUMP(a.At(i));
}
}
[Updated on: Tue, 11 December 2012 14:30] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Aug 24 14:13:28 CEST 2025
Total time taken to generate the page: 0.04883 seconds
|