15 import
The use of a module in another module or dialog is started with the keyword import.
The keyword is followed by the logical name of the module. The logical name usually is not the name of the module itself. Sometimes it is even possible to use one and the same module with different logical names in a module although this can be described in a better and more elegant way by using models. The logical name of the imported module is followed by a string bearing the name of the interface file.
Definition
{ export | reexport } import { <Identifier> } "<file name>"
{
object-specific attributes>
}
See also
For further information please read about the object module or refer to chapter “Modularization” of manual “Programming Techniques”.
Events
none
Children
Parent
Menu
none
15.1 Attributes
|
Attribute |
RLD |
PID |
Properties |
Short Description |
|---|---|---|---|---|
|
application |
application |
S,G/D/C |
functions of the module to be loaded are to be linked to this application |
|
|
object |
document |
S,G/-/- |
accesses the I-th XML Document |
|
|
boolean |
boolean |
-,G/-/- |
returns if the object class is an USW class |
|
|
class |
class |
-,G/-/- |
returns the I-th registered USW class |
|
|
object |
record |
S,G/-/C |
accesses the first record of an object |
|
|
integer |
integer |
-,G/-/- |
current index of object in the children list of its parent |
|
|
object |
record |
S,G/-/C |
accesses the last record of an object |
|
|
boolean |
boolean |
S,G/D/C |
loading state of the module |
|
|
object |
record |
S,G/-/C |
accesses the I-th record of an object |
|
|
integer |
integer |
-,G/-/- |
queries the number of child records |
|
|
boolean |
boolean |
S,G/D/C |
module can be unloaded |
15.2 Specific Attributes
A module can be loaded into another module in different ways. Loading here implies that not only the object names but also their definitions are known to the module and can thus be displayed and changed. Internally there are three different kinds of loading some of which are already determined by the objects defined or exported in the module.
-
The module is loaded immediately. You cannot influence the time when the module is loaded, as objects from the module are needed immediately (default); others are needed when superordinate modules are read. This applies when the module contains exported necessary models and resources.
-
The module will be loaded only if an exported object out of the module is really needed, e.g. if the object is accessed in a rule by reference or query.
-
In this case you yourself decide whether you want the module to be loaded. For this purpose you have to set the attribute .load to true at the logical module name (import name). The module will then be loaded and made available by the Dialog Manager.
Example
module Modul
import Colors "color.if";
window W
{
.bgc Green; // load on use
}
on W focus
{
this.bgc := Red; // implicit load
}
on W select
{
Colors.load := true; // explicit load
}
Load on use is preferred to the other loading types. Implicit load is preferred to explicit load. In the example above load on use is carried out, i.e. the other types have no effect any longer as the module is already in the memory and the rules can be executed directly.
Explicit load can be specified as attribute already at the import.
module Modul
import Colors "color.if"
{
.load true; // explicit load
}
15.3 Example
!! Interfacefile: module.if
module Module
export import StandardColor "color.if";
...
import Colors "PRIVLIB:mycolor.if";
// The file mycolor.if is only searched
// in the path PRIVLIB