Puts options tcl

Puts options tcl

Author: dimonchik Date: 02.07.2017

The covered Tcl commands include the puts , open , gets , flush , incr , info , set , and unset commands. In the first example, we will mention the puts command. The puts command is used to print messages to the console or to other channels like a file. The command has the following syntax:. The puts is the command name. Optional parameters are specified between question marks. The -nonewline switch suppresses the newline character.

By default, the command puts a newline to each message. The channelId must be an identifier for an open channel such as the Tcl standard input channel stdin , the return value from an invocation of open or socket.

It defaults to standard output channel stdout if not specified. Finally, the string is the message to be printed.

The puts command prints a message to the console. Both command invocations do the same thing. The open command opens a file, a serial port, or a command pipeline and returns a channel identifier.

puts options tcl

In the following example, we use the command to open a file. The puts command is used to write to a file, opened for writing with the open command. The gets command reads a line from a channel, and the flush command flushes buffered output of a channel.

In the following example we create a script that greets the user. The output is buffered. To see the output immediately after the command runs, we can use the flush command.

The stdout is the standard output. In our case it is a terminal; it is called a channel id in Tcl. The gets command reads a line from the standard input.

Basic Tcl commands

The result is stored in the name variable. If a parameter is passed to the command, then its value is added to the value of the variable; otherwise the value is incremented by 1. Number 4 is added to the x variable.

TCL/TK format force width - Tcl/Tk - Tek-Tips

The puts command prints 10 to the console. The set command is used to create and read variables. The unset command destroys a variable.

puts options tcl

This line also prints the value of the x variable. The set command with one parameter reads the value of the variable.

puts options tcl

The value is passed to the puts command and is printed to the terminal. Tcl scripts like any other scripts can take command line arguments. Tcl has three predefined variables. Home Contents Subscribe Previous Next.

Rating 4,9 stars - 313 reviews
inserted by FC2 system