Core Function Unpack

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(flag)
Line 1: Line 1:
 
<pre>
 
<pre>
Unpack( <expression>, <binary-array/string>, <flag> )
+
Unpack( <format>, <data/binary-array>, <flag> )
 
</pre>
 
</pre>
  
 
=== Description ===
 
=== Description ===
  
Unpack data from a binary array
+
Unpack data from a binary array  
  
==== expression ====
+
Unpacks from a binary array into a normal array according to the given format.
  
The format string to use.
+
The unpacked data is stored in an associative array.
  
==== binary-array/string ====
+
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 [[Core Function Pack|Pack( )]] for an explanation of the format codes.
 +
 
 +
==== data/binary-array ====
  
 
An binary array of bytes such as one produced by the Pack function.
 
An binary array of bytes such as one produced by the Pack function.
Line 17: Line 23:
 
OR
 
OR
  
A string to be converted into a binary array of bytes (z0 ASCII encoding).
+
A variable that will be converted to a binary array.
  
 
==== flag ====
 
==== flag ====
Line 23: Line 29:
 
Optional; Control what is returned options are:
 
Optional; Control what is returned options are:
  
0 = Return an array (If there is more than one item or just return THAT item by itself (provided no (key) was used) not in an array)
+
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)
 
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
 
2 = Force return of single item as is (string, int, float etc) regardless if (key) etc was used
 
3 = Force return to be an array regardless of what it contains
 
  
 
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.  
 
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.  
Line 37: Line 41:
 
=== Return Value ===
 
=== Return Value ===
  
Success: Returns the array of data (Only if its over 1 item, For single items (provided there was no (key) used) it will return the item such as string, int, float etc) unless the flag is set to 1 then it will return a string regardless of what the item is or how many there are.
+
Success: Depends on flag see table below
 +
 
 +
<pre>
 +
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)
 +
</pre>
  
Failure: Returns null.
+
Failure: Returns null
  
 
=== Remarks ===
 
=== Remarks ===
  
Go see [[Core Function Pack|Pack( <expression>, <expressions> )]] for a list of formats and examples.
+
None.
  
 
=== Example ===
 
=== Example ===
  
Go see [[Core Function Pack|Pack( <expression>, <expressions> )]] for a list of formats and examples.
+
Go see [[Core Function Pack|Pack( )]] for examples.
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 14:01, 26 September 2013

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