تی‌سی‌ال
نمونه برنامه‌های کامل Tcl

در زیر نمونه‌هایی از برنامه‌های کامل Tcl آورده شده‌است. نمونه اول یک اسکریپت کنترلی برای برنامه شبیهسازی Modelsim است و دستورهای افزوده شده به Tcl توسط برنامه Modelsim در آن به خوبی مشهود است:
# Copy Test Bench Files to the appropriate place
# $testAddr is the address of the simulation files
# $benchAddr is the address of the test bench directory
set benchRoot $۱
set testRoot $۲

set testsAddr $۳

set benchName $۴
set testName $۵
# The address in which results should be put
set destAddr $benchRoot
#Copy test bench specified on command line
file delete -force $testRoot/tsource
file copy -force $benchRoot/$benchName $testRoot/tsource
# Run the simulation
vsim -voptargs=+acc work.tbleon
# Add the processor's pinout signals
add wave sim:/tbleon/tb/p0/leon0/resetn
add wave sim:/tbleon/tb/p0/leon0/clk
add wave sim:/tbleon/tb/p0/leon0/pllref
add wave sim:/tbleon/tb/p0/leon0/plllock
add wave sim:/tbleon/tb/p0/leon0/errorn
add wave sim:/tbleon/tb/p0/leon0/address
add wave sim:/tbleon/tb/p0/leon0/data
add wave sim:/tbleon/tb/p0/leon0/ramsn
add wave sim:/tbleon/tb/p0/leon0/ramoen
add wave sim:/tbleon/tb/p0/leon0/rwen
add wave sim:/tbleon/tb/p0/leon0/romsn
add wave sim:/tbleon/tb/p0/leon0/iosn
add wave sim:/tbleon/tb/p0/leon0/oen
add wave sim:/tbleon/tb/p0/leon0/read
add wave sim:/tbleon/tb/p0/leon0/writen
add wave sim:/tbleon/tb/p0/leon0/brdyn
add wave sim:/tbleon/tb/p0/leon0/bexcn
add wave sim:/tbleon/tb/p0/leon0/sdcke
add wave sim:/tbleon/tb/p0/leon0/sdcsn
add wave sim:/tbleon/tb/p0/leon0/sdwen
add wave sim:/tbleon/tb/p0/leon0/sdrasn
add wave sim:/tbleon/tb/p0/leon0/sdcasn
add wave sim:/tbleon/tb/p0/leon0/sddqm
add wave sim:/tbleon/tb/p0/leon0/sdclk
add wave sim:/tbleon/tb/p0/leon0/sa
add wave sim:/tbleon/tb/p0/leon0/sd
add wave sim:/tbleon/tb/p0/leon0/pio
add wave sim:/tbleon/tb/p0/leon0/wdogn
add wave sim:/tbleon/tb/p0/leon0/dsuen
add wave sim:/tbleon/tb/p0/leon0/dsutx
add wave sim:/tbleon/tb/p0/leon0/dsurx
add wave sim:/tbleon/tb/p0/leon0/dsubre
add wave sim:/tbleon/tb/p0/leon0/dsuact
add wave sim:/tbleon/tb/p0/leon0/test
# To continue script execution
onbreak {
resume
}
# First run
run -all
# Set onbreak to its default value
onbreak ""
# Open dataset as gold for comparison
dataset open $benchRoot/$benchName/gold.wlf
echo Golden Version Opened for comparison!
# Starting Compare
compare start gold sim
# Add signals for comparison
compare add gold:/tbleon/tb/p0/leon0/resetn
compare add gold:/tbleon/tb/p0/leon0/clk
compare add gold:/tbleon/tb/p0/leon0/pllref
compare add gold:/tbleon/tb/p0/leon0/plllock
compare add gold:/tbleon/tb/p0/leon0/errorn
compare add gold:/tbleon/tb/p0/leon0/address
compare add gold:/tbleon/tb/p0/leon0/data
compare add gold:/tbleon/tb/p0/leon0/ramsn
compare add gold:/tbleon/tb/p0/leon0/ramoen
compare add gold:/tbleon/tb/p0/leon0/rwen
compare add gold:/tbleon/tb/p0/leon0/romsn
compare add gold:/tbleon/tb/p0/leon0/iosn
compare add gold:/tbleon/tb/p0/leon0/oen
compare add gold:/tbleon/tb/p0/leon0/read
compare add gold:/tbleon/tb/p0/leon0/writen
compare add gold:/tbleon/tb/p0/leon0/brdyn
compare add gold:/tbleon/tb/p0/leon0/bexcn
compare add gold:/tbleon/tb/p0/leon0/sdcke
compare add gold:/tbleon/tb/p0/leon0/sdcsn
compare add gold:/tbleon/tb/p0/leon0/sdwen
compare add gold:/tbleon/tb/p0/leon0/sdrasn
compare add gold:/tbleon/tb/p0/leon0/sdcasn
compare add gold:/tbleon/tb/p0/leon0/sddqm
compare add gold:/tbleon/tb/p0/leon0/sdclk
compare add gold:/tbleon/tb/p0/leon0/sa
compare add gold:/tbleon/tb/p0/leon0/sd
compare add gold:/tbleon/tb/p0/leon0/pio
compare add gold:/tbleon/tb/p0/leon0/wdogn
compare add gold:/tbleon/tb/p0/leon0/dsuen
compare add gold:/tbleon/tb/p0/leon0/dsutx
compare add gold:/tbleon/tb/p0/leon0/dsurx
compare add gold:/tbleon/tb/p0/leon0/dsubre
compare add gold:/tbleon/tb/p0/leon0/dsuact
compare add gold:/tbleon/tb/p0/leon0/test
#compare add -r gold:/*
# Running compare
compare run
# Saving comparison and differences
compare saverules $destAddr/$testName-$benchName-comprules.sav

onerror {
echo Hurray! No Differences Found!!;
resume
}

compare savediffs $destAddr/$testName-$benchName-compdiffs.sav
echo Comparison complete!
#Goodbye!
quit -sim;
dataset close gold
نمونه دوم یک برنامه ping ساده است که در محیط لینوکس اجرا می‌شود[۶]:
#!/usr/local/bin/wish -f
# Ping example #۱
frame .buttons -borderwidth 10
pack .buttons -side top -fill x

button .buttons.quit -text Quit -command exit
button .buttons.ping -text Ping -command Ping
pack .buttons.quit .buttons.ping -side right

frame .f ; pack .f -side top
label .f.l -text Host:
entry .f.host -width 20 -relief sunken
pack .f.l .f.host -side left

text .log -width 60 -height 10 -bd 2 -relief raised
pack .log -side top

proc Ping {} {
    set hostname [.f.host get]
    catch {exec /usr/sbin/ping $hostname} result
    .log insert end $result
    .log insert end \n
}
به عنوان نمونهای دیگر می‌توان برنامه تبدیل فایل‌های Dos به Unix را مشاهده کرد[۱]:
#!/usr/local/bin/tclsh
# Dos2Unix
# Convert a file to Unix-style line endings
# If the file is a directory, then recursively
# convert all the files in the directory and below.
## Arguments
# f The name of a file or directory.
## Side Effects:
# Rewrites the file to have LF line-endings

proc Dos2Unix {f} {
    puts $f
    if {[file isdirectory $f]} {
        foreach g [glob [file join $f *]] {
            Dos2Unix $g
        }
    } else {
        set in [open $f]
        set out [open $f.new w]
        fconfigure $out -translation lf
        puts -nonewline $out [read $in]
        close $out
        close $in
        file rename -force $f.new $f
    }
}
# Process each command-line argument

foreach f $argv {
    Dos2Unix $f
}