Gambas Documentation
Como se hace...
Compilación e instalación
Componentes
Controls pictures
Descripciones del Lenguaje
Developer Documentation
Documentacion y Recetas
Documentación del Entorno de Desarrollo
Fragmentos de código
Glosario
Índice del Lenguaje
Abs
Access
ACos
ACosh
Alloc
AND
Ang
APPEND
Array
AS
Asc
Asignación
ASin
ASinh
ATan
ATan2
ATanh
BChg
BClr
BEGINS
Bin$
BREAK
BSet
BTst
BYREF
CASE
CATCH
CBool
Cbr
CByte
CDate
CFloat
Choose
Chr$
CInt
CLASS
CLong
CLOSE
Comp
CONST
Constantes del Lenguaje
CONTINUE
Conv$
COPY
Cos
Cosh
CREATE
CREATE STATIC
CShort
CSng
CStr
Date
DateAdd
DateDiff
Day
DConv$
DEBUG
DEC
Declaracion de Arreglos
Declaración de Constantes
Declaración de Eventos
Declaración de Funciones Externas
Declaración de Métodos
Declaración de Propiedades
Declaración de Variables
Declaración de Variables Locales
DEFAULT
Deg
DFree
DIM
Dir
DIV
DO
ELSE
END
ENDIF
ENDS
END SELECT
END WITH
ENUM
Enumeration declaration
Eof
ERROR
Etiquetas
EVENT
EXEC
Exp
Exp2
Exp10
Expm
EXPORT
Expresión Constante
EXTERN
FALSE
FINALLY
FLUSH
FOR
FOR EACH
Format$
Frac
Free
FUNCTION
GOTO
Hex$
Hour
Html$
Hyp
IF
IN
INC
INPUT
INPUT FROM
InStr
Int
IsAscii
IsBlank
IsBoolean
IsByte
IsDate
IsDigit
IsDir
IsFloat
IsHexa
IsInteger
IsLCase
IsLetter
IsLong
IsNull
IsNumber
IsObject
IsPunct
IsShort
IsSingle
IsSpace
IsString
IsUCase
KILL
LAST
LCase$
Left$
Len
LIBRARY
LIKE
LINE INPUT
LINK
LOCK
Lof
Log
Log2
Log10
Logp
LOOP
LTrim$
Max
ME
Métodos especiales
Mid$
Min
Minute
MKDIR
MOD
Month
MOVE
New
NEXT
NOT
Now
NULL
OPEN
Operadores Aritméticos
Operadores de Asignación
Operadores de Cadena
Operadores Lógicos
OPTIONAL
OR
OUTPUT
OUTPUT TO
Pi
PRINT
PRIVATE
PROCEDURE
PROPERTY
PUBLIC
QUIT
Quote$
Rad
RAISE
Randomize
READ[../../def/stream] _\Stream_
Realloc
REPEAT
Replace$
RETURN
Right$
RInStr
RMDIR
Rnd
Rol
Ror
Round
RTrim$
SConv$
Second
Seek
SELECT
Sgn
Shell$
Shl
Shr
Sin
Sinh
SLEEP
Space$
Split
Sqr
Stat
STATIC
STEP
STOP
STOP EVENT
Str$
String$
StrPtr
SUB
Subst$
SUPER
SWAP
Tan
Tanh
Temp$
THEN
Time
Timer
Tipos de Datos
TO
Trim$
TRUE
TRY
TypeOf
UCase$
UNLOCK
UNTIL
Val
WAIT
WATCH
Week
WeekDay
WEND
WHILE
WITH
WRITE
XOR
Year
LÉEME
Licencia del Wiki
Manual del Wiki
Mensajes de Error
Pendiente de traducción
Registrarse
Repositorio de Aplicaciones
Tutoriales
Últimos cambios

Binary Data Representation

The READ and WRITE instructions allow to read and write binary representation of Gambas datatypes values.

Datatype Size Representation
Boolean 1 byte 0 for FALSE, 255 for TRUE.
Byte 1 byte The data value in binary.
Short 2 bytes The data value in binary.
Integer 4 bytes The data value in binary.
Long 8 bytes The data value in binary.
Pointer 4 bytes in 32 bits
8 bytes in 64 bits
The pointer value in binary.
Single 4 bytes The data value in binary.
Float 8 bytes The data value in binary.
Date 8 bytes The date and time as two four-bytes integers.
String variable The string length is written first, as a variable-length integer number:
  • One byte is written if the string length is lower or equal than 127 characters.

  • Two bytes are written if the string length is between 128 and 16383 characters.

  • Four bytes are written if the string length is between 16384 and 1073741824 characters.

  • Longer strings cannot be written at the moment.

Then the string contents is written.

Desde 3.15

If the Stream.NullTerminatedString property is set, then strings are null terminated instead. No string length is read or written.
NULL 1 byte Null values and null strings are written as a single 0 byte.
Variant Variable When writing a variant value, a byte indicating the value datatype is written before. The value itself is written according to this table.
Array 2 bytes + array length + array contents
  • One byte whose value is 65.

  • One byte whose value represents the array contents datatype.

  • The array length, written like a string length.

  • The value of each array element.

Collection 1 byte + collection length + collection contents
  • One byte whose value is 67 if the collection keys are case sensitive, 99 if they are not case sensitive.

  • The collection length, written like a string length.

  • For each collection item:
    • The key, written as a string

    • Its associated value.

Structure Contents size
  • The structure contents are written in declaration order recursively.

  • Embedded arrays items are written in order. Contrary to normal arrays, no size or type header is written.

Serializable objects

Desde 3.15
1 byte + class name (optional) + object contents
  • One byte whose value is 79 or 111.

  • If the initial byte is 111, the class name is written that way:
    • One byte for the class name length, between 1 and 255.

    • The class name.

  • The object contents as written by the _write method of the class.

The endianness of the binary data is the endianness of the stream.

See also