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 » ArrayCtrl - convert String
ArrayCtrl - convert String [message #37458] Tue, 09 October 2012 08:53 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hi guys,
I have a little problem with my arractrl.

I'm trying to read a csv file... I used Split() function to store lines into array. Here the code:
while(!in.IsEof()) 
    {
		Vector<Value> w;
		String line = in.GetLine();
		Vector<String> v = Split(line, ";",false);
		for(int i=0; i<v.GetCount(); i++)
			w.Add(v[i]);
		array.Add(w);
    }


Now I have a trouble converting array column from String to double Sad

I tryed to .SetConvert(Single<ConvDouble>()); without success
struct ConvDouble : Convert
{
	Value Format(const String &q) const
	{
		return q.IsNull ? Null : UPP::Format("%.2d", q);
	}
};


so, what's the right way to convert String to double ( that allow me to use array.Get(),GetColumn() and Set() to compute ) ?!

Regards,
Matteo
Re: ArrayCtrl - convert String [message #37465 is a reply to message #37458] Tue, 09 October 2012 14:39 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Hello,

to convert from String to Double, override the function Scan.

for example:
struct ConvDouble : Convert
{
	Value Format(const String &q) const
	{
		return q.IsNull ? Null : UPP::Format("%.2d", q);
	}

	Value Scan(const Value& text) const
	{
                
		String s = text;      //
		return ScanDouble(s); // Not tested. 
	}
};


omari.


regards
omari.
Re: ArrayCtrl - convert String [message #37496 is a reply to message #37465] Thu, 11 October 2012 09:44 Go to previous message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
oh nice... Thanks!
Previous Topic: Callbacks mechanism doesn't handle overloaded functions?
Next Topic: [HttpRequest] undefined identifier
Goto Forum:
  


Current Time: Thu Mar 28 19:31:28 CET 2024

Total time taken to generate the page: 0.02644 seconds