BinaryAllocArray

Allocates a memory buffer and copies the contents of an array.

Syntax:

BinaryAllocArray( array )

Parameters

(a) array: Specifies an array.

Returns:

(i) handle: Returns a handle to a buffer that contains a copy of the array.

 

This function is intended to convert binary data from an array of binary data, such as an image returned by a OLE/COM function to it's original form, so that it may be subsequently written to disk.

Use this function to allocate a memory buffer that contains a copy of the contents of an array. The memory buffer’s size is automatically set to hold a copy of the entire array.

The array elements must be integers, floating point numbers or one of the COM Automation types from the list below:

 

Variant-type

Value to specify

I1

A 1-byte character value

I2

A 2-byte integer value

I4

A 4-byte integer value

R4

32-bit IEEE floating point value.

R8

64-bit IEEE floating point value.

BOOL

A Boolean (True/False) value

CY

A currency value, specified as a string in the form "#CURRENCY:value

DATE

A date/time value, specified as a string in Ymd or YmdHms format

UI1

1-byte unsigned integer.

UI2

2-byte unsigned integer.

UI4

4-byte unsigned integer.

UI8

8-byte unsigned integer.

INT

4-byte signed integer value (equivalent to I4).

UINT

4-byte unsigned integer (equivalent to VT_UI4).

DECIMAL

A decimal value, specified as a string in the form "#DECIMAL:value

 

Notes:

Example:

This example uses the BinaryAllocArray function To copy an image To a binary buffer so that it can be saved To a local file. The image is retrieved from a host internet site as an array of bytes or "ARRAY|U1" as returned By ObjectTypeGet.
; Create a local file name.
path = "c:\temp\"
imagefile = "http://www.google.com/images/logo.gif"
localname = StrCat(path, ItemExtract(ItemCount(imagefile, "/"), imagefile, "/"))
; Get an image from the internet.
WinHttpReq = ObjectCreate("WinHttp.WinHttpRequest.5.1") ; Windows XP SP 1
WinHttpReq.Open("GET", imagefile, @FALSE)
WinHttpReq.Send
x = WinHttpReq.ResponseBody
; Convert to binary buffer.
BinBuf = BinaryAllocArray(x)
; Write binary buffer to a file.
BinaryWrite(BinBuf, localname)
; Cleanup
WinHttpReq = 0
BinaryFree(BinBuf)
See Also:

BinaryAlloc, BinaryWrite, Binary Operations, ObjectType, ObjectTypeGet