On 14/06/2013 at 07:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi Folks,
I'm trying to compare two string values and return a LONG value based on whether the string's are the same or not. Example below:
std::vector< String > MyVectorStrings; // 6 vectors, 1-5 with strings (0 is empty)
MyVectorStrings[1] = "StringOne"; etc
LONG DataChecker(String MyString)
{
LONG Value = 0;
if(MyString.operator==("StringOne"))
{
Value= 1;
return Value;
}
if(MyString.operator==("StringTwo"))
{
Value = 2;
return Value;
}
return Value; // should return 0 if nothing above is true
}
Bool MyFunction(void)
{
LONG value = 0;
for(int i = 1; i <= 5;) // vector[0] is empty, start at 1
{
value = DataChecker(MyVectorStrings[i]);
GePrint(LongToString(value)); // everything bar the first vector returns 0. This is not correct.
i++;
}
return TRUE;
}
The above is the custom function I run from inside a loop, with a mock example of the loop below it. The string is taken from a vector of String's, one at a time through the loop using the 'i' value.
I've tried with the string operator "if's" inside the loop too, but it didn't work either. I simply cannot get anything passed the first "if" statement to return the correct value. But I know the strings are correct, I've printed them out - many times over.
Is there something buggy with this operator? The MyString.compare() does the same thing too.
WP.