In XOTclIDE there are three ways to import your existing Tcl sources into XOTclIDE components. This section describes how these importing function work and what their limits are. Generally if your Tcl program is well structured and has no commands or a few commands in the global script context other than class or procedure definitions the importing works out of the box.
There are two main importing functions in XOTclIDE, both accessible from the Component Browser
package require name.
-> With this function you can load any Tcl package accessible in your Tcl system by callingsource filename.
-> This importing function can evaluate any script in the file system. It is the same as using the commandThe importing functions in XOTclIDE do not parse Tcl scripts but evaluate them with the Tcl Interpreter. Therefore the importing works very reliably. Any package or script can be loaded into XOTclIDE. XOTclIDE tracks the definition of Tcl procedures with the proc name arguments body command and the definition of XOTcl Classes, Objects and their instance methods and class methods. The importing tracker notices every newly defined procedure, creates components, and adds the procedure to this component. All procedures are also normally evaluated by Tcl interpreter. The importing tracker does not notice any other script evaluation in the global context.
Let's examine a Tcl script in the file myapp.tcl that should be imported.
# This is great script that I want to reuse in XOTclIDE # Author: old Tcl'er # Revision: package require Tk # set debug 1 set color red set configfile myapp.conf if {![file exists $myapp.conf]} { # error "can not find config file $configfile" } # Starting Application # parameters: None proc startApp {} { button .re -text "Quit" -command "quite" # ... your program } ... many other defined procedures # next line starts the application startApp
The importing function will create a new component with the name myapp with all your procedures. The new component can be seen as follows
# automatically generated from XOTclIDE package provide importExample 0.1 @ tclproc startApp idemeta struct importExample default proc startApp {} { # button .re -text "Quit" -command "quite" # ... your program }
As you see, all comments, global context commands and the application starting command are lost. Comments (# lines) in the global context are not imported during evaluation because Tcl ignores them. You can use the comment importer (see the section called “Importing Tcl comments”) to add these comments to the component.
Another problem is the evaluation of Tcl commands in the global context. In XOTclIDE you should have just one such line coded in the configuration map (see the section called “Configurations Management”). To enable proper import the definition block should be moved to a special new procedure. The example above could appear as follows:
# This is great script that I want to reuse in XOTclIDE # Author: old Tcl'er # Revision: package require Tk # set debug 1 proc defineGlobalConstans {} { global color configfile set color red set configfile myapp.conf } proc checkConfigFile {} { global configfile if {![file exists $configfile]} { # error "can not find config file $configfile" } } # Starting Application # parameters: None proc startApp {} { button .re -text "Quit" -command "quite" # ... your program } proc basicStartApp {} { defineGlobalConstans checkConfigFile startApp } ... many other defined procedures # next line start the application basicStartApp
In this case we have only one line with direct script evaluation and this can be imported into XOTclIDE without losing information. I think good Tcl programs should be written this way - no evaluation in the global context - anyway.
To import a regular tcl package use menu Component Browser. A new component with the same name as the imported package will be created, along with nested packages that are loaded from the imported package using package require.
-> in
Newly created components will have names that correspond to the script file name, without extension. Any nested script evaluation or package require commands are respected. Before sourcing the script XOTclIDE changes the working directory to the path of the script file. The application will start normally. A problem may appear when the application uses a toplevel window, as the toplevel window is already used by the XOTclIDE Transcript window. If an error occurs while importing, importing is interrupted with the error message.
Procedures defined in the :: namespace will be added to a Tcl-Proc-Group named “default”. Procedures with names “mynamespace::myname” with be added to a Tcl-Proc-Group named “mynamespace”.
Another way to import your application is to start XOTclIDE from your application and introspect it with XOTclIDE. XOTclIDE can import procedures and XOTcl object classes directly from a running Tcl interpreter. To start XOTclIDE from your application you can use the START.tcl script in the XOTclIDE directory. Change the working directory to the XOTclIDE directory with the START.tcl script.
To import code from your running application you must first create a new component where all procedures and classes from the Interpreter will be stored. To import a Tcl procedure from the Tcl interpreter, first select the component where you want to import to and use menu Component Browser
-> -> inTo import XOTcl Classes from the Interpreter select the component and choose menu Component Browser
-> -> inAlthough importing an application like this is more work, it's a good choice if you want to import only part of an application or the application is not in a readable format.
Consider the example below
# This procedure make magic initialization of # X Module. # Warning: proc initModuleX {{path {}} { # # }
The three line comment belongs to procedure initModuleX. XOTclIDE has a special parser that can scan Tcl script files and associate the comments to previously imported components. To launch the # Comments Scanner use the menu
-> -> Unlike the source importer, this tool does not evaluate the selected scripts but scans all lines after a leading # character.
One of main advantages of XOTclIDE is easy customizing of XOTclIDE for users needs. Many of XOTclIDE components are loaded dynamic at runing time only on demand. In menu
-> are all currently registered plug-ins accesible. The plug ins are normal components the registration and start scripts are specified per file pluginslist.txt in XOTclIDE directory.Following Plug-Ins are currently delivered with XOTclIDE
Unit Test Framework programmed after Smalltalk SUnit (JUnit, NUnit). See also Unit Tests Homepage
Tests of XOTclIDE itself
Small XOTcl Application taken from Tcl Wiki
Generate HTML Source Code Documentation from Source Comments
Importing tool described in the section called “Importing Tcl comments”
Can import code sniplets form Tcl wiki Tcl Wiki
This tool extend the functionality of Application Deployer Wizard. It can generate TclKit Distributions or standalone Starpacks directly from XOTclIDE. It work properly only form XOTclIDE TclKit version or if TclKit envirorment are installed properly in your Tcl system
This tool can inspect all Tk windows. It can be used to view and change all configuration of every Tk window. Tk Inspector includes also widget serializator that can be used to serialize every windows and their descend to Tcl script that can be used as code snippet.
Ideal for edit and test short Tcl-scripts that all contents are evaluated in global context. You can use all advantages of XOTclIDE: syntax highlighting, syntax check, code completion. The script can be evaluated in slave interpreter.
GUI helper for SQL access to all databases supported by XOTclIDE. Additional 2 Lists-Views show all table names and columns names (schema of DB). The result will be displayed in TkTable-Widget. Every cell can be also viewed in separately view.
This plug-in is adapted GPL program written by L. Riesterer original source