Cross-Platform Scripts

Cross-platform support lets a Tcl/Tk script run unchanged on UNIX, Windows, and Macintosh. However, you could still have platform dependencies in your program. The most obvious is if your script executes other programs or uses C-level extensions. These need to be ported for your script to continue to work.

File Name Manipulation

File naming conventions vary across platforms. New file operations were added to help you manipulate file names in a platform-independent manner. These are the file join, file split, and file pathtype operations, which are described on page 103. Additional commands to copy, delete, and rename files were added in Tcl 7.6

Newline Translations

Windows and Macintosh have different conventions for representing the end of line in files. These differences are handled automatically by the new I/O subsystem. However, you can use the new fconfigure command described on page 221 to control the translations.

The tcl_platform Variable

In practice you may need a small amount of platform-specific code. The tcl_platform array holds information about the computer and operating system that your script is running on. This array is described on page 182. You can use a script file with the name of the platform to isolate all your platform-specific code. The following command sources either unix.tcl, windows.tcl, or macintosh.tcl from your script library:

source [file join $lib $tcl_platform(platform).tcl]

The console Command

The Windows and Macintosh versions of wish have a built-in console. The commands you enter in the console are evaluated in the main Tcl interpreter, but the console is really implemented in another Tcl interpreter to avoid conflicts. You can show and hide the console with the console command, which is described on page 28.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.98.190