Apr 26, 2010 at 12:58pm UTC
sorry,
I just mean how could I convert these two "Strings" into integer values, so that they can be compared to see if a string1 is higher than string2?
I need to extract the digits eg: 003 and 103 -(removing the "." from each)
then a comaprison against both numeric values retrieved.
I dont know how else to elaborate that
Apr 26, 2010 at 1:21pm UTC
characters, just like integers - have values.
You compare the strings contents to see which has a higher value - in this case 1.0.3 would be.
if (version003 < version103)
Is equal to TRUE.
Just tried it... It works.
Last edited on Apr 26, 2010 at 1:23pm UTC
Apr 26, 2010 at 2:03pm UTC
that doesnt work for all cases...
this does
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
bool Update::IsVersionHigher(wxString vnumber1, wxString vnumber2)
{
long * version=new long [3];
version[0] = vnumber1[0]-48;
version[1] = vnumber1[2]-48;
version[2] = vnumber1[4]-48;
long * version2 = new long [3];
version2[0] = vnumber2[0]-48;
version2[1] = vnumber2[2]-48;
version2[2] = vnumber2[4]-48;
if ( ( (version[0]*10000) + (version[1]*100) + version[2] ) < ( (version2[0]*10000) + (version2[1]*100) + version2[2] ) )
{
return true ;
}
else {return false ;}
}
Last edited on Apr 26, 2010 at 2:04pm UTC