"Sputnik" help  
Sputnik Help
BinaryGrow(<binary>, <size>, [<filler>], [<fromLeft>])

Description

Expands a binary string by the specified additional size, filling the additional space with a filler byte.

Parameters

<binary> The binary string to be expanded.
<size> The additional size by which the binary string should be expanded.
<filler> Optional byte value (an integer) to use as the filler. If not provided, the filler byte will be 0x00 (null byte) by default.
<fromLeft> Optional oolean value indicating whether the expansion should occur from the left side. If set to true, the additional space will be added at the beginning of the binary string. If not provided or set to false, the additional space will be added at the end of the binary string.

Return Value

Success: Returns the expanded binary string with the specified size..
Failure: Returns current size (means no change).

Remarks

The BinaryGrow function allows you to expand a binary string by a specific additional size. It takes a binary string, the additional size, an optional filler byte, and an optional expansion direction as input. The filler byte is used to fill the additional space created by the expansion. By default, if the filler byte is not provided, it will be 0x00 (null byte). The expansion direction determines whether the additional space is added at the beginning or end of the binary string. If the expansion direction is not specified or set to false, the additional space will be added at the end of the binary string. This function is useful when you need to increase the size of a binary string by a specific amount and fill the newly added space with a specific value.

Related

BinaryShrink, BinarySize

Example

Example of usage:

my $a = Bin('A');
BinaryGrow($a, 4);
say BinaryExpand($a, false);

my $a = Bin('A');
BinaryGrow($a, 4, 'T');
say $a;

my $a = Bin('A');
BinaryGrow($a, 4, 'T', true);
say $a;

// PRINTS
// 41 00 00 00 00 -- -- -- -- -- -- -- -- -- -- -- A....
// ATTTT
// TTTTA

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org