version 2003
PA_GetBlobParameter (params; index; blob) long
Parameter | Type | Description | |
params | PA_PluginParameters | Parameters received in PluginMain | |
index | short | Index of the parameter in params | |
blob | void * | Value (buffer) of the index parameter (a BLOB) | |
Function result | long | BLOB size |
Description
The routine PA_GetBlobParameter fills blob with the value (of type BLOB) of the index parameter in params and returns its size.
First call the routine with blob as 0L to retrieve the size of the buffer you should allocate. Then, allocate the buffer and call the routine again with the allocated buffer.
After using blob, you can dispose of it as it does not belong to 4th Dimension, it is a copy of the parameter. As usual, it is a good habit to dispose of memory that is no longer needed.
If you do not want to receive a copy of the BLOB (for memory optimization), you can use the PA_GetBlobHandleParameter routine, which returns a handle to the BLOB. In this case, remember that the handle belongs to 4th Dimension and you must not dispose of it.
See Create a new plug-in for a description of parameter accessors.
NOTE:
The first parameter starts at index 1.
Example
The 3rd routine of the plug-in is named "pi_DoWithBlob".
The 4D developer is told to use it this way:
pi_DoWithBlob($blob);// or BLOB, or <>BLOB, or [Table1]BlobField
void PluginMain( long selector, PA_PluginParameters params ) { switch ( selector ) { . . .kInitPlugin, kDeinitPlugin case kMyRoutine : // declared as DoWithBob(&O) in the STR# resource DoWithABlob(params); break; } } void DoWithABlob (PA_PluginParameters params ) { char *blob; long blobSize; blob = 0L; blobSize = PA_GetBlobParameter(params, 1, 0L); blob = malloc(textSize); blobSize = PA_GetBlobParameter(params, 1, blob); // Let's work with the blob DoSomethingWithThisBlob(blob); // We can now release the received copy free(blob); }
See Also
Create a new plugin, PA_Blob, PA_GetBlobHandleParameter.
Error Handling
PA_GetLastError() keeps the last error that occurred before calling the routine.