If we now return to the XLL+ Function Wizard,
we will find that the Date
type has been added
to the list of available argument types.
Let us examine the code that is generated for a date type:
CXlOper* DateFn_Impl(CXlOper& xloResult, double ValueDate_op) { // Input buffers long ValueDate; // Validate and translate inputs XlReadScalarEx(ValueDate_op, ValueDate, psl::DateConverter(), L"ValueDate"); // End of generated code
The validation function is slightly different from what we have seen before.
psl::DateConverter
.You will recall that this was the value of the extended type's ConverterType property.
The other change is that we now have a local variable
ValueDate
of the reqired date type, long
.
When the ValueDate argument is validated at run-time, we see some new behavior. If the argument is a number less than 30000, we get the error result:
#ERROR: Expected date for ValueDate
We can just as easily handle arrays of extended type values.
For example, we could have a vector input PaymentDates
:
This code is generated:
// Input buffers std::vector<long> PaymentDates; // Validate and translate inputs XlReadVectorEx(*PaymentDates_op, PaymentDates, psl::DateConverter(), L"PaymentDates", XLA_TRUNC_ONEMPTY|XLA_TRUNC_ONBLANK); // End of generated code
The local variable PaymentDates
is of type
std::vector<long>
, as is required.
Next, we will examine the converter class, since that is where all the work appears to be happening.