logo image

Tcl Hello World! 

Tcl Hello World! 



Click on RUN button to see the output

Tool Command Language(TCL) online compiler

Write, Run & Share TCL code online using OneCompiler's TCL online compiler for free. It's one of the robust, feature-rich online compilers for TCL language, running the latest TCL version 8.6. Getting started with the OneCompiler's TCL editor is easy and fast. The editor shows sample boilerplate code when you choose language as TCL. OneCompiler also has reference programs, where you can look for the sample code and start learning. Happy learning!!

Taking inputs (stdin)

OneCompiler's TCL online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample TCL program which takes name as input and prints hello message with your name.

set name [gets stdin]
puts "Hello $name"

About TCL

Tool Command Language(TCL) is a general purpose scripting language which is commonly used for GUIs and for testing. Everything is by default string in TCL. It was created by John Osterhout in 1989.

Syntax help


Variable is a identifier which is used to hold the value. set is used to create variables.


set name onecompiler


1. If-Else:

When ever you want to perform a set of operations based on a condition IF-ELSE is used.

if(conditional-expression) {
} else {

You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.

2. Switch:

Switch is an alternative to If-Else-If ladder.

switch(conditional-expression) {    
value1 {     
 # code
value1 {     
 # code
default {
# code

3. For:

For loop is used to iterate a set of statements based on a condition.

  # code  

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition) {  
 # code 


Array is a collection of similar data which is stored in continuous memory addresses. Array values can be fetched using index. Index starts from 0 to size-1.


set ArrayName(Index) value


Procedure is a sub-routine which contains set of statements. Uusually procedures are required when multiple calls are made to same set of statements. Procedures increases re-usuability and modularity.


proc procedureName {arguments} {
   # code

Help us with your feedback!

Reference Programs:


No tags available for Tcl

How to use?

Choose the language in which you want to run your program, by clicking the button next to Run. And then write your code in the code box, You can use the auto complete snippets and warnings and errors which helps you to write better code faster way.
Once you are done writing your code click the Run button, now the code will be submitted to OneCompiler and you will see the results in a second.

How to contribute?

Please fork OneCompiler repository and contribute us by adding more languages or the features to the existing OneCompiler backend.
You can also contibute to the community by adding more programs which users can search and use as base code for their programs.

API & More

You can embed OneCompiler into your own website. That helps your website users to write and test their programs within your website.
If you want to run and see the results from your backend you can utilize the OneCompiler API by integrating it with your backend.