Core Function BinaryCompare

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Return Value)
(Example)
Line 34: Line 34:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
my $Binary1 = Pack("z0", "Hello world!!!");
+
my $Binary1 = Pack("A*", "Hello world!!!");
my $Binary2 = Pack("z0", "Hello world!!!");
+
my $Binary2 = Pack("A*", "Hello world!!!");
  
If( BinaryCompare($Binary1, $Binary2) )
+
If( BinaryCompare($Binary1, $Binary2) == 0 )
 
{
 
{
 
println("Both binary variables contain the same data");
 
println("Both binary variables contain the same data");
Line 48: Line 48:
 
println("");
 
println("");
 
println("Lets try again now now that one was changed");
 
println("Lets try again now now that one was changed");
my $Binary1 = Pack("z0", "Test");
+
my $Binary1 = Pack("A*", "Test");
If( BinaryCompare($Binary1, $Binary2) )
+
If( BinaryCompare($Binary1, $Binary2) == 0 )
 
{
 
{
 
println("Both binary variables contain the same data");
 
println("Both binary variables contain the same data");

Revision as of 13:35, 27 September 2013

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

Contents

Description

Compare two binary variables.

Parameters

binary-array

The a binary variable to use.

binary-array2

The a binary variable to use.

Return Value

-1 if binary1 is less than binary2

1 if binary1 is greater than binary2

0 if they are equal.

NULL 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