Impressum
GoTo:
Home
 
Médecins Sans Frontičres | Ärzte ohne Grenzen Akazien Verlag   
 
Lesezeichen [ Jobs # QR-Code # MagicWords ]Di 8 Okt 2024 23:43:45


 huecker.com # Grundlagen der Programmierung | Tcl Tutorial.
--

 

. Simple Text Output .

[ Previous | Index | Next ]

The traditional starting place for a tutorial is the classic "Hello, World" program. Once you can print out a string, you're well on your way to using Tcl for fun and profit!

The command to output a string in Tcl is the puts command.

A single unit of text after the puts command will be printed to the standard output device (in this case, the lower window). The default behavior is to print a newline character ("return") appropriate for the system after printing the text.

If the string has more than one word, you must enclose the string in double quotes or braces ({}). A set of words enclosed in quotes or braces is treated as a single unit, while words separated by whitespace are treated as multiple arguments to the command. Quotes and braces can both be used to group several words into a single unit. However, they actually behave differently. In the next lesson you'll start to learn some of the differences between their behaviors. Note that in Tcl, single quotes are not significant, as they are in other programming languages such as C, Perl and Python.

Many commands in Tcl (including puts) can accept multiple arguments. If a string is not enclosed in quotes or braces, the Tcl interpreter will consider each word in the string as a separate argument, and pass each individually to the puts command. The puts command will try to evaluate the words as optional arguments. This will probably result in an error.

A command in Tcl is a list of words terminated by a newline or semicolon. Tcl comments are a # at the beginning of the line, or after the command is closed with a ; semicolon.

--

. Example .

    puts "Hello, World - In quotes"  ;# This is a comment after the command.
    puts {Hello, World - In Braces}  # *Error* - there is no semicolon!

    puts "This is line 1"; puts "this is line 2"

    puts "Hello, World; - With a semicolon inside the quotes"
   

--
[ Home | Top ]
[ . Previous | Index | Next . ]
Der Inhalt dieser Seite wurde am 31.08.2024 um 11.36 Uhr aktualisiert.
Navigation Seminare Magic Software Projekte Publikationen Kontakt Home
 
   huecker dot com * Germany | Datenschutz
© 1999, 2024 Franz-Josef Hücker. All Rights Reserved.
Contact Print Page LinkedIn follow me on twitter RSS Feeds & Podcasts