Core Function Unpack

From Sputnik Wiki
Revision as of 14:01, 26 September 2013 by UberFoX (Talk | contribs)
Jump to: navigation, search
Unpack( <format>, <data/binary-array>, <flag> )

Contents

Description

Unpack data from a binary array

Unpacks from a binary array into a normal array according to the given format.

The unpacked data is stored in an associative array.

To accomplish this you have to name the different format codes and separate them by a slash /. If a repeater argument is present, then each of the array keys will have a sequence number behind the given name.

format

See Pack( ) for an explanation of the format codes.

data/binary-array

An binary array of bytes such as one produced by the Pack function.

OR

A variable that will be converted to a binary array.

flag

Optional; Control what is returned options are:

0 = Return an associative array containing unpacked elements of binary array

1 = Return a string (Regardless of how many items are to be returned it will just append them)

2 = Force return of single item as is (string, int, float etc) regardless if (key) etc was used

Basically set it to 0 to get the array or single item if applicable, 1 to return a string regardless of what content is (such as int), 2 to return the first object intact (no string conversion) and finally 3 to force it to be an array no matter what.

Default: 0

Return Value

Success: Depends on flag see table below

Flag 0 = Return an associative array containing unpacked elements of binary array
Flag 1 = Returns a string containing all the elements of the array joined together with no separator
Flag 2 = Return the first element of the array (if one exists otherwise return null)

Failure: Returns null

Remarks

None.

Example

Go see Pack( ) for examples.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox