XLL+ Class Library

COper::operator [] Example

//{{XLP_SRC(OperBraceExample)
    // NOTE - the FunctionWizard will add and remove mapping code here.
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(OperBraceExample, "RPH", "OperBraceExample", 
    "Vector,Index", "Example", "Demonstrates the use of COper::op"
    "erator[ ]", "Vector argument\000Zero-based index into"
    " vector\000", "\0\0", 1)

extern "C" __declspec( dllexport )
LPXLOPER OperBraceExample(const COper* lpopVector, USHORT
    usIndex)
{
    CXlOper xloResult;
//}}XLP_SRC

    BOOL bOk = TRUE;

    // Check that Arg1 is a vector, since operator[ ] 
    // demands that is a vector, and asserts if it is not.
    bOk = lpopVector->IsVector();
    // Check that Index is in range
    bOk = bOk && (usIndex >= 0);
    bOk = bOk && (usIndex < lpopVector->GetCount());

    // If all went well, extract the value.
    // Otherwise return an error.
    if ( bOk )
        xloResult = (*lpopVector)[usIndex];
    else
        xloResult = xlerrNA;
    return xloResult.Ret();
}

Uses

COper::operator [] | COper::GetCount | COper::IsVector