Core Function BinaryMid

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Return Value)
Line 27: Line 27:
 
Success: Returns a new binary variable.
 
Success: Returns a new binary variable.
  
Failure: Returns 0.
+
Failure: Returns null.
  
 
=== Remarks ===
 
=== Remarks ===

Revision as of 14:45, 29 August 2013

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 null.

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