Core Function BinaryGet

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> BinaryGet( <binary-array>, <index> ) </pre> === Description === Get the byte at an index of a binary variable. === Parameters === ==== binary-array ==== The binary va...")
 
m (1 revision)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<pre>
 
<pre>
BinaryGet( <binary-array>, <index> )
+
BinaryGet( <binary-array>, <index> )
 
</pre>
 
</pre>
  
Line 21: Line 21:
 
Success: Returns the byte at the given location.
 
Success: Returns the byte at the given location.
  
Failure: Returns 0.
+
Failure: Returns NULL.
  
 
=== Remarks ===
 
=== Remarks ===
Line 30: Line 30:
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$binary = BinaryHex("48656c")
+
$binary = BinaryHex("48656c");
println( "Binary 0: '" . BinaryGet($binary, 0) )
+
println( "Binary 0: '" . BinaryGet($binary, 0) );
println( "Binary 1: '" . BinaryGet($binary, 1) )
+
println( "Binary 1: '" . BinaryGet($binary, 1) );
println( "Binary 2: '" . BinaryGet($binary, 2) )
+
println( "Binary 2: '" . BinaryGet($binary, 2) );
 +
// Now show all
 +
println( "All:" );
 +
for( $i = 0; $i < BinaryLen($binary); $i++)
 +
{
 +
println( "Binary $i: '" . BinaryGet($binary, $i) );
 +
}
 +
</syntaxhighlight>
 +
 
 +
You can also do this an easier way using the [ ] array bracket
 +
 
 +
<syntaxhighlight lang="sputnik">
 +
$binary = BinaryHex("48656c");
 +
println( "Binary 0: '" . $binary[0] );
 +
println( "Binary 1: '" . $binary[1] );
 +
println( "Binary 2: '" . $binary[2] );
 +
// Now show all
 +
println( "All:" );
 +
for( $i = 0; $i < BinaryLen($binary); $i++)
 +
{
 +
println( "Binary $i: '" . $binary[$i] );
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 12:38, 14 June 2015

BinaryGet( <binary-array>, <index> )

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.

Return Value

Success: Returns the byte at the given location.

Failure: Returns NULL.

Remarks

None.

Example

$binary = BinaryHex("48656c");
println( "Binary 0: '" . BinaryGet($binary, 0) );
println( "Binary 1: '" . BinaryGet($binary, 1) );
println( "Binary 2: '" . BinaryGet($binary, 2) );
// Now show all
println( "All:" );
for( $i = 0; $i < BinaryLen($binary); $i++)
{
	println( "Binary $i: '" . BinaryGet($binary, $i) );
}

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

$binary = BinaryHex("48656c");
println( "Binary 0: '" . $binary[0] );
println( "Binary 1: '" . $binary[1] );
println( "Binary 2: '" . $binary[2] );
// Now show all
println( "All:" );
for( $i = 0; $i < BinaryLen($binary); $i++)
{
	println( "Binary $i: '" . $binary[$i] );
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox