Use of the Init 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.

via Use of the Init function.

Advertisements
Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s