next up previous contents
Next: Use of the PageEnd function Up: The InitChange, ShowPage and PageEnd Previous: Use of the Change function

Use of the Init function

    A common use for the Init function is to set default values, when the module is invoked. Imagine you have an entry, which is for a user name. This entry should be initialized with the current users name. An approch for this could be:

...
set user [exec whoami]
Entry username -default user

This does however not work in two situations:

The module is bytecompiled
In this situation, the default values is set at the time when the module is being bytecompiled, and the default value will the be the name of the user, who bytecompile the module, and not the name of the user who is runing the module.
A default setup is given
If the user select a default setup, the -defaut switch is never read!

In both cases. you should use the Init function:

...
Entry user
...
Init {
  set user [exec whoami]
}

When the init function is called, while importing an export file, the variable loadingExports is set to 1.



Jesper Kjær Pedersen <blackie@imada.ou.dk>
Wed Oct 2 13:29:53 MET DST 1996