THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2012 at 10:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I'm going through the string class and writing out small working examples of each string function. So I don't have to figure them out while I'm in the middle of a project. And I'm not getting the expected results from ComparePart() & RelCompare();
They are producing strange values(36&100,000). When they should be producing zero(I think).
Here's what I've got.
I'm comparing two strings with the same values then running each of the string functions on them:
String s1 = "Hello there"; //The string we will work on
LONG len = s1.GetLength(); //Get the length of the string
LONG Fpos = NULL; //This will hold the position of a string in the text
LONG Lpos = NULL; //This will hold the position of a string in the text
Bool firstfound = s1.FindFirst("ll",&Fpos,1); //Finds the first occurance of "ll" and stores it's position in the string in "Fpos"
Bool lastfound = s1.FindLast("e",&Lpos,-1); //Finds the last occurance of "e" and stores it's position in the string in "Lpos"
GePrint("First Position in the string= " + LongToString(Fpos));
GePrint("Last Position in the string= " +LongToString(Lpos));
String sub = s1.SubStr(2,2); //Gets "ll" characters in the word Hello
GePrint("SubString= " + sub);
String s2 = "Hello there"; //A second string we'll use to compare to the original string
LONG comp = s1.Compare(s2); //Compares two strings and returns zero if the two strings are exactly the same (Case sensitive)
//If the second string is shorter than the original. It will return positive values
//If the second string is longer than the original. It will return negative values
GePrint("StringsEqual?: " + LongToString(comp));
LONG lexcomp = s1.LexCompare(s2); //Compares two strings and returns zero if the two strings are exactly the same (NOT case sensitive)
//If the second string is shorter than the original. It will return positive values
//If the second string is longer than the original. It will return negative values
GePrint("StringsEqual?: " + LongToString(lexcomp));
LONG comppart = s1.ComparePart(s2, 2, 2); //Returns 36!?<--------------Why not zero?
//LONG comppart = sub.Compare(scopy); //Also Returns 36!?
GePrint("PartEqual?: " + LongToString(comppart));
LONG relcomp = s1.RelCompare(s2); //Returns 100,000!?<-------Why not zero?
GePrint("RelPartEqual?: " + LongToString(relcomp));
I'm wondering why I'm not getting zero for those two functions as expected?
And what those numbers(36 & 100,000) mean?
-ScottA