XLL+ Class Library (6.3)

CXllApp::GetNextFnAssoc() Example

This example returns an array containing a row of data about each function in the add-in library.

CopyC++
//{{XLP_SRC(GetFunctionList) 
    // NOTE - the FunctionWizard will add and remove mapping code here. 
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN3(GetFunctionList, GetFunctionList_4, GetFunctionList_12, "R!", 
    "U!", L"GetFunctionList", 0, L"", 0, L"Demo functions", 0, L"Returns a lis"
    L"t of all the functions contained in this add-in", 0, L"", 0, 0, L"{GetFu"
    L"nctionList,,,Returns a list of all the functions contained in this add-i"
    L"n,Demo functions,1,136,U,{},{},3,,0,0}", 1)
CXlOper* GetFunctionList_Impl(CXlOper&);

extern "C" __declspec(dllexport)
LPXLOPER12 GetFunctionList_12()
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(GetFunctionList_Impl(xloResult));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret12();
}
extern "C" __declspec(dllexport)
LPXLOPER4 GetFunctionList_4()
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(GetFunctionList_Impl(xloResult));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret4();
}

CXlOper* GetFunctionList_Impl(CXlOper& xloResult)
{
    // End of generated code 
//}}XLP_SRC 
 
    // Get an in-scope pointer to the application object
    XLL_FIX_STATE;
    CXllApp* papp = XllGetApp();

    // Create the result buffer
    xloResult.AllocArray(papp->GetFnCount(), 7);

    // Iterate through each function 
    // Write its properties into a row of the output array
    CXllApp::POSITION pos;
    CString sKey;
    CXllFn* pfn;
    USHORT usRow;
    for ( usRow = 0, pos = papp->GetStartFnPosition(); pos; usRow++)
    {
        papp->GetNextFnAssoc(pos, sKey, pfn);
        xloResult.Cell(usRow, 0) = pfn->m_stName;
        xloResult.Cell(usRow, 1) = pfn->m_stArgNames4;
        xloResult.Cell(usRow, 2) = pfn->m_stCategory4;
        xloResult.Cell(usRow, 3) = pfn->m_stHelpText4;
        xloResult.Cell(usRow, 4) = (double)pfn->m_usType;
        xloResult.Cell(usRow, 5) = pfn->m_stEntryPoint4;
        xloResult.Cell(usRow, 6) = pfn->m_stArgTemplate4;
    }

    // Return the array 
    return xloResult.Ret();
}

Uses

CXllApp::GetNextFnAssoc | CXllApp::GetFnCount | CXllApp::GetStartFnPosition