Core Function BinaryConcat
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> BinaryConcat( <destination/array>, <values> ) </pre> === Description === Mass append a ton of Binary variables in an extremely fast and efficient way. === Parameters ===...") |
(→Example) |
||
Line 51: | Line 51: | ||
// Make a binary var we will concat onto it | // Make a binary var we will concat onto it | ||
my $a = Pack("A*", "Hello"); | my $a = Pack("A*", "Hello"); | ||
+ | // Make a binary var we will use as the separator | ||
+ | my $sep = Pack("A*", ", "); | ||
// Make binary stuff to concat to it | // Make binary stuff to concat to it | ||
my $b = Pack("A*", "Hehe"); | my $b = Pack("A*", "Hehe"); | ||
Line 56: | Line 58: | ||
my $d = Pack("A*", "Cat"); | my $d = Pack("A*", "Cat"); | ||
my $e = Pack("A*", "Dog"); | my $e = Pack("A*", "Dog"); | ||
− | |||
// Do the concat | // Do the concat | ||
− | BinaryConcat(array(&$a, $ | + | BinaryConcat(array(&$a, $sep), $b, $c, $d, $e); |
say $a; | say $a; | ||
// PRINTS | // PRINTS |
Latest revision as of 10:34, 14 September 2015
BinaryConcat( <destination/array>, <values> )
Contents |
Description
Mass append a ton of Binary variables in an extremely fast and efficient way.
Parameters
destination/array
IF this param is NOT an array then it expects a binary variable or something it can as such.
IF this param IS an array then the element [0] must be a reference to a binary variable and [1] must be the separator as a binary variable or something that can be converted to it.
values
One of more values to be concatenated.
Return Value
Success: Returns true.
Failure: Returns false.
Remarks
None.
Example
// Make a binary var we will concat onto it my $a = Pack("A*", "Hello"); // Make binary stuff to concat to it my $b = Pack("A*", "Hehe"); my $c = Pack("A*", "Test"); my $d = Pack("A*", "Cat"); my $e = Pack("A*", "Dog"); // Do the concat BinaryConcat($a, $b, $c, $d, $e); say $a; // PRINTS // HelloHeheTestCatDog
Using the separator to do that we must use an array with first element referenced using &
// Make a binary var we will concat onto it my $a = Pack("A*", "Hello"); // Make a binary var we will use as the separator my $sep = Pack("A*", ", "); // Make binary stuff to concat to it my $b = Pack("A*", "Hehe"); my $c = Pack("A*", "Test"); my $d = Pack("A*", "Cat"); my $e = Pack("A*", "Dog"); // Do the concat BinaryConcat(array(&$a, $sep), $b, $c, $d, $e); say $a; // PRINTS // Hello, Hehe, Test, Cat, Dog