"Sputnik" help  
Sputnik Help
BinaryCreate([<size>], [<filler>] )

Description

The BinaryCreate function creates a binary string with a specified size and fills it with a specified byte value. This function is useful when you need to create binary data structures or buffers of a specific size.

Parameters

<size> Optional size of the binary string to create. Must be a positive integer.
<filler> Optional byte value used to fill the binary string. (Default: 0x00)

Return Value

Success: Returns binary string of the specified size, filled with the specified byte value.
Failure: Returns null.

Remarks

The size parameter must be a positive integer. If a non-positive value is provided, the resulting binary string will be empty.
The filler parameter is optional. If not provided, the binary string will be filled with 0x00 by default.
The resulting binary string will have a length equal to the specified size, and each byte in the string will have the same value as the filler parameter.

Related

Bin, BinNew

Example

Empty:

printr BinaryCreate();
// PRINTS
// Binary
// (
// )


All zeros:

printr BinaryCreate(5);
// PRINTS
// Binary
// (
//     [0] => 0x00 [0] (.)
//     [1] => 0x00 [0] (.)
//     [2] => 0x00 [0] (.)
//     [3] => 0x00 [0] (.)
//     [4] => 0x00 [0] (.)
// )

Using filler:

printr BinaryCreate(5, 0xFF);
// PRINTS
// Binary
// (
//     [0] => 0xFF [255] (ÿ)
//     [1] => 0xFF [255] (ÿ)
//     [2] => 0xFF [255] (ÿ)
//     [3] => 0xFF [255] (ÿ)
//     [4] => 0xFF [255] (ÿ)
// )
Using filler with a char:
say BinaryCreate(5, 'T');
// PRINTS
// TTTTT

 


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