Core Function BinaryCompare

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
<pre>
 
<pre>
BinaryCompare( <binary-array>, <binary-array2>, <length> )
+
BinaryCompare( <binary-array>, <binary-array2>, <offset>, <length> )
 
</pre>
 
</pre>
  
Line 17: Line 17:
 
The a binary variable to use.  
 
The a binary variable to use.  
  
==== length ====
+
==== offset ====
  
Optional; Maximal number of bytes to compare.
+
Optional; Start position to begin comparing. (0 = first byte)
  
Default: Length of the smallest array
+
If the start is a negative value the byte position will work backwards from the length of the shortest binary variable.
 +
 
 +
==== length ====
  
If you enter a number too high it will be shortened to smallest array
+
Optional; Maximal number of bytes to compare. By default the entire remainder of the shortest binary variable.
  
If you enter under zero it will change to zero
+
If length  is given and is negative, then the compare will begin with many bytes will be omitted from the end of shortest binary variable (after the offset position has been calculated when a offset is negative).
  
If zero is the length it will do a compare as if you had ignored this parameter
+
If offset denotes the position of this truncation or beyond, failure will be returned ( -2 ).
  
 
=== Return Value ===
 
=== Return Value ===

Revision as of 13:59, 27 September 2013

BinaryCompare( <binary-array>, <binary-array2>, <offset>, <length> )

Contents

Description

Compare two binary variables.

Parameters

binary-array

The a binary variable to use.

binary-array2

The a binary variable to use.

offset

Optional; Start position to begin comparing. (0 = first byte)

If the start is a negative value the byte position will work backwards from the length of the shortest binary variable.

length

Optional; Maximal number of bytes to compare. By default the entire remainder of the shortest binary variable.

If length is given and is negative, then the compare will begin with many bytes will be omitted from the end of shortest binary variable (after the offset position has been calculated when a offset is negative).

If offset denotes the position of this truncation or beyond, failure will be returned ( -2 ).

Return Value

-1 if binary1 is less than binary2

1 if binary1 is greater than binary2

0 if they are equal.

-2 on error

Remarks

None.

Example

my $Binary1 = Pack("A*", "Hello world!!!");
my $Binary2 = Pack("A*", "Hello world!!!");
 
If( BinaryCompare($Binary1, $Binary2) == 0 )
{
	println("Both binary variables contain the same data");
}
Else
{
	println("No match");
}
 
println("");
println("Lets try again now now that one was changed");
my $Binary1 = Pack("A*", "Test");
If( BinaryCompare($Binary1, $Binary2) == 0 )
{
	println("Both binary variables contain the same data");
}
Else
{
	println("No match");
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox