Friday, 24 February 2017

Hiding full Frame, instead of hiding tabs

#!/bin/sh
# btnn_frm2.tcl \
exec tclsh "$0" ${1+"$@"}
proc toggle_frame { }   {
global frame_status

if { $frame_status =="shown" } {
 pack forget .f
 set frame_status "hidden"
 return 1
}
if { $frame_status =="hidden"} {

   pack .f
   pack .l -in .f
   pack .l2 -in .f
set frame_status "show"
return 1
      }
}

set frame_status "shown"
button .btoggel -text "show/hide frame " -command "toggle_frame"

frame .f -borderwidth 5
label .l -text "lab1"
label .l2 -text "lab2"
pack .btoggel .f
pack .l -in .f
pack .l2 -in .f

Slider and entery Box in GUI

#!/bin/sh
# bttn3.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
    global age
set name [.ent get]
.txt insert end "Hello $name,\n You are $age years old."

}
#Globle Variables
set age 10

#GUI building
frame .frm -background yellow -borderwidth 5 -relief flat ;

label .lab -text "Enter name:"
entry .ent
button .but -text "push Me" -command "push_button"
#age
scale .scl -label "Age :" -orient h -digit 2 -from 0 -to 50 -variable age -tickinterval 50
#Text Area
frame .textarea -background red -borderwidth 2
text .txt -yscrollcommand ".srl_y set" -xscrollcommand ".srl_x set" -width 50 -height 10
  scrollbar .srl_y -command ".txt yview" -orient v
 scrollbar .srl_x -command ".txt xview" -orient h
 #Geometry Management
pack .lab -in .frm
pack .ent -in .frm
pack .frm
pack .scl
pack .but
grid .txt -in .textarea -row 1 -column 1
grid .srl_y -in .textarea -row 1 -column 2 -sticky ns
grid .srl_x -in .textarea -row 2 -column 1 -sticky ew
pack .textarea

Hide and Show button (managing push button)

This program is implemented in eclipse

#!/bin/sh
# bttn_frm.tcl \
exec tclsh "$0" ${1+"$@"}
proc hide  {} {
pack forget .f
}

proc show {} {

pack .f
pack .l -in .f
pack .l2 -in .f
}
button .bh -text "hide" -command "hide"
button .bs -text "show" -command "show"
frame .f -borderwidth 5 -background red
label .l -text "lab1"
label .l2 -text "lab2"
pack .bh .bs .f
pack .l -in .f
pack .l2 -in .f

Procedures called by name, called by value, and procedure when you not sure about how many arguments you are going to pass

#!/bin/sh
# procd1.tcl \
exec tclsh "$0" ${1+"$@"}
proc prco1 {} {
set xm 4
puts "$xm"
}

proc prco2 {} {
set xd 3
return  $xd
}

proc adder {m n} {
set s 0
set s [expr $m + $n]
return $s
}

#############procedure when you are not sure how many arguments will be passed during calling
##############and calling procedure proc2 from inside of multi_add procedure
proc multi_add {args} {
if {$args eq ""} {
puts "got no argument"
}
puts "got $args"
set lgth [llength $args]
puts "lgth:$lgth"
set myList $args
foreach i $myList {
puts $i }
for {set i 0} {$i <= [llength $args] } {incr i} {
set j($i) [lindex $args $i]
puts "j($i)=> $j($i)"
}

#puts "$i"
set test [adder $j(0) $j(1)]
puts "test:$test"
}

####################MAIN###################

#######calling just by function name
prco1
set x [prco2]
puts "value of x : $x"
set z [adder $x 2]
puts "value of resutl: $z"

multi_add 4 3

Wednesday, 15 February 2017

How to start the Remote Access service if get error 1068?

When trying to start the Remote Access Connection Manager service, I always get an error message saying:
 
Error 1068: The dependency service or group failed to start.

 I'm using Windows 7 64-bit.

  1. Control Panel → Administrative Tools → Services → Windows Event Log
  2. Right-click "Properties → Startup type" if disabled, turn it on to automatic
Enabling this unblocks the opportunity to Enable/start the Remote Access Connection Manager and Remote Access Auto Connection Manager.

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."