Map names in expressions
Map names in expressions that are used in map rules represent calls to functional maps.
The syntax of a functional map call in an expression is the same as the syntax of a function:
FunctionalMapName ( argument1 , argument2 , ... argumentn )
At run time, when a rule calls a functional map, the functional map writes the output, in the format defined by its output card type, directly to the output of the executable map. The functional map also places the information about the type or types that it builds in the output work file of the executable map, if necessary. So the type that the functional map builds is the type of the output card of the functional map, which must match the output type of the rule on which the functional map call is placed.
When the output type of the functional map is a group, map build analysis verifies that the type of the output card of the functional map matches the output type of the rule on which the call is placed. When the output type of the functional map is an item, map build analysis checks that the item classes match, but it does not require that the type of the output card of the functional map be the exact same type as the output type of the rule on which the functional map call is placed. Because of this way that map build analysis operates, functional maps can behave more like subroutines. You can use the same functional map to build various output objects that all have the same characteristics, as long as you do not try to reference the output objects of the calling rules in later rules.
A functional map does not behave like a function because when the functional map completes processing, it has already written its output to the output of the calling rule. That calling rule cannot access the data that the functional map built. This behavior is different from the behavior of a function call, which returns the value that the function produced to the point of invocation. The calling rule can manipulate the value that a function returned. The calling rule cannot manipulate the value that a functional map produced.
When the output of a functional map is an item, you can use the ASFUNCTION general function to return the output to the invoking map rule instead of to the output card.
Since the type that the functional map builds is the type of the output card of the functional map, later references to the output type of the rule, in subsequent rules, cannot work properly unless the type of the output card of the functional map exactly matches the output type of the rule. If the rule is on some type, for example, A, and the output type of the functional map is some different type, for example, B, the object that is reflected in the work file for the rule is B. If a subsequent rule tries to reference the instance of type A, that reference returns NONE.
The following examples show two ways, one that is valid and one that is not valid, to specify map rules that use map names in expressions. For both examples, the names of the functional maps are prefixed by F_.
Valid example:
=IF (A > 10, F_BigMap (X), F_LittleMap (Y))
This example is valid because the rule does a comparison on an item, and then calls one of two functional maps, which sends the results directly to the output of the executable map. If the value of A is greater than 10, the rule calls the F_BigMap functional map; otherwise, the rule calls the F_LittleMap functional map.
Not valid example:
=IF (F_Map (A) > 10, F_BigMap (X), F_LittleMap (Y))
This example is not valid because the rule attempts to use the output of the F_Map functional map in a comparison. The rule calls the F_Map functional map, and after F_Map completes processing, it writes the results directly to the output of the executable map. The value that F_Map produced is not available to the calling rule; therefore, the rule cannot perform the comparison operation.