A Scripting Language for Web, Linux and Windows

A Scripting Language for Web, Linux and Windows

Binary functions

V1 strings can contain binary data (also zero byte). The length of a string is always detected with strlen() function.

The following functions can be used to parse and format binary data and access the memory.

Function/Arguments Return Description
binformat (number number, [number format=7, number nbo=0] ) string Convert a number into a binary format and return the binary string. format can be following: 1 = 8 Bit (char), 2 = 16 Bit (short), 3 = 32 Bit (int), 4 = 64 Bit (long long), 5 = 32 Bit (float), 6 = 64 Bit (double), 7 = integer with default width (defined in constant _ALIGN). If optional parameter nbo is 1, then 32 Bit and 16 Bit will be converted from network byte order to host byte order. If nbo is 2, then 32 Bit and 16 Bit will be converted from host byte order to network byte order. If nbo is 0, then 32 Bit and 16 Bit are formatted in native machine format.
binparse (string string, [number format=7, number pos=0, bool signed=0, number nbo=0] ) number Parse a binary string and return the parsed number. format can be following: 1 = 8 Bit (char), 2 = 16 Bit (short), 3 = 32 Bit (int), 4 = 64 Bit (long long), 5 = 32 Bit (float), 6 = 64 Bit (double), 7 = integer with default width (defined in constant _ALIGN). Optional parameter pos set the position where parsing will start. If signed is true, then the number will returned signed, default is unsigned. If nbo is 1, then 32 Bit and 16 Bit will be converted from network byte order to host byte order. If nbo is 2, then 32 Bit and 16 Bit will be converted from host byte order to network byte order. If nbo is 0, then 32 Bit and 16 Bit are parsed in native machine format.
memat (number address [,number length=0]) string Read memory data from address. If no length is given it stops on zero byte (0 terminated string) otherwise the length of bytes is read. Memory data is returned as string. Usually this function will be used to read memory data from pointers returned by native functions. For detailed description read manual Native function calling.
memref (string &string) number Return a reference pointer to memory of string. Usually this function will be used to make pointers for native functions. For detailed description read manual Native function calling.
memset (number address, string data, [,number offset=0]) number Set memory data at address. Optional offset is added to address. Size of data is returned. Usually this function will be used to write data on pointers returned by native functions. For detailed description read manual Native function calling.

Note that 64 Bit integer numbers cannot be loaded completely into internal floating point representation. See also datatypes.
To work with binary strings see also Native function calling.

back to Home

V1 Version 0.96 - Documentation generated Wed, 03 Jan 2024 12:21