Initializing help system before first use

mmreflect

Topics covered in this chapter:

This module allows a model or package to programatically access Mosel entities whose names and types were not known at compile-time. To use this module, the following line must be included in the header of the Mosel model file:

 uses 'mmreflect'

New functionality for the Mosel language

The type iterator

This module provides the type iterator for enumerating the cells of an array without referring to its individual indices. This type acts as an indexer such that an entity of this type can be used as the only index of a compatible array for its dereferencing. Internally it maintains a reference to an array and a position in this array in the form of an index tuple. Before an iterator is used it must be initialised and bound to an array with a call to inititer (this association may be cancelled by resetting the entity with reset). The status of an iterator (e.g. whether it has been initialised, whether the enumeration has been completed) is returned by getstatus and positioning it to the next available cell of the array is achieved by calling nextcell. The index tuple held in an iterator can be accessed with getindices and setindices. The following example shows how to copy the content of array ar1 to array ar2 using an iterator:

 declarations
   ar1:dynamic array(S1:set of string,R1:range) of integer
   ar2:dynamic array(set of string,set of integer) of real
   itr:iterator
 end-declarations
 ar1('a',1):=10
 ar1('b',1):=20

 inititer(itr,ar1)           ! 'itr' is associated to 'ar1'
 while(nextcell(itr)) do     ! iterate over the existing cells of 'ar1'
   ar2(itr):=ar1(itr)        ! 'itr' can be used with both 'ar1' and 'ar2'
   writeln("indices:", itr.indices)
 end-do

Note that although the iterator itr is bound to array ar1, it can also be used to dereference ar2 since this array is compatible with ar1 in terms of number and type of its indexing sets.

The type reflecterror

An entity of type reflecterror is returned by certain functions of this module: it characterises the execution status of the function. The code and message associated to this status can be retrieved with getcode and getmsg, no error occurred if the code is 0.

This type is defined such that an expression of type reflecterror used as a statement will cause a runtime error if the status is not null and it will be ignored otherwise. Thanks to this property a function returning an entity of this type can be used either as a function or as a procedure: in the first case error management will be handled by the model and in the second case any error will cause a program termination.

 err:=callproc("myproc")
 if err.code<>0 then
   writeln("Failed to call 'myproc' (",err.msg,")")
   exit(1)
 end-if

Procedures and functions

Call a public function with the given name.
Call a public procedure with the given name.
Delete a cell of a dynamic array.
Check if a given entry in a dynamic array has been created.
Find a field of a record type.
Find an identifier in the dictionary.
Get the list of all public fields of a record type.
Get all identitifiers of a model.
Get all runtime parameters.
Get all identitifiers of a model for which annotations are available.
Get model annotations associated to a given symbol.
Get the value of a cell of an array.
Get the code associated to a reflect error.
Get the type ID of an element of a collection.
Get the name of a field of a record from its order number.
Get the type of a field of a record from its order number.
Get the value of a field in a record.
Retrieve the index tuple held in an iterator.
Get the message associated to a reflect error.
Retrieve the number of arguments required by a subroutine.
Retrieve the return type of a subroutine.
Retrieve the signature of a subroutine.
Get the status of an iterator.
Initialise an iterator.
Advance an iterator to the next cell of its array.
Set the value of a cell of an array.
Set the value of a field in a record.
Set the index tuple of an iterator.
Test the return value of findident.

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.