Puts options tcl

Puts options tcl

Posted: SacredScorpion Date: 27.05.2017
puts options tcl

ChannelId must be a channel identifier such as returned from a previous invocation of open or socket. It must have been opened for output. If no channelId is specified then it defaults to stdout. Puts normally outputs a newline character after string, but this feature may be suppressed by specifying the -nonewline switch. The latter is necessary when Working with binary data.

Some people write something like: However, you can use the return value of set as an argument to puts instead.

catch manual page - Tcl Built-In Commands

Newline characters in the output are translated by puts to platform-specific end-of-line sequences according to the current value of the -translation option for the channel for example, on PCs newlines are normally replaced with carriage-return-linefeed sequences; on older Macintoshes newlines are normally replaced with carriage-returns.

See the fconfigure manual entry for a discussion on ways in which fconfigure will alter output. Tcl buffers output internally, so characters written with puts may not appear immediately on the output file or device; Tcl will normally delay output until the buffer is full or the channel is closed.

You can force output to appear immediately with the flush command. Output to the terminal i. When the output buffer fills up, the puts command will normally block until all the buffered data has been accepted for output by the operating system.

If channelId is in nonblocking mode then the puts command will not block even if the operating system cannot accept the data. Instead, Tcl continues to buffer the data and writes it in the background as fast as the underlying file or device can accept it. The application must use the Tcl event loop for nonblocking output to work; otherwise Tcl never finds out that the file or device is ready for more output data. It is possible for an arbitrarily large amount of data to be buffered for a channel in nonblocking mode, which could consume a large amount of memory.

Tcl Help Show discussion The only value string may not always take is "-nonewline". MG finds this not to be true, on Win XP and ActiveTcl 8. Doing puts -nonewline does print the string '-nonewline' to the console.

Presumably this is because it checks the number of args given, and only checks for the switch if there are two args. Darren New recently pointed out in comp.

puts options tcl

No big problem but ugly - therefore I routinely add the one-liner proc puts! RS A variation, which requires that you only use simple puts to stdout, no -nonewline , but then is transparent i.

If the puts command is invalidly called with 3 arguments, one gets the following error: See also getputs for a brief overload. The problem was that every buffer write caused a flush of the disk cache. The workaround in 8. Thanks KBK and the Tcl chatroom for the quick answer! RS Silas - - You can print colors or bold text with puts at least, in a Linux shell which supports that like xterm or rxvt.

In ANSI color control , RS uses that to color pieces of text in a text widget. Here is a little example: By supports above, it appears someone means "can be forced to emulate".

Which is fine, I suppose. However, note that this support is no different than put's general "support" of outputting whatever characters someone wants to specify in the argument.

puts options tcl

In this case, someone hand coded the escape sequences necessary to change the colors of one particular kind of terminal emulation. If you need some other escape sequence, then you would edit the string and hard code the new sequence. Any ISO url about?

Vadtec - - I found these links which provide information on ANSI color control. The first link, to ECMA, is quite large and is the entire ISO specification.

Tcl and Tk Programming for the Absolute Beginner - Kurt Wall - Google Livres

It is probably over kill for most needs. The second link I found by chance with Google. The relevant information for ANSI color control is in the section labled ISO ANSI COLOR SEQUENCES. Note that "brighter colors" means "bold". I hope this helps someone. Tcl syntax Arts and crafts of Tcl-Tk programming Category Command Category Channel. Getting started What is Tcl? Tcl in the wild Major applications.

inserted by FC2 system