Core Function BinaryInsert

From Sputnik Wiki
Revision as of 01:36, 21 April 2012 by UberFoX (Talk | contribs)
Jump to: navigation, search
BinaryInsert( <binary-array>, <binary-array2>, <index> )

Contents

Description

Insert a binary variables data into another binary variable at a specific location.

Parameters

binary-array

The binary variable to insert data to.

binary-array2

The binary variable to copy data from.

index

The index position to insert at.

Return Value

Success: Returns 1.

Failure: Returns 0.

Remarks

This modifies the original binary variable and does not return a copy.

If the "Overwrite" param is not used or is 0 the binary variable binary-array2 will be inserted into binary-array and increase the size of binary-array.

However if "Overwrite" param above 0 the binary variable binary-array2 will be inserted into binary-array and the size of binary-array will not be increased instead binary-array2 data will overwrite data in binary-array at the given location.

Example

$binary1 = Pack("z0", "111 333");
$binary2 = Pack("z0", " 222");
BinaryInsert($binary1, $binary2, 3);
$k = 0;
Foreach ($binary1 as $i)
{
	println( DecPad($k, 3) . " Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) );
	$k++;
}
println( Unpack("z0", $binary1) ); // Prints: 111 222 333
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox