XLL+ Class Library (6.3)

Changes to the generated code

When you return to your source code, you will see that some of the generated code has been changed.

CopyC++
CXlOper* HISTVOL_Impl(CXlOper& xloResult, const CXlOper* Prices_op, doubleDaysPerYear)
{
    // Input buffers 
    std::vector<double> Prices;
    // Validate and translate inputs
    XlReadVector(*Prices_op, Prices, L"Prices", XLA_TRUNC_ONEMPTY|
        XLA_TRUNC_ONBLANK);
    // End of generated code 
//}}XLP_SRC 
    try
    {
        xloResult = CalcHistVol(Prices, 250.0);
    }
    catch(const char*)
    {
        xloResult = xlerrNum;
    }
    return xloResult.Ret();
}

Notice that your code outside the //{{XLP_SRC delimiters is unchanged; all the changes occur within the delimiters, in the portion of the code that is "owned" by the XLL+ Function Wizard.

Make one more change to the function, to pass the new argument to our CalcHistVol(), as shown below:

CopyC++
CXlOper* HISTVOL_Impl(CXlOper& xloResult, const CXlOper* Prices_op, double 
    DaysPerYear)
{    
    ...

    try
    {
        xloResult = CalcHistVol(Prices, DaysPerYear);
    }
    catch(const char*)
    {
        xloResult = xlerrNum;
    }
    return xloResult.Ret();
}

The new release of the function is now complete, and ready for building and testing.

A cautionary note

Existing users of the function will be inconvenienced by this change, since they will now get a #NUM! error in all their existing spreadsheets.

In the next chapter, we will revisit this function, and replace DaysPerYear with an optional argument, which, if omitted, will be defaulted to 250. That way, the existing users are unaffected, and new users can choose to specify the days per year or to omit it, as they prefer.

Next: Adding an optional argument >>