![]() |
![]() ![]() ![]() ![]() |
Creating new Tcl scripts is very easy. There are two ways to create Tcl scripts:
.tcl
extension that contains Tcl commands.
mytest.tcl
in the pages directory for a virtual server, just type
http://www.yourorg.com/mytest.tcl
in the URL field of your browser.
The results will be displayed in your page.
.tcl
file in your pages
directory, but it is more powerful. The statements that define the URL-handling
procedures and bind the procedures to URLs are normally stored in script
files in the appropriate subdirectory of the AOLserver home directory.
By default, all script files in this directory that end with the .tcl extension are automatically sourced by the AOLserver at server startup time. This process is termed Tcl Initialization. Because the statements included in the scripts files can normally be re-sourced at any time, it is possible to modify or add new script files to the Tcl directory while the server is running and re-initialize Tcl. The AOLserver provides an operation for this purpose, itself written in Tcl, which is accessed by opening the /NS/TclInit URL. Each of the AOLserver modules has it's own subdirectory in the Tcl directory, and you can specify that AOLserver initialize a specific subdirectory using /NS/TclInit/subdirectory. /NS/TclInit is not recursive in that it does not automatically initialize Tcl scripts in subdirectories below the one specified.
The AOLserver also provides operations for opening an
existing or new Tcl script in an HTML form where you can update it and submit
it for evaluation by the server. You can use any browser to create, edit,
and update your Tcl extensions. The easiest way to get started is to use
a browser to bring up the AOLserver Administration page. From AOLpress, go
to Tools
Administer Server, and select the name of your server (e.g.,
http://www.yourorg.com/
). From any other browser, go to the relative
URL /NS/Admin on your server (e.g., http://
www.yourorg.com/NS/Admin
). At the bottom of the page, follow the link
to Tcl Scripting, and then follow the link to View/Edit Shared Script Files.
The AOLserver lists all Tcl files in the Tcl subdirectory specified in the
configuration file with links to view and/or update those script
files.
Many of the basic AOLserver services are implemented as Tcl scripts. In fact, most of the database operations such as handling database inserts, queries, and updates, are written as Tcl scripts. You can easily modify the basic database operations by simply editing the Tcl scripts that implement the functionality.
The following section is a tutorial on developing new operations in the AOLserver Tcl interface. The examples are a quick and fun way to get to an overview of the Tcl scripting process.