Core Function BinaryPush

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> BinaryPush( <binary-array>, <byte> ) </pre> === Description === Add a byte to the end of a binary variable. === Parameters === ==== binary-array ==== The binary varia...")
 
(Example)
Line 30: Line 30:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$binary = Pack("z0", "One")
+
$binary = Pack("z0", "One");
BinaryPush($binary, Asc(" "))
+
BinaryPush($binary, Asc(" "));
BinaryPush($binary, Asc("T"))
+
BinaryPush($binary, Asc("T"));
BinaryPush($binary, Asc("w"))
+
BinaryPush($binary, Asc("w"));
BinaryPush($binary, Asc("o"))
+
BinaryPush($binary, Asc("o"));
println( "'" . Unpack("z0", $binary) . "'" ) ; Prints: One Two
+
println( "'" . Unpack("z0", $binary) . "'" ); // Prints: One Two
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 17:54, 19 November 2011

BinaryPush( <binary-array>, <byte> ) 

Contents

Description

Add a byte to the end of a binary variable.

Parameters

binary-array

The binary variable to use.

byte

The byte to add to the end of the binary data.

Return Value

Success: Returns 1.

Failure: Returns 0.

Remarks

Binary data is not really meant to be resized like crazy so if you have a LOT of data its best to avoid using this too often.

Example

$binary = Pack("z0", "One");
BinaryPush($binary, Asc(" "));
BinaryPush($binary, Asc("T"));
BinaryPush($binary, Asc("w"));
BinaryPush($binary, Asc("o"));
println( "'" . Unpack("z0", $binary) . "'" ); // Prints: One Two
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox