Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
lectus is currently offline  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

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Why isn't the data getting inserted?
Next Topic: sessions in Skylark
Goto Forum:
  


Current Time: Sun Aug 24 20:23:27 CEST 2025

Total time taken to generate the page: 0.04901 seconds