xlFree

Allows Microsoft Excel to free auxiliary memory associated with an XLOPER. xlFree frees the auxiliary memory and resets the pointer to NULL but does not destroy other parts of the XLOPER.

This function does not return a value.

Syntax

Excel4(xlFree, 0, n, LPXLOPER px, ...)

px, ...

One or more XLOPERs to free.

Remarks

You must free every XLOPER that you get as a return value from Excel4 or Excel4v if that XLOPER uses auxiliary memory (if it contains pointers). It is always safe to free XLOPERs even if they did not use auxiliary memory, as long as you got them from Excel4 or Excel4v.

Example

This example calls GET.WORKSPACE(1) to return (as a string) the platform on which Microsoft Excel is currently running. The code copies this returned string into a buffer for later use. The standard strcpy function is not used to copy the string to the buffer because strcpy expects a null-terminated string and the returned value is a byte-counted string. The code places the buffer back into the XLOPER for later use with the Excel function. Finally, the code displays the string in an alert box.

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlFreeExample(void)
{
    XLOPER xRes, xInt;
    char buffer[10];
    int i, len;

    xInt.xltype = xltypeInt;
    xInt.val.w = 1;
    Excel(xlfGetWorkspace, (LPXLOPER)&xRes, 1, (LPXLOPER)&xInt);
    len = (BYTE)xRes.val.str[0];
    for(i = 0; i <= len; i++)
        buffer[i] = xRes.val.str[i];
    Excel(xlFree, 0, 1, (LPXLOPER)&xRes);
    xRes.val.str = buffer;

    Excel(xlcAlert, 0, 1, (LPXLOPER)&xRes);
    return 1;
}