Introduction
The xreflect module allows a package to programatically access Mosel entities whose names and types were not known at compile-time. For example, this allows a developer to write a function to increment each value in a named array by 1, regardless of the type or index sets of the array.
Limitations
xreflect can only operate on entities of the following types:
- boolean
- integer
- real
- string
- set of boolean
- set of integer
- set of real
- set of string
- array of boolean
- array of integer
- array of real
- array of string
Additionally, xreflect can only access entities declared as public, for example in a public declarations block.:
public declarations myArray: array(range) of string end-declarations
Namespace
All types and subroutines exported by the xreflect module are part of the xreflect namespace; your model or package will need to reference this namespace in order to use this functionality. For example:
model myModel uses 'xreflect' nssearch xreflect public declarations myArray: array(range) of string end-declarations writeln('Type of values in myArray: ',getvaluetype('myArray')) end-model