Core Function BinaryLoad

From Sputnik Wiki
Revision as of 10:04, 12 November 2011 by UberFoX (Talk | contribs)
Jump to: navigation, search
BinaryLoad( <file>, <flag> )

Contents

Description

Create a new binary variable by loading binary data from a file.

Parameters

file

Name of file to load.

flag

Optional; Compression flag.

0 = The file is not compressed

1 = The file is compressed (This must be a specific compression like the one produced by using BinarySave)

Return Value

Success: Returns the new binary variable.

Failure: Returns 0.

Remarks

This will even accurately load exe files so they can be saved again without damage.

Example

$binary = BinaryLoad("Sputnik.exe")
println("Size is : " . BinaryLen($binary) )
BinarySave($binary, "SputnikTest.exe")
Example with compression
$binary = Pack("z0", ("Hello World!\n" x 1_000))
BinarySave($binary, "test.txt", 1)
$binaryLoaded = BinaryLoad("test.txt", 1)
println( Unpack("z0", $binaryLoaded) ) ; Prints "Hello World!" 1000 times
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox