XLL+ Class Library (6.3)

CXlOper::Coerce() Example

CopyC++
// Function:    CoerceEx 
// Purpose:     Uses CXlOper::Coerce to return the contents of a cell 
 
//{{XLP_SRC(CoerceEx) 
    // NOTE - the FunctionWizard will add and remove mapping code here. 
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN3(CoerceEx, CoerceEx_4, CoerceEx_12, "RCA", "UC%A", L"CoerceEx", 
    0, L"Address,A1", 0, L"Example", 0, L"Uses CXlOper::Coerce to return the c"
    L"ontents of an address", 0, L"Address of a cell\0TRUE if address is in A1"
    L" format, FALSE if it is in R1C1 format\0", 0, 0, L"{CoerceEx,,,Uses CXlO"
    L"per::Coerce to return the contents of an address,Example,1,128,U,{{0,{Ad"
    L"dress,String,0,,Address of a cell,,,,}},{0,{A1,Boolean,0,,\"TRUE if addr"
    L"ess is in A1 format, FALSE if it is in R1C1 format\",,,,}}},{},3,,0,0}", 1)
CXlOper* CoerceEx_Impl(CXlOper&, const CXlStringArg&, BOOL);

extern "C" __declspec(dllexport)
LPXLOPER12 CoerceEx_12(const XCHAR* Address, BOOL A1)
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    CXlStringArg Address__port(Address);
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(CoerceEx_Impl(xloResult, Address__port, A1));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret12();
}
extern "C" __declspec(dllexport)
LPXLOPER4 CoerceEx_4(const char* Address, BOOL A1)
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    CXlStringArg Address__port(Address);
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(CoerceEx_Impl(xloResult, Address__port, A1));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret4();
}

CXlOper* CoerceEx_Impl(CXlOper& xloResult, const CXlStringArg& Address, BOOL A1)
{
    // End of generated code 
//}}XLP_SRC 
 
    // Attempt to convert the address to a reference
    CXlOper xloRef;
    if (!xloRef.MakeRef(Address, A1))
        return CXlOper::RetError(xlerrValue);

    // Coerce the reference to a value
    xloResult.Coerce(xloRef);

    return xloResult.Ret();
}

Uses

CXlOper::Coerce | CXlOper::MakeRef