contents   index   previous   next



Clib.memcmp()

syntax:

Clib.memcmp(buf1, buf2[, maxLen])

where:

buf1 - first buffer or byte array to use in comparison.

 

buf2 - second buffer or byte array to use in comparison.

 

maxLen - maximum number of characters to compare.

 

return:

number - negative, zero, or positive according to the following rules:

 

< 0 if str1 is less than str2

= 0 if str1 is the same as str2

> 0 if str1 is greater than str2

description:

This method compares the first maxLen bytes of buf1 and buf2. If the parameter maxLen is not specified, then maxLen is the smaller of the lengths of buf1 and buf2. If maxLen is specified and one of the arrays is shorter than the specified length, then ScriptEase treats length of the shorter array as being maxLen.

 

The example function checks to see if the shorter string is the same as the beginning of the longer string. This method differs from Clib.strcmp() in that this function returns true if passed the strings "foo" and "foobar", since it only compares characters up to the end of the shorter string.

 

see:

Clib.strcmp()

 

example:

function MyStrCmp(string1, string2)

{

   var len = Clib.min(string1.length,

                      string2.length);

   return(Clib.memcmp(string1, string2, len) == 0); 

}

 


Clib.memcpy()