Core Function BinaryPush
From Sputnik Wiki
(Difference between revisions)
(→Example) |
m (1 revision) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 25: | Line 25: | ||
=== Remarks === | === Remarks === | ||
− | Binary data is not really meant to be resized like crazy so if you have a LOT of data | + | Binary data is not really meant to be resized like crazy, so if you have a LOT of data, it is best to avoid using this too often. |
=== Example === | === Example === | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $binary = Pack(" | + | $binary = Pack("A*", "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(" | + | println( "'" . Unpack("A*", $binary, 3) . "'" ); // Prints: One Two |
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
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, it is best to avoid using this too often.
Example
$binary = Pack("A*", "One"); BinaryPush($binary, Asc(" ")); BinaryPush($binary, Asc("T")); BinaryPush($binary, Asc("w")); BinaryPush($binary, Asc("o")); println( "'" . Unpack("A*", $binary, 3) . "'" ); // Prints: One Two