Core Function BinaryCreate

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> BinaryCreate( <size>, <fill> ) </pre> === Description === Create a new binary variable and its array size and fill data type. === Parameters === ==== size ==== The siz...")
 
m (1 revision)
 
(4 intermediate revisions by one user not shown)
Line 23: Line 23:
 
Success: Returns the new binary variable.
 
Success: Returns the new binary variable.
  
Failure: Returns 0.
+
Failure: Returns null.
  
 
=== Remarks ===
 
=== Remarks ===
  
N/A
+
These binary arrays might look a bit similar to normal arrays but they are not since they are locked as BYTE only and take up less ram.
  
 
=== Example ===
 
=== Example ===
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
$binary = BinaryCreate(1000) ; Create it
+
$binary = BinaryCreate(1000); // Create it
; Print its data
+
// Print its data
$k = 0
+
$k = 0;
For $i In $binary
+
Foreach ($binary as $i)
println( DecPad($k, 5) . " Byte: " . $i )
+
{
$k++
+
println( DecPad($k, 5) . " Byte: " . $i );
Next
+
$k++;
; Finally print its size
+
}
println("The size of the new binary variable is: " . BinaryLen($binary) )
+
// Finally print its size
 +
println("The size of the new binary variable is: " . BinaryLen($binary) );
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 12:38, 14 June 2015

BinaryCreate( <size>, <fill> )

Contents

Description

Create a new binary variable and its array size and fill data type.

Parameters

size

The size (in bytes) of the new binary variable.

fill

Optional; The byte to fill the data with.

Default is 0

Return Value

Success: Returns the new binary variable.

Failure: Returns null.

Remarks

These binary arrays might look a bit similar to normal arrays but they are not since they are locked as BYTE only and take up less ram.

Example

$binary = BinaryCreate(1000); // Create it
// Print its data
$k = 0;
Foreach ($binary as $i)
{
	println( DecPad($k, 5) . " Byte: " . $i );
	$k++;
}
// Finally print its size
println("The size of the new binary variable is: " . BinaryLen($binary) );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox