File: tlib-ch5.htm

package info (click to toggle)
aolserver 3.4.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 22,692 kB
  • ctags: 33,612
  • sloc: ansic: 171,340; tcl: 10,218; sh: 3,821; cpp: 2,779; makefile: 2,041; yacc: 1,648; perl: 456; php: 13
file content (83 lines) | stat: -rw-r--r-- 4,188 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<HTML><HEAD>
<TITLE>Tcl Libraries   -- Tcl-only Modules</TITLE>
<LINK rel=Previous href="tlib-ch4.htm">
<LINK rel=ToC href="toc.htm">
<LINK rel=Index href="master.htm">
<LINK rel=Next href="tlib-ch6.htm">
</HEAD><BODY BGCOLOR="#ffffff"><A NAME="topofpage"></A>
<TABLE WIDTH=100%>
  <TR>
    <TD ALIGN=LEFT>
      <A NAME="topofpage"></A> <IMG  SRC="as-c-sm.gif">
    </TD>
    <TD ALIGN=RIGHT>
      <A href="tlib-ch4.htm"><IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
      <A href=toc.htm> <IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
      <A href=master.htm> <IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
      <A href="tlib-ch6.htm"> <IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
      <A name="7983"> </A>
    </TD>
  </TR>
</TABLE>

<a name="14887">
</a><h3>Tcl-only Modules</h3>
<p><a name="14891">
</a>As described in the <a href="tlib-ch3.htm#13548">"Tcl Libraries" section</a>, 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:</p>
<pre>    <a name="14892"></a>/home/mydir/tcl/a
    <a name="14893"></a>/home/mydir/tcl/a/nsdb
    <a name="14894"></a>/home/mydir/tcl/a/perm
</pre><p><p><a name="14895">
</a>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. </p>
<a name="14896">
</a><h4>Configuration for Tcl-only Modules</h4>
<p><a name="15958">
</a>To load a Tcl-only module, add the following line to your configuration file:</p>
<pre>    <a name="14898"></a>ns_section "ns/server/<i>servername</i>/modules"
    <a name="14899"></a>ns_param mytcl Tcl
</pre><p><p><a name="14900">
</a>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.</p>
<p><a name="14901">
</a>For Tcl-only modules, no C module file is loaded. Only the corresponding Tcl directories are initialized.</p>
<a name="14903">
</a><h4>Example of Tcl Initialization with Tcl-only Modules</h4>
<p><a name="14904">
</a>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:</p>
<pre>    <a name="14905"></a>ns_section "ns/server/S1/modules"
    <a name="14906"></a>ns_param M1 Tcl
</pre><p><p><a name="14907">
</a>The library for server S1 (/servers/S1/modules/tcl) contains these files:</p>
<pre>    <a name="14908"></a>abc.tcl
</pre><p><p><a name="14914">
</a>The library for module M1 (/servers/S1/modules/tcl/M1) contains these files:</p>
<pre>    <a name="14915"></a>init.tcl
    <a name="14916"></a>priv.tcl
    <a name="14917"></a>script1.tcl
</pre><p><p><a name="14922">
</a>The Tcl files will be sourced in this order:</p>
<pre>    <a name="17129"></a>/servers/S1/module/tcl/abc.tcl
    <a name="17130"></a>/servers/S1/module/tcl/M1/init.tcl
    <a name="14928"></a>/servers/S1/module/tcl/M1/priv.tcl
    <a name="14929"></a>/servers/S1/module/tcl/M1/script1.tcl
</pre><p>

<TABLE BORDER="2" CELLPADDING="1" width="100%">
<TR><TD COLSPAN=3><P ALIGN=Center>
<IMG SRC="bluebult.gif">
<A HREF="#topofpage">
<FONT SIZE=-1>Top of Page</FONT></A>
<IMG SRC="bluebult.gif">
</TD></TR>
<TR><TD COLSPAN=3><P ALIGN=Center>
<A href="tlib-ch4.htm">
<IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm>
<IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm>
<IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="tlib-ch6.htm">
<IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<BR align=center>
<FONT size=-1>Copyright &copy; 1998-99 America Online,
Inc.</FONT>
</TD></TR></TABLE></BODY></HTML>