When you want to embed a Tclet inside a web page, just follow these three simple steps:
First, use a text editor to write the Tclet to a file whose name ends
with the extension .tcl.
Second, write an HTML file containing an embed statement that refers to the Tcl file.
Third, upload these two files to your web site, and you're done!
You'll notice that there is no special step to prepare your Tclet for execution by the Tcl plugin. That's because Tcl is an interpreted language. What this means to you is that you just write the Tclet to a file as explained in the first step above, and it's immediately ready to be used.
Now I'll explain how this works: how your Tclet gets to be running inside a browser on someone else's computer across the Internet when they visit your page. Magic!
As I mentioned several times already, Tclets are little programs embedded inside web pages. Web pages are implemented by HTML files, which contain special formatting codes to let the browser know what to display and where. One of the statements defined by the HTML language is the embed tag. It looks like this:
<embed src=somefile.tcl width=100 height=100 ...>
When the browser sees this, it fetches the file somefile.tcl, the value of the src argument, from the same site that the page was loaded from and invokes the Tcl plugin to handle its display. The browser determines which plugin to invoke to handle each file in an embed statement, by looking at the file extension and invoking the plugin registered for that extension. When you installed the Tcl plugin, it registered itself so that it would be invoked whenever a file with a .tcl extension is mentioned in an embed statement.
The value of the src argument is actually a URL used to locate the file containing the Tclet on some web server. The example above uses a relative URL, which will be resolved relative to the URL of the file containing the embed statement. The example URL above will resolve to the file somefile.tcl in the same directory where the web page is stored. You can also use absolute URLs, such as http://www.sunlabs.com/tcl/plugin/simple.tcl. This allows you to use anyone else's Tclets in your own web pages if you wish and as long as they allow you.
By the way, please feel free to re-use any of the Tclets on this site, either by referencing them here, or by copying them to your own site. They're yours for the taking. Near each Tclet you'll see the symbol. Clicking on it will lead you to a page with the listing of the Tclet. Save the page to a local file on your machine and you've just copied the Tclet. Couldn't be easier.
The values of the other arguments shown above, width and height are used by the browser to allocate a screen area for use by the Tclet. The Tclet will use this area to draw itself and interact with the user.