A.5   Tcl Code Outside Procedures

Tcl allows code that is not in a procedure. This code is interpreted immediately when the file is read by the Tcl interpreter. Aside from the global-variable initialization done in the globals block near the top of the file, collect all such material at the bottom of the file.

However, it improves clarity--when possible--to collect any initialization code in an initialization procedure, leaving only a single call to that procedure at the bottom of the file. This is especially true for dialog creation and initialization, and more generally for all commands related to graphic objects.

Tcl code outside procedures must also have a documentation heading, including the following blocks:

The following is a sample heading for Tcl code outside all procedures.

Example A-4:  Heading for Out-of-Procedure Tcl Code

##################################################################### 
# 01Spy.tcl - Initialization code 
# 
# This code is executed when the file is sourced. It executes the module 
# entry routine which does all the necessary initialization to get a 
# runnable spy utility. 
#  
 
# Call the entry point for the module 
 
spyInit