Function call
Function calls look similar to function definitions. If you define this function:
int Sqr(int x) { return x * x; }
You can call it in another function such as:
void Calculate() { int result = Sqr(4); }
When calling functions BI# tries to determine the target function by using its name and the argument types. If the argument types do not match exactly, BI# will try to find a matching function by converting the arguments. If you define this function, for example:
double Sqr(double x) { return x * x; }
You can call it with an
int
argument and BI# will convert it to
a
double
automatically:
void Calculate() { double result = Sqr(4); }
BI# provides two variations of function calls. The first variation is
the
cached
keyword, which can be applied to
functions that can potentially cache their results. This can speed up your
processes tremendously. For example, the
OLAPGetElementList()
function is able
to cache its results, so it performs real work only at the first call and for
all subsequent calls it can return the cached results:
void Process(OLAPConnection connection) { OLAPElementList result = cached OLAPGetElementList( connection, "dimension1", true ); }
At the moment you can apply the
cached
keyword to these functions:
-
OLAPGetElementList
-
OLAPCellReadNumber
-
OLAPCellReadString
-
OLAPGetStringAttribute
-
OLAPGetIntAttribute
-
OLAPGetDoubleAttribute
-
OLAPGetChildElementList
-
OLAPCellReadComment
Another function call variation is the
async
keyword that runs a function
asynchronously.
void LogMessage(string message) { async WriteLine(message); }
In the
LogMessage()
function above, BI# runs
the
WriteLine()
function asynchronously,
that is, the function returns immediately and BI# continues with the next
function, while the runtime system runs
WriteLine()
in the background.
At the moment, the support for
async
is experimental.