DecodePacket (open)
Decode a binary packet
Syntax
// Core function, no LOADLIB necessary
RECORD FUNCTION DecodePacket(STRING format, STRING data)Parameters
STRING formatFormatting string: field1:<type> [ repeatcounter | ? | * ],field2:<type> [ repeatcounter | ? | * ]
The following types are accepted:
| Type | Description | 
|---|---|
x | 
Skip a NUL byte. If a count is specified, skip that many NULs. If '?', return number of bytes skipped. If '*', skip until non-NUL | 
b | 
Signed 64bit long (little endian order, 64-bit) | 
B | 
Unsigned 64bit long (little endian order, 64-bit) | 
c | 
Signed character (8 bit) | 
C | 
Unsigned character (8 bit) | 
d | 
Signed 64bit long (big endian order, 64-bit) | 
D | 
Unsigned 64bit long (big endian order, 64-bit) | 
s | 
Signed short (little endian order, 16-bit) | 
S | 
Unsigned short (little endian order, 16-bit) | 
l | 
Signed long (little endian order, 32-bit) | 
L | 
Unsigned long (little endian order, 32-bit) | 
n | 
Signed short (big endian order/network byte order, 16-bit) | 
N | 
Unsigned short (big endian order/network byte order, 16-bit) | 
p | 
Signed long (big endian order/network byte order, 32-bit) | 
P | 
Unsigned long (big endian order/network byte order, 32-bit) | 
a | 
NUL-padded string (padded up to specified counter). If '*', simply read until NUL termination | 
A | 
ASCII-padded string (paddedup to specified counter). If '*', simply read until space termination | 
r | 
Raw data - take a string. If a counter is specified, that many bytes is taken. If '*', all remaining bytes are taken. | 
R | 
Raw data - take a string and reverse it. If a counter is specified, that many bytes is taken. If '*', all remaining bytes are taken. | 
f | 
Float (little endian order, 32-bit) | 
F | 
Double (little endian order, 64-bit) | 
g | 
Float (big endian order, 32-bit) | 
G | 
Double (big endian order, 64-bit) | 
h | 
Datetime (little endian order, 2x32-bit). First day, then mseconds | 
i | 
Datetime (big endian order, 2x32-bit). First day, then mseconds | 
j | 
Boolean (8-bit) | 
@@ | 
Jump to absolute position in packet decoder. } | 
STRING dataData to decode
Return value
RECORDA record containing the decoded data, or a non-existing record if the decoding failed