[ Previous ] [ Contents ] [ Index ] [ Next ]

Tcl-only Modules

As described in the "Tcl Libraries" section, you can define a Tcl directory for each server. However, none of the subdirectories under the Tcl directories will be initialized unless you load a corresponding module. For example, if the ServerA server has a Tcl directory defined as /home/mydir/tcl/a, and the nsdb and perm modules are loaded, then the following directories will be initialized as server start-up:

    /home/mydir/tcl/a
    /home/mydir/tcl/a/nsdb
    /home/mydir/tcl/a/perm

If you want another directory under /home/tcl/a that contains Tcl scripts to be initialized also, you must load a Tcl-only module for it into the server using the "Tcl" keyword.

Configuration for Tcl-only Modules

To load a Tcl-only module, add the following line to your configuration file:

    ns_section "ns/server/servername/modules"
    ns_param mytcl Tcl

Then, at server start-up, the /home/mydir/tcl/a/mytcl directory will be initialized too. You can load any number of Tcl-only modules into a virtual server to have the Tcl scripts in the corresponding directories initialized.

For Tcl-only modules, no C module file is loaded. Only the corresponding Tcl directories are initialized.

Example of Tcl Initialization with Tcl-only Modules

This example shows demonstrates the order in which Tcl scripts are initialized at startup time for a server. The Library parameter is not set, so the library for S1 defaults to /servers/S1/modules/tcl. A Tcl-only module called M1 is loaded for S1 as follows:

    ns_section "ns/server/S1/modules"
    ns_param M1 Tcl

The library for server S1 (/servers/S1/modules/tcl) contains these files:

    abc.tcl

The library for module M1 (/servers/S1/modules/tcl/M1) contains these files:

    init.tcl
    priv.tcl
    script1.tcl

The Tcl files will be sourced in this order:

    /servers/S1/module/tcl/abc.tcl
    /servers/S1/module/tcl/M1/init.tcl
    /servers/S1/module/tcl/M1/priv.tcl
    /servers/S1/module/tcl/M1/script1.tcl

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.