<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_PutBlob |
Declare Function sx_PutBlob Lib "Apollo9.dll"
(ByVal cpFieldName As String
vpVar As Any,
ByVal lSize As Long)
As Long
LONG FAR PASCAL sx_PutBlob
(BYTEP cpFieldName,
VOIDP vpVar,
LONG lSize);
Stores a BLOB in a memo field. A BLOB is a binary large object. The maximum size of a BLOB is 16 megabytes. Elements that contain fixed length strings may be stored and retrieved. If the BLOB resides completely in a file, use sx_Replace to store it in the memo.
cpFieldName: The name of the memo field that holds the BLOB.
vpVar: A pointer to a memory object.
lSize: The size of the BLOB.
The number of bytes written. If this differs from the size passed in lSize, an error has occurred.
' save and retrieve an array of integers to and from a BLOB
Static intArray(20) As Integer
Dim i As Integer
Dim lSize As Long
Dim lBytes As Long
Dim DynArray() As Integer
' set up blob example
For i = 1 To 20
intArray(i - 1) = i + 99
Next i
' write array to disk
lSize = UBound(intArray) - LBound(intArray) + 1
lSize = lSize * Len(intArray(LBound(intArray)))
lBytes = sx_PutBlob("notes", intArray(LBound(intArray)), lSize)
If lBytes <> lSize Then
MsgBox "Blob write error"
Exit Sub
End If
sx_Commit
' retrieve array from same record
lSize = sx_GetBlobLength("notes")
ReDim DynArray(lSize / 2)
lBytes = sx_GetBlob("notes", DynArray(LBound(DynArray)))
If lBytes <> lSize Then
MsgBox "Blob read error"
Exit Sub
Else
For i = 1 To 20
Debug.Print DynArray(i - 1)
Next i
End If
// write an array of long integers
lSize = sx_PutBlob("blobfield", longArray, (LONG)sizeof(longArray));