Core Function BinaryJoin

From Sputnik Wiki
Jump to: navigation, search
BinaryJoin( <separator>, <values>, <start>, <count> )

Contents

Description

Join together a ton of Binary variables in an extremely fast and efficient way.

Parameters

separator

A value to use as the separator.

values

One of more values to be joined.

To send more than one value create an array()

start

Optional; Position of the first array element in values to use.

length

Optional; Number of elements in values to use.

Return Value

Success: Returns a new binary variable.

Failure: Returns empty binary variable.

Remarks

Use NULL as the separator to join with an empty separator.

This function is generic similar to the arrays Join() function so you can use anything you want in as the parameters and it will be converted into binary on the fly.

Example

// Create some binary variables
$binary1 = Pack("A*", "The");
$binary2 = Pack("A*", "quick");
$binary3 = Pack("A*", "FoX");
// Create a separator
$binarySep = Pack("A*", " ");
 
// Join them together
my $Joined = BinaryJoin($binarySep, array($binary1, $binary2, $binary3));
 
// Print result
say BinaryExpand($Joined);
// Prints:
// 54 68 65 20 71 75 69 63 6B 20 46 6F 58 -- -- -- The quick FoX

Same as above but this time with no separator

// Create some binary variables
$binary1 = Pack("A*", "The");
$binary2 = Pack("A*", "quick");
$binary3 = Pack("A*", "FoX");
 
// Join them together
my $Joined = BinaryJoin(null, array($binary1, $binary2, $binary3));
 
// Print result
say BinaryExpand($Joined);
// Prints:
// 54 68 65 71 75 69 63 6B 46 6F 58 -- -- -- -- -- ThequickFoX

Since this is a generic function like the array Join() function you can use anything as the parameters and it will be converted into binary on the fly for example here we use a string for the separator

// Create some binary variables
$binary1 = Pack("A*", "The");
$binary2 = Pack("A*", "quick");
$binary3 = Pack("A*", "FoX");
 
// Join them together
my $Joined = BinaryJoin(",", array($binary1, $binary2, $binary3));
my $Joined2 = BinaryJoin("?!", array($binary1, $binary2, $binary3));
 
// Print result
say BinaryExpand($Joined);
say BinaryExpand($Joined2);
// Prints:
// 54 68 65 2C 71 75 69 63 6B 2C 46 6F 58 -- -- -- The,quick,FoX
// 54 68 65 3F 21 71 75 69 63 6B 3F 21 46 6F 58 -- The?!quick?!FoX
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox