Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 13.  Reflection and Debugging

Cross-Platform Support

Tcl is designed so that you can write scripts that run unchanged on UNIX, Macintosh, and Windows platforms. In practice, you may need a small amount of code that is specific to a particular platform. You can find out information about the platform via the tcl_platform variable. This is an array with these elements defined:

  • tcl_platform(platform) is one of unix, macintosh, or windows.

  • tcl_platform(os) identifies the operating system. Examples include MacOS, Solaris, Linux, Win32s (Windows 3.1 with the Win32 subsystem), Windows 95, Windows NT, and SunOS.

  • tcl_platform(osVersion) gives the version number of the operating system.

  • tcl_platform(machine) identifies the hardware. Examples include ppc (Power PC), 68k (68000 family), sparc, intel, mips, and alpha.

  • tcl_platform(isWrapped) indicates that the application has been wrapped up into a single executable with TclPro Wrapper. This is not defined in normal circumstances.

  • tcl_platform(user) gives the login name of the current user.

  • tcl_platform(debug) indicates that Tcl was compiled with debugging symbols.

  • tcl_platform(thread) indicates that Tcl was compiled with thread support enabled.

On some platforms a hostname is defined. If available, it is returned with the info hostname command. This command may return an empty string.

One of the most significant areas affected by cross-platform portability is the file system and the way files are named. This topic is discussed on page 103.

      Previous section   Next section