Wednesday, 8 February 2017

file Handling in tcl-tk

Check it @ Coding Ground



#!/usr/bin/tclsh



set infile [open "main.tcl" r]

set number 0





while {[gets $infile line] >=0} {

incr number

after 500

puts "$number $line"

}

close $infile





set outfile [open "report.out" w]

puts $outfile "Number of lines: $number"

close $outfile



set outfile [open "report.out" a]

puts $outfile "gone potatoes"

close $outfile

Tuesday, 7 February 2017

Procedures in tcl-tk

Check it @ Coding Ground





#!/usr/bin/tclsh

#y= fun(k,u,v)

proc proc_by_copy {a b c}  {

#$set a 1

#set b 2

#set c 3

puts ">>>>>>>inside by copy a,b,c:$a $b $c"

}

proc proc_by_reference { a b c } {

upvar $a a_

upvar $b b_

upvar $c c_

set a_ [expr $a_*2]

set b_ [expr $b_*2]

set c_ [expr $c_*2]

puts ">>>>>>inside by reference a,b,c: $a_ $b_ $c_"

}

proc myfunc {x} {

return [expr 2 * $x]

 }

proc proc_by_global { } {



global K

global L

global M



puts ">>>>>inside by copy K,L,M: $K $L $M\n\n"

}

###################\/main

set A 2

set B 4

set C 6

puts "\n\n A,B,C before by copy :$A $B $C"

proc_by_copy $A $B $C

puts " A,B,C after by copy : $A $B $C\n\n"



set A 2

set B 4

set C 6



puts "A,B,C before by ref : $A $B $C"

proc_by_reference A B C

puts " A,B,C after by ref :$A $B $C"

set X 3

set Y [myfunc $X]

puts "\n\nY=myfunc(X=$X) is $Y\n\n"



set K 10

set L 20

set M 30

proc_by_global

Switch command in tcl-tk

Check it @ Coding Ground





puts "Enter the menu item number to show the information about the person.\n Any other number will quit the application:"



puts -nonewline "1- Dr.\n2- Gurinder\n3- Pal\n4- Singh:"



gets stdin select



while { $select <=6 && $select>=1 } {

     switch $select {

              1 { puts "Gurinder pal SIngh is your teacher!\n"}

              2 { puts "In tcl-tk class.\n"}

              3 { puts "8th semester ECE\n"}

              4 { puts "4 lectures a week \n"}

               default { puts "tcl-tk for vsli tool automation"}

}

       puts "Select another person:"

       gets stdin select

 }

   puts "End of program."

Saturday, 28 January 2017

for loop in tcl-tk

#!/usr/bin/tclsh

proc keypressed {{channel stdin}} {
exec /bin/stty raw -echo <@stdin
set c [read stdin 1]
exec /bin/stty -raw echo <@stdin
}


set k 0
puts "select example number"
gets stdin example

if {$example ==1} {
for {set i 0} {$i<= 10} {set i [expr {$i +1}]} {
set k [expr {$k+$i}]

puts $k
keypressed
}
puts "k=$k \nend of program"
exit
}
#placement of "set z '"" really maters, by chamging position result will changed"
if {$example !=1} {#if u put set z"" here result will be different
for {set i 1} {$i<= 5} {incr i} {set z ""
for {set k 1} {$k<=5}  {incr k} {
set z "*$z"                      }
puts $z
keypressed }
puts "end of program"
exit
}

for loop in tcl-tk

Check it @ Coding Ground

Sunday, 21 August 2016

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path




How to use Tomcat 8.5.x and TomEE 7.x with Eclipse?

ou've to change the ServerInfo.properties file of Tomcat's /lib/catalina.jar file.
ServerInfo.properties file contains the following code

server.info=Apache Tomcat/8.5.4
server.number=8.5.4.0
server.built=Jul 6 2016 08:43:30 UTC

Just open the ServerInfo.properties file by opening the catalina.jar with winrar from your Tomcat's lib folder

ServerInfo.properties file location in catalina.jar is /org/apache/catalina/util/ServerInfo.properties

Notice : shutdown the Tomcat server(if it's already opened by cmd) before doing these things otherwise your file doesn't change and your winrar shows error.
Then change the following code in ServerInfo.properties

server.info=Apache Tomcat/8.0.8.5.4
server.number=8.5.4.0
server.built=Jul 6 2016 08:43:30 UTC

Restart your eclipse(if opened). Now it'll work.