Core Function BinaryMid

From Sputnik Wiki
Revision as of 17:40, 19 November 2011 by UberFoX (Talk | contribs)
Jump to: navigation, search
BinaryMid( <binary-array>, <start>, <length> )

Contents

Description

Create a binary variable by extracting a number of bytes from another binary variable.

Parameters

binary-array

The binary variable to use.

start

Position to start from.

length

Optional; How many bytes to copy.

Default is all remaining bytes;

Return Value

Success: Returns a new binary variable.

Failure: Returns 0.

Remarks

This does not modify the original.

Example

Copy from "brown" to end of the data:

$binary = Pack("z0", "The quick brown FoX");
$binary2 = BinaryMid($binary, 10);
println("b1: " . Unpack("z0", $binary));
println("b2: " . Unpack("z0", $binary2));

Copy just the "FoX" part example:

$binary = Pack("z0", "The quick brown FoX");
$binary2 = BinaryMid($binary, 16, 3);
println("b1: " . Unpack("z0", $binary));
println("b2: " . Unpack("z0", $binary2));
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox