Version 1 of Tcl Tutorial Lesson APP

Updated 2018-12-17 18:36:09 by arjen

Building and distributing applications

Once you have developed an application, say a database viewer or a chat program, you probably want to distribute it to other people. There are several ways to do that. One simple way is:

Have them install Tcl/Tk and give them the source code to your application. Then they can run your application like this:

     tclsh myapp.tcl


This way of invoking your program means that the working directory is (or should be) the directory containing the main source file and any files your application requires, such as other source files or files containing configuration data can be found relative to that working directory.

But what if the user wants to start your program in an arbitrary directory? She might put the command in a batch file or shell script, and store that in a convenient place that is found by the invocation mechanism, like one of the directories in the PATH environmental variable, something over which you have no control. To find out where your application is installed, you can use the global variable argv0, like in the lesson on command-line arguments or the command info script as explained in the lesson on modularization.

This gives you the opportunity to get all the directories right where to find the files your application uses and to make sure that all packages are included.