View Full Version : c++ wxwidgets inch to metric questions.

Jonas thomas
October 21st, 2010, 05:02 AM
I'm having a brain cramp here.

I have a string that I want to convert from inch to metric.
The standard is to say something like 1.5 inch but I also want to allow

I get an compiler error on the """
Is there an easy way around that? or do I need to go char by char '"'

wxString dimensionString = wxString(value).MakeLower();
// Need to convert inch to internally stored metric
// todo
// This could be improved to do conversions such as
// 1 Inch or 1 5/8" or 5/16 inch

if dimensionString.Contains(_T("inch")))||dimensionString.Contains(_T(""")))

October 21st, 2010, 05:05 AM
put a \ before the " you want in your string

if (
dimensionString.Contains(_T("inch")) ||
) length *= 25.4;

Soz had to update cuz you got your braces wrong as well.
I always split complicated boolean expressions up like I did above to help me spot that kind of problem so wuz not attuned to the way you done it there ;)

Jonas thomas
October 21st, 2010, 05:15 AM
You'd think that /" would work... That's generating a bunch of really interesting errors. If I go "asdf" instead of """ it's generating errors as well... Need to look at this in the morning after some zzz's thanks.. anyway.

put a \ before the " you want in your string

if dimensionString.Contains(_T("inch")))||dimensionString.Contains(_T("\"")))

Jonas thomas
October 21st, 2010, 05:24 AM
Then again...
This will compiles

if ((dimensionString.Contains(_T("inch")))||(dimensionString.Contains(_T("asdf"))))

Change to this

if ((dimensionString.Contains(_T("inch")))||(dimensionString.Contains(_T("\""))))

works... It helps to have the \ in the correct direction.... Duhhhh...