Gets or Writes data to a file.
Syntax
value = GET16( buffer [ ,offset [ ,byteorder ]] )
value = GET32( buffer [ ,offset [ ,byteorder ]] )
binval = PUT16( value [ ,byteorder ] )
binval = PUT32( value [ ,byteorder ] )
Version Ref: 5.6
The GETnn functions retrieve a binary value from a buffer, and the PUTnn functions convert the value into binary. The offset parameter specifies the zero-relative offset within the buffer where the value resides. The byteorder parameter specifies the byte order of the binary value, with "L" meaning little-endian, "B" meaning big-endian, and the default being the native order of the current system.
For example, to get the 32-bit little-endian value at offset 8 within the MyBuffer variable, you would use:
value = GET32(MyBuffer,"8","L")
To convert the RouterHandle variable into a 16-bit little-endian value, you would use:
value = PUT16(RouterHandle,"L")
Note that 8-bit values can already be read/written using the existing ASC and CHR functions.
These functions are used more easily interpret the contents, where READ()/WRITE() could access the data, but interpreting the contents would require a bit of work to extract/build the binary data.
For example, you want to get information about a .BMP file. Within the file is a BITMAPINFOHEADER structure, defined in C as:
typedef struct tagBITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
} BITMAPINFOHEADER;
After you read the information with:
xx = read(handle,MyBuffer,"40")
You want to extract the information from it:
biSize = GET32(MyBuffer)
biWidth = GET32(MyBuffer,"4")
biHeight = GET32(MyBuffer,"8")
biPlanes = GET16(MyBuffer,"12")
biBitCount = GET16(MyBuffer,"14")
... and so on ...
If you wanted to write out the information, you could build the buffer using the PUT16/PUT32 functions:
MyBuffer = PUT32(biSize) & PUT32(biWidth) & PUT32(biHeight) & PUT16(biPlanes) & PUT16(biBitCOunt) & ...etc...
It may also be the case that the file is always in a specific endian byte order, regardless of the platform you are running filePro on. (For example, binary data sent via TCP/IP is almost always sent in big-endian order, even on little-endian platforms.) In that case, you would pass an explicit "L" or "B" endian parameter to force the byte order.