Database Reference
In-Depth Information
:: -- additional code
:: -- additional code
Benefits = Salary * vBlendedRate;
:: -- additional code )
ENDFIX
There are quite a few interesting things going on with this script. First, a rate data-
base is used instead of co-mingling the rates with the other accounts in the Employee
database. In most cases, rates are not multidimensional and only bloat the dense block
needlessly. Secondly, a variable is used to control when the rate is retrieved from the
Emp_rate database. variable vInitialize is set to zero when it is defined. It is still zero
when the first employee is processed so the blended rate is retrieved and saved in vari-
able vBlendedrate. variable vInitialize is set to any value other than zero so that the
Blended rate will not be fetched again for the life of the script. variable vBlendedrate
can now be used like any other member, but with much less processing overhead than
@xrEF. It is worth noting that the scope of a variable is the entire script. If there were
additional FIx statements in this script, the value of vBlendedrate persists.
Another handy feature of variables is the array variable. In the spirit of honesty, I
never used array variables and, in fact, did not know how they worked until I started
researching this chapter. The array documentation is pretty weak. After much experi-
mentation, I got arrays to work and I must say that they are pretty slick. Arrays are
defined in the first part of a script much like single dimensional variables.
What makes the variable an array is the association with a dimension. For example,
the Scenario dimension in Sample.Basic has four members. If the application called for
there to be a different blended rate for both Actual and Budget, an array works perfectly.
Array variables can be defined in a number of ways.
ARRAY vaBlendedRate[Scenario];
This defines an array named vaBlendedrate that has four occurrences (Actual,
Budget, variance, variance %). The array can be initialized at definition by any of the
following:
ARRAY vaBlendedRate[Scenario] = {.3,.35,0,0};
ARRAY vaBlendedRate[Scenario] = {.3,.35};
Both statements are the same. They evaluate as Actual = .3, Budget = .35. variance = 0,
variance % = 0. Providing values for the variance and variance % make little sense as
they are dynamic.
Arrays values also can be set in code. Fix on a single cell to set the value for better
performance. to set the value, arrays need to be in a member calculation block. here are
examples of setting the Actual and Budget occurrences:
ARRAY vaBlendedRate[Scenario];
FIX (Jan,Sales)
Actual (
vaBlendedRate = .3;
)
ENFIX
FIX (Jan,Sales)
Search WWH ::




Custom Search