Core Function BinaryResize
From Sputnik Wiki
BinaryResize( <binary-array>, <size>, <data> )
Contents |
Description
Resize a binary variables data array.
Parameters
binary-array
The binary variable to use.
size
The new size for the binary variables data array.
data
Optiona; The byte to place into all new slots (Assuming the new array is larger than the old).
Default is 0
Return Value
Success: Returns 1.
Failure: Returns 0.
Remarks
This modifies the original binary variable and does not return a copy.
Example
Resize a binary to contain just 1 word:
$binary = Pack("z0", "Hello World!") BinaryResize($binary, 5) $k = 0 For $i In $binary println( "($k) Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) ) $k++ Next
Resize a binary and fill in the gaps with ! symbols :
$binary = Pack("z0", "Hello World!") BinaryResize($binary, 20, Asc("!")) $k = 0 For $i In $binary println( "($k) Byte: " . $i . " | Hex: " . Hex($i) . " | Char: " . Chr($i) ) $k++ Next