XLL+ Class Library (6.3)

CXlOper::FromNumericVector2() Example

CopyC++
// Function:    IntArray 
// Purpose:     Returns an integer array 
 
//{{XLP_SRC(IntArray) 
    // NOTE - the FunctionWizard will add and remove mapping code here. 
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN3(IntArray, IntArray_4, IntArray_12, "RH", "UH", L"IntArray", 0, 
    L"Type", 0, L"14", 0, L"Returns an integer array", 0, L"Integer type: 0=sh"
    L"ort;1=USHORT;2=int;3=unsigned int;4=long;5=unsigned long\0", 0, 0, L"{In"
    L"tArray,,,Returns an integer array,14,1,132,U,{{0,{Type,Unsigned Short In"
    L"t,0,,Integer type: 0=short;1=USHORT;2=int;3=unsigned int;4=long;5=unsign"
    L"ed long,,,,}}},{},3,,0,0}", 1)
CXlOper* IntArray_Impl(CXlOper&, unsigned short int);

extern "C" __declspec(dllexport)
LPXLOPER12 IntArray_12(unsigned short int Type)
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(IntArray_Impl(xloResult, Type));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret12();
}
extern "C" __declspec(dllexport)
LPXLOPER4 IntArray_4(unsigned short int Type)
{
    XLL_FIX_STATE;
    CXlOper xloResult;
    try {
        CXlStructuredExceptionHandler _seh_;
        xloResult.HandleResult(IntArray_Impl(xloResult, Type));
    }
    catch(const CXlRuntimeException& ex) {
        CXllApp::Instance()->DisplayException(xloResult, ex);
    }
    return xloResult.Ret4();
}

CXlOper* IntArray_Impl(CXlOper& xloResult, unsigned short int Type)
{
    // End of generated code 
//}}XLP_SRC 
 
    switch (Type)
    {
    case 0:
        {
            std::vector<short> v;
            for (short i = -5; i < 5; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    case 1:
        {
            std::vector<USHORT> v;
            for (USHORT i = 0; i < 10; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    case 2:
        {
            std::vector<int> v;
            for (int i = -5; i < 5; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    case 3:
        {
            std::vector<unsigned int> v;
            for (unsigned int i = 0; i < 10; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    case 4:
        {
            std::vector<long> v;
            for (long i = -5; i < 5; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    case 5:
        {
            std::vector<unsigned long> v;
            for (unsigned long i = 0; i < 10; i++)
                v.push_back(i);
            xloResult.FromNumericVector2(v);
        }
        break;
    default:
        throw CXlErrorException(xlerrValue);
    }
    return xloResult.Ret();
}

Uses

CXlOper::FromNumericVector2