Core Function BinaryMid

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
  
Create a binary variable by extracting a number of bytes from another binary variable.
+
Create a binary variable by extracting a number of bytes from another binary variable.
  
 
=== Parameters ===
 
=== Parameters ===

Revision as of 08:26, 12 November 2011

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