XLL+ Class Library

Bounded input arrays

The functions COper::ReadVector(), COper::ReadMatrix() CXlOper::ReadVector() and CXlOper::ReadMatrix() support the use of named bounding variables.

Bounding variables

If the plUBound argument of ReadVector() or the plUBound1 or plUBound2 arguments of ReadMatrix() are not zero, then they are used as pointers to a bounding variable.

Inner and outer bounds

The upper bound value will be treated as the size() of the vector, unless the XLA_BOUND_UBOUND_INNER bit of the lFlags argument has been set, in which case its value will be size() - 1 (following Visual Basic conventions).

Fixed upper bounds

If the bounding variable contains a value >= 0 before the call to ReadXXX(), then it will be treated as the required size of the vector/matrix. For example, if the variable contains 10, then the function ReadVector() will fail if the input variable does not contain exactly 10 non-empty items, and will return an error message like "#Error: Expected 10 items for Input".

Variable upper bounds

If the bounding variable contains -1 before the call to ReadXXX(), then its value will be set to the upper bound of the vector or matrix that has been read in.

Shared bounding variables

If a bounding variable is used by more than one call to ReadMatrix() or ReadVector(), then it can be used to ensure that all the arrays read in by these calls are the same size.

Consider the following example, with two vector inputs X and Y containing 3 and 5 cells respectively.

long lBound = -1;
std::vector<long> vecX;
std::vector<double> vecY;

// Because lBound contains -1, the call to X->ReadVector() will set its value.
bOk = bOk && X->ReadVector(vecX, "X", xloResult, &lBound);
// After reading X, lBound will be set to 3

// Because lBound now does not contain -1, the call to Y->ReadVector() will expect an upper bound of 3.
bOk = bOk && Y->ReadVector(vecY, "Y", xloResult, &lBound);
// The call will fail and an error string, "#Error: Expected 3 items for Y", will be returned.

Similarly, you can ensure that a matrix input is square, by assigning the same bounds to *plBound1 and *plBound2.

long lBound = -1;
xlp::matrix<long> matX;
bOk = bOk && X->ReadMatrix(matX, "X", xloResult, 0, &lBound, &lBound);

See matrix & vector flags for a full list of flag values.

See Also

COper::ReadVector() | COper::ReadMatrix() | CXlOper::ReadVector() | CXlOper::ReadMatrix() | matrix & vector flags