Tool Command Language; Introduction; Tcl Scripting Language Features; Hello, World!" Example - Newport XPS-Q8 Manual

Universal high-performance motion controller/driver
Table of Contents

Advertisement

XPS-Q8
2.0

Tool Command Language

EDH0307En1041 — 10/17
2.1

Introduction

Tcl is short for Tool Command Language. Tcl commands perform a variety of
functions, such as: output a string, compute a math expression, or display a widget. Tcl
casts everything into the mold of a command, even programming constructs like
variable assignments and procedure definitions. Tcl requires a minimal amount of
syntax to properly invoke commands, leaving the remainder of the work to command
implementation.
The basic syntax of a Tcl command is:
command
arg1 arg2 arg3 ...
The command is either the name of a built-in command or a Tcl procedure. White
space (i.e., spaces or tabs) is used to separate the command name from command
arguments, and a new line (i.e., the end of line character) or semicolon is used to
terminate a command. Tcl does not interpret arguments respective to commands, other
than to perform grouping.
argument.
Tcl also performs substitution, which is used with programming
variables and nested command calls. The behavior of the Tcl command processor can
be summarized in three basic steps:
• Argument grouping.
• Value substitution of nested commands, variables, and backslash escapes.
• Command invocation. It is up to the command to interpret its arguments.
The Tcl gets from stdio command is not supported.
2.2

Tcl scripting language features

2.2.1

"Hello, World!" example

puts
stdout {Hello, World!}
⇒ Hello, World!
In this example, the command is puts, which takes two arguments: an I/O stream
identifier and a string.
newline character.
There are two points to emphasize:
• Arguments are interpreted by the command. In the example, stdout is used to
identify the standard output stream. The use of stdout as a name is a convention
employed by
the standard error output, and stdin is used to identify the standard error input.
• Curly braces are used to group words together into a single argument. The
command receives Hello, World! as its second argument.
The braces are not part of the value.
The braces are required syntax for the interpreter, and they get stripped off before the
value is passed to the command. Braces group all characters, including newlines and
nested braces, until a matching brace is found. Tcl also uses double quotes for grouping.
Grouping arguments will be described in more detail later.
This allows multiple words to be used in a single
NOTE
puts
writes the string to the I/O stream along with a trailing
puts
and other I/O commands. Also, stderr is used to identify
2
Tcl Manual
puts

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents