How should I then code if I want my program to run on most platforms

Purpose: gather together tips on writing portable Tcl and Tk programs that will more likely run on many platforms.

Looks like someone started a similar page some time ago, calling it What should I be sure to do so my Tcl based programs run cross platform and Tcl built-ins for cross platform functionality.

  • See these PostScript files for observations on portable Tcl coding.

ftp://www.tcl.tk/pub/tcl/doc/portable-tk.ps and ftp://www.tcl.tk/pub/tcl/doc/portable-tk-slides.ps

  • Stay away from platform specific extensions, including DDE, Registry and AppleScript.
  • See Microsoft Windows for some information about windows.
  • Use file rather than exec or self parsing file names, etc.
  • Avoid exec, because different OSs support widely different commands.
  • Avoid depending on console, which currently is not available on Unix.
  • Avoid puts to stdout and stderr (especially in library code), which might not be available for graphical applications on Microsoft Windows and MacOS.
  • Make certain your code can accomodate file paths with spaces in them.
  • Avoid setting environment variables to the empty string. On Windows, that causes those variables to be unset.

LV 2006-Feb-16 A discussion of best practices for making use of file is in order, for I've seen people recommend file join, file nativename, and file normalize, but would love to see practical coding examples showing how one can write code (both Tcl and Tk) for gathering file names from users, generating new file names, etc.