After you have installed XLL+, follow these instructions for the quickest possible introduction to using XLL+. You can find out more about any of the steps by clicking on the "More..." links.
On the Tools menu, click the New XLL+ Function item and then fill in the function's name, and press OK.
-999.9
.
As with all the example code in this guide, the code which the developer should add
is shown in inverse.
CXlOper* HISTVOL_Impl(CXlOper& xloResult, const CXlOper* Prices_op, double DaysPerYear) { // 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 // TODO - set the value of xloResult, or return another value // using CXlOper::RetXXX() or throw a CXlRuntimeException. xloResult = -999.9; return xloResult.Ret(); }In a real-world example, you would now pass the inputs to a useful function, and return the result, or handle any errors. For example, you might add the try-catch block shown below:
CXlOper* HISTVOL_Impl(CXlOper& xloResult, const CXlOper* Prices_op, double DaysPerYear) { // 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, DaysPerYear); } catch(...) { xloResult = xlerrValue; } return xloResult.Ret(); }
For a more thorough introduction to XLL+, read through the topics in the Getting Started section.