Saturday, July 20, 2013

TCL EXAMPLES - Variables

ex_var.tcl


set four 4
set four_real 4.0
set three 3

set threefourths [expr $three / $four]
puts "threefourths: $threefourths"

set threefourths_real [expr $three / $four_real]
puts "threefourths_real: $threefourths_real"

Sunday, June 9, 2013

TCL Tutorials -Expressions


ex_expression.tcl


set r 2.0
set pi [expr { 4 * atan(1.0) }]
set area [expr {$pi * $r * $r}]

puts "r      : $r"
puts "pi     : $pi"
puts "area     : $area"

Friday, June 7, 2013

TCL Tutorials - Quoting


An Example of how to use quotes in tcl


ex_quoting.tcl

set years 32
set years_sub "I am $years";
set years_no_sub {I am $years};

puts "this string got substituted - weak quoting"
puts $years_sub

puts "this string did not substitute - rigid quoting"
puts $years_no_sub

Wednesday, June 5, 2013

TCL Tutorials - Line Continuation


This examples states the use of line continuation

ex_02.tcl

set members { \
abc \
def \
ghi \
jkl \
}
puts $members

Tuesday, June 4, 2013

TCL Tutorials- Comments

I am starting TCL tutorials and will be posting it on a daily basis

comment_example.tcl


#this is a comment

set real_years 4
set dog_name "spot"; #another comment
set dog_years [expr (7*$real_years)]

puts "my dog $dog_name is $real_years"
puts "he acts $dog_years old"

Monday, April 1, 2013

Breadth First Search In TCL

I searched the web for a bfs code and could not find one in tcl that is easy so came up with this one .


bfs.tcl
---------

set visited [list]
set START "0"
set END "5"
set nonodes 6
set graph(0) {}

proc printpath visited {

set path ""
foreach node $visited {
lappend path $node  
}
puts $path
}
proc initgraph { cnt } {

global graph
for {set i 0} {$i < $cnt } { incr i } {
set graph($i) {}
}
}
proc addedge { node1 node2 } {

global graph

set adjacent $graph($node1)
lappend adjacent $node2
set graph($node1) $adjacent
}

proc isconnected { node1 node2 } {

global graph

set adjacent $graph($node1)
return [lsearch -exact $adjacent $node2]
}

proc getadjacentnodes { node1 } {

global graph
return $graph($node1)
}

proc breadthfirstsearch { visited } {

global END START
set nodes [getadjacentnodes [lindex $visited end]]

for {set i 0} {$i < [llength $nodes] } { incr i } {

set node [lindex $nodes $i]
set b [lsearch -exact $visited $node]
if { $b == 1} {
continue
}
set b [string compare $node $END]
if { $b == 0} {
lappend visited $node
printpath $visited

set visited [lreplace $visited [expr [llength $visited]-1] [expr [llength $visited]-1]]
break
}
}
for {set i 0} {$i < [llength $nodes] } { incr i } {

set node [lindex $nodes $i]
set b1 [lsearch -exact $visited $node]
set b2 [string compare $node $END]
if { $b1 == 1  ||  $b2 == 0 } {
continue;
}
lappend visited $node
breadthfirstsearch $visited
set visited [lreplace $visited [expr [llength $visited]-1] [expr [llength $visited]-1]]
}
}

initgraph $nonodes

addedge "0" "1"
addedge "1" "2"
addedge "1" "3"
addedge "1" "4"

addedge "2" "5"
addedge "3" "5"
addedge "4" "5"
addedge "1" "5"

set visited [list $START]

breadthfirstsearch $visited

Tuesday, January 22, 2013

Control VLC Player

Hello all i searched the net for a way in which vlc player can be controlled
And here is the steps

Start VLC using the following command

vlc --extraintf http

Then run the following commands to control it

Play
-------
wget http://127.0.0.1:8080/requests/status.xml?command=pl_play

Stop
-------
wget http://127.0.0.1:8080/requests/status.xml?command=pl_stop






Pause
----------
wget http://127.0.0.1:8080/requests/status.xml?command=pl_pause

Next
-------
wget http://127.0.0.1:8080/requests/status.xml?command=pl_next

Prev
-------
wget http://127.0.0.1:8080/requests/status.xml?command=pl_previous