Core Function BinarySet

From Sputnik Wiki
Jump to: navigation, search
BinarySet( <binary-array>, <index>, <value> )

Contents

Description

Get the byte at an index of a binary variable.

Parameters

binary-array

The binary variable to use.

index

Any valid numeric expression.

value

The byte to place.

Return Value

Success: Returns 1.

Failure: Returns 0.

Remarks

None.

Example

$binary = BinaryHex("48656c");
println( "Before change:" );
println( "Binary 0: '" . BinaryGet($binary, 0) );
println( "Binary 1: '" . BinaryGet($binary, 1) );
println( "Binary 2: '" . BinaryGet($binary, 2) );
BinarySet($binary, 0, 67);
BinarySet($binary, 2, 44);
println( "" );
println( "After change:" );
println( "Binary 0: '" . BinaryGet($binary, 0) );
println( "Binary 1: '" . BinaryGet($binary, 1) );
println( "Binary 2: '" . BinaryGet($binary, 2) );

You can also do this an easier way using the [ ] array bracket

$binary = BinaryHex("48656c");
println( "Before change:" );
println( "Binary 0: '" . $binary[0] );
println( "Binary 1: '" . $binary[1] );
println( "Binary 2: '" . $binary[2] );
$binary[0] = 67;
$binary[2] = 44;
println( "" );
println( "After change:" );
println( "Binary 0: '" . $binary[0] );
println( "Binary 1: '" . $binary[1] );
println( "Binary 2: '" . $binary[2] );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox