⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node27.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 HTML
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by:  Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by:  Nikos Drakos, CBLU, University of Leeds* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from:  Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>3.7 Class EmbeddedTcl</TITLE><META NAME="description" CONTENT="3.7 Class EmbeddedTcl"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html"><LINK REL="previous" HREF="node26.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node26.html"><LINK REL="up" HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><LINK REL="next" HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html1535"  HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1529"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1523"  HREF="node26.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node26.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1531"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html1533"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html1536"  HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html">3.8 Class InstVar</A><B> Up:</B> <A NAME="tex2html1530"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html">3. OTcl Linkage</A><B> Previous:</B> <A NAME="tex2html1524"  HREF="node26.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node26.html">3.6 Class TclCommand</A> &nbsp <B>  <A NAME="tex2html1532"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1534"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H1><A NAME="SECTION02170000000000000000"></A><A NAME="sec:EmbeddedTcl"></A><BR>3.7 Class EmbeddedTcl</H1><P>permits the development of functionality in either compiled code,or through interpreter code, that is evaluated at initialization.For example, the scripts tcl-object.tcl or the scripts intcl/lib.Such loading and evaluation of scripts is done through objects in theEmbeddedTcl../Tcl/Tcl.h.<P>The easiest way to extend  is to add OTcl codeto either tcl-object.tcl or through scriptsin the tcl/lib directory.Note that, in the latter case,  sourcestcl/lib/ns-lib.tcl automatically, and hencethe programmer must add a couple of lines to this fileso that their script will also get automatically sourced by  at startup.As an example,the file tcl/mcast/srm.tcl defines some of the instance proceduresto run SRM.In tcl/lib/ns-lib.tcl, we have the lines:<PRE>        source tcl/mcast/srm.tcl</PRE>to automatically get srm.tcl sourced by  at startup.<P>Three points to note with EmbeddedTcl code are thatfirstly, if the code has an error that is caught during the eval,then  will not run.Secondly, the user can explicitly override any of the code in the scripts.In particular, they can re-source the entire script after making their ownchanges. Finally, after adding the scripts to tcl/lib/ns-lib.tcl, andevery time thereafter that they change their script, the usermust recompile  for their changes to take effect.Of course, in most cases<A NAME="tex2html8"  HREF="footnode.html#foot729" tppabs="http://www.isi.edu/nsnam/ns/doc/footnode.html#foot729"><SUP>3.4</SUP></A>,the user can source their scriptto override the embedded code.<P>The rest of this subsection illustratehow to integrate individual scripts directly into .The first step is convert the script into an EmbeddedTcl object.The lines below expand ns-lib.tcl and create the EmbeddedTcl objectinstance called <TT>et_ns_lib</TT>:<PRE>        tclsh bin/tcl-expand.tcl tcl/lib/ns-lib.tcl | \bs                               ../Tcl/tcl2c++ et_ns_lib \&gt; gen/ns_tcl.cc</PRE>The script, bin/tcl-expand.tcl../ns-2/tcl-expand.tclexpands <TT>ns-lib.tcl</TT> by replacing all <TT>source</TT> lineswith the corresponding source files.The program, tcl2cc.c../Tcl/tcl2c++.c.html,converts the OTcl code into an equivalent EmbeddedTcl object, <TT>et_ns_lib</TT>.<P>During initialization, invoking the method <TT>EmbeddedTcl::load</TT>explicitly evaluates the array.<DL COMPACT><DT>--<DD>tcl-object.tcl../Tcl/tcl-object.tcl  is evaluated by the method  Tcl::init../Tcl/Tcl.ccTcl::init;  []Tcl_AppInit../ns-2/tclAppInit.cc::Tcl_AppInit  invokes []Tcl::Init.  The exact command syntax for the load is:  <PRE>        et\_tclobject.load();</PRE><DT>--<DD>Similarly,  tcl/lib/ns-lib.tcl../ns-2/tcl/lib/ns-lib.tcl  is evaluated directly by <TT>Tcl_AppInit</TT> in ns_tclsh.cc.  <PRE>        et\_ns\_lib.load();</PRE></DD></DL><P><HR><!--Navigation Panel--><A NAME="tex2html1535"  HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1529"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1523"  HREF="node26.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node26.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1531"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html1533"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html1536"  HREF="node28.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node28.html">3.8 Class InstVar</A><B> Up:</B> <A NAME="tex2html1530"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html">3. OTcl Linkage</A><B> Previous:</B> <A NAME="tex2html1524"  HREF="node26.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node26.html">3.6 Class TclCommand</A> &nbsp <B>  <A NAME="tex2html1532"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1534"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <!--End of Navigation Panel--><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -