The source code has now been modified.
CXlOper* HISTVOL_Impl(CXlOper& xloResult, const CXlOper* Prices_op, const CXlOper* DaysPerYear_op) { // Input buffers std::vector<double> Prices; double DaysPerYear; // Validate and translate inputs XlReadVector(*Prices_op, Prices, L"Prices", XLA_TRUNC_ONEMPTY| XLA_TRUNC_ONBLANK); XlReadScalar(*DaysPerYear_op, DaysPerYear, L"DaysPerYear", XLA_DEFAULT_EMPTY, 250.0); // End of generated code //}}XLP_SRC try { xloResult = CalcHistVol(Prices, DaysPerYear); } catch(const char*) { xloResult = xlerrNum; } return xloResult.Ret(); }
const CXlOper*
)
and name (to DaysPerYear_op
).double DaysPerYear
, has been declared.DaysPerYear
from
DaysPerYear_op
.All the work is done by XlReadScalar, using the value (250.0) that we specified in the Function Wizard.
DaysPerYear_op
contains a numeric value,
then it will be converted to a double
and put into the local variable DaysPerYear
.DaysPerYear
.double
, then an exception of type CXlRuntimeException
will be thrown, and the function will exit immediately. The exception will contain a message such as
"Expected number for DaysPerYear
".
There is no need to change your code; the Function Wizard's changes will do all the work.
This technique can also be used to read in optional boolean, integer and string values, or for values of any type, including extended types.