_AllocMemo( ) API Library Routine

See Also   Example

Allocates size bytes of space in the memo file for a field and inserts the new block number in the associated record in the database.

Syntax

long _AllocMemo(Locator FAR *fld, long size)
Locator FAR *fld;            /* Pointer to locator that defines the memo field. */
long size;                     /* Size of allocated space in bytes. */

Remarks

When _AllocMemo( ) is successful, it returns the location in the file to begin writing; otherwise, it returns  – 1.

Caution   Writing more than size bytes causes memo file corruption.

If you plan to replace a memo field using direct methods, be sure your routine calls _AllocMemo( ) before writing to the memo file, even if the new value is the same length or smaller than the original. This prevents problems in multi-user situations. _AllocMemo( ) reuses the previously allocated space when it's safe to do so.

For more information on how to create an API library and integrate it with Visual FoxPro, see Chapter 28, Accessing the Visual FoxPro API, in the Programmer's Guide.