TCL/TKL Example Code

The tcldemo is extremely simple. TCL has built in support for socket communication so the programmer need not do anything very fancy.




#!/usr/local/bin/tclsh

set host [lindex $argv 0]
set port [lindex $argv 1]
set _delim_ "\n"


set s [socket $host $port]
fconfigure $s -buffering line


puts stdout "\nTcldemo\n"




proc acssend {s command data} {

 global _delim_ 

 puts stdout "Hit Enter To Send:"
 puts stdout "$command"
 puts stdout "$data"
 gets stdin line

 #set ret [string compare "y" $line]  

 puts $s [format "%s%s%s" $command $_delim_ $data ] 

 flush $s
}






if { $s > 0} {

 acssend $s "open_gdsii" "demo.gds"
 acssend $s "redraw" ""
 acssend $s "set_nesting_level" "1"
 acssend $s "redraw" ""
 acssend $s "set_nesting_level" "2"
 acssend $s "redraw" ""
 acssend $s "set_nesting_level" "0"
 acssend $s "redraw" ""
 acssend $s "set_display_filter_size" "40"
 acssend $s "redraw" ""
 acssend $s "set_display_filter_size" "0"
 acssend $s "redraw" ""
 acssend $s "set_window" "2000,2000,2600,2600"
 acssend $s "open_structure" "CMP2"
 acssend $s "set_layers_off" "all"
 acssend $s "redraw" ""
 acssend $s "set_layers_on" "all"
 acssend $s "redraw" ""
 acssend $s "set_fill" "on"
 acssend $s "set_fill" "off"
 acssend $s "set_outline" "off"
 acssend $s "set_outline" "on"

 acssend $s "get_layer_list" ""
 gets $s line
 puts stdout "Received:"
 puts stdout "$line"
 gets $s line
 puts stdout "$line\n"

 acssend $s "get_structure_list" ""
 gets $s line
 puts stdout "Received:"
 puts stdout "$line"
 gets $s line
 puts stdout "$line\n"

 acssend $s "get_structure_root" ""
 gets $s line
 puts stdout "Received:"
 puts stdout "$line"
 gets $s line
 puts stdout "$line\n"

 acssend $s "get_structure_children" "TOP"
 gets $s line
 puts stdout "Received:"
 puts stdout "$line"
 gets $s line
 puts stdout "$line\n"

 acssend $s "get_structure_extents" "TOP"
 gets $s line
 puts stdout "Received:"
 puts stdout "$line"
 gets $s line
 puts stdout "$line\n"

 acssend $s "exit" ""
}