Friday, 28 April 2017

1.   ls -lrt | grep "^1"

Used for command to list all the links from a directory


2.   # touch file
     # chmod 400 file

Used to Create a read-only file in your home directory

3.   uname -a 
     used for finding which operating system your system is running on in UNIX

4.    killing a process find PID and use kill -9 PID command

5.  For bringing a process back in foreground use command "fg jobid" and for getting job id you use command      jobs

6. By using "top" command in UNIX you will find which process is taking how much CPU

7. By using "df" command in UNIX. For example "df -h ." will list how full your current drive is

Monday, 13 March 2017

Color selection

#!/bin/sh
# color_m.tcl \
exec tclsh "$0" ${1+"$@"}
set color ""
button .but -text "color chooser" -command {

set color [tk_chooseColor]
if {$color== ""} return
.lab configure -text "the chosen color is $color"
.lab configure -background $color
}
label .lab -text "No color is chosen"
pack .lab
pack .but

Displaying some Message Box

#!/bin/sh
# mssg1.tcl \
exec tclsh "$0" ${1+"$@"}
set answer [tk_messageBox -title "Application question " -message "really quit?" -type yesno -icon question]

switch $answer {
yes exit
no {tk_messageBox -message "I know like this application!" -type ok}

}

GUI_ Menu bar, Menus and Menu Items.

#!/bin/sh
# simpel_mny.tcl \
exec tclsh "$0" ${1+"$@"}
proc menu_clicked { no opt } {
tk_messageBox -message "you have clicked $opt. \n This function is not implanted yet "
}
#Declare that there is a menu

menu .mbar
. config -menu .mbar
#the main buttons
# cascade, checkbutton, command, radiobutoon, or separator,

.mbar add cascade -label "File" -underline 0 \
-menu [menu .mbar.file -tearoff 0]
.mbar add cascade -label "Others" \
-underline 0 -menu [menu .mbar.oth -tearoff 1]
.mbar add cascade -label "Help" -underline 0 -menu [menu .mbar.help -tearoff 0]

##File Menu##
set m .mbar.file
$m add command -label "New" -underline 0 \
-command { .txt delete 1.0 end} ; #A new item called New is added
$m add checkbutton -label "Open" -underline 0 -command {menu_clicked 1 "Open"}
$m add command -label "Save" -underline 0 -command {menu_clicked 1 "Save"}
$m add separator
$m add command -label "Exit" -underline 1 -command exit

##other Menu ##
set m .mbar.oth
$m add cascade -label "Insert" -underline 0 -menu [menu $m.mnu -title "Insert"]

$m.mnu add command -label "Name" -command {.txt insert end "Name : Gurinder V A\n"}
$m.mnu add command -label "Website" \
-command {.txt insert end "Website: https://www.blogger.com/\n"}
$m.mnu add command -label "Email" \
-command {.txt insert end "Email : gurinderpalsingh900@gmail.com\n"}

$m add command -label "Insert All"  -underline 7 \
-command {.txt insert end {Name : Gurinder V A
Website: https://www.blogger.com/
Email : gurinderpalsingh900@gmail.com}
}  
#help
set m .mbar.help
$m add command -label "About" -command {
.txt delete 1.0 end
.txt insert end {
About
---------
this script created to make a menu for a tcl/tk class
made by Gurinder pal Singh
segveris.blogspot.in
}
}
#making a text area
text .txt -width 50
pack .txt

Simple Button development without writing procedure

#!/bin/sh
# simpl_brrn.tcl \
exec tclsh "$0" ${1+"$@"}

button .exit_button -text "QUIT" -command exit
puts "The exit button text is: [.exit_button cget -text]"
puts "The exit button color is: [.exit_button cget -background]"

set clickButton [button .b1 -text "Please Click Me" \
-command {.b1 configure -text "I’ve been Clicked!"}]
pack .b1
pack .exit_button

List Box in tcl/tk

#!/bin/sh
# chk_btnn.tcl \
exec tclsh "$0" ${1+"$@"}
# Graphical User Interface :ListBox

proc insert_to_list {} {

#take the input of the entry

set input [ .ent get ]

#if { $input =""} {return}

#put input on the end of all listbox items

.lst insert end "$input"
}
proc delete_from_list {} {

#to delete the current selection

set selected_index [ .lst curselection]
if { $selected_index ==""} { return }
.lst delete $selected_index
.lst activate 0
}


listbox .lst -selectmode single ; # select mode can be single browse multiple or extend; the default value is browse


.lst insert end "student " "Teacher" "clerk" "Business Man"  "Common Man" "Computer Expert" "Others"


.lst configure -activestyle underline

.lst activate 1
entry .ent -textvariable text_ent
button .but1 -text "insert to list" -command "insert_to_list"
button .but2 -text "delete from list" -command "delete_from_list"
pack .lst
pack .ent
pack .but1
pack .but2

Sunday, 12 March 2017

How to Delete KMSPico Created Files from Registry


  • Open Registry by Typing Regedit in the Windows Search Field and then press on Enter.
  • This will open the registry entries. Now users need to press CTRL + F together and type KMSPico to find the entries.
  • Once located, delete all KMSPico named entries. If you are unable to find it, you need to look up for it on the directories manually. Be careful and delete only KMSPico entries, else it can damage your Windows Computer severely.
HKEY_CURRENT_USER—-Software—–Random Directory. 
HKEY_CURRENT_USER—-Software—Microsoft—-Windows—CurrentVersion—Run– Random
HKEY_CURRENT_USER—-Software—Microsoft—Internet Explorer—-Main—- Random

Wednesday, 1 March 2017

CheckBox and Radio button development and controlling

#!/bin/sh
# bttn_chk_rado.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
global selection
tk_messageBox -message "$selection!" -type ok
}

proc push_button2 { } {
global selection2
set selection {}
foreach value [array name selection2] {
if {$selection2($value)!= 0} {
set selection "$selection and $selection2($value)"
}
}
tk_messageBox -message "you chose $selection!" -type ok

}
proc toggle { } {
.chk1 toggle
}
set selection 0
frame .textarea -background red -borderwidth 2 -relief flat
for {set i 1} {$i <= 10} {incr i} {
radiobutton .rad$i -text "choice #$i" -variable selection -value "choice is $i"
pack .rad$i -in .textarea
}

frame .frmchk -background green -borderwidth 5 -relief groove
for {set i 1} {$i <= 10} {incr i} {
checkbutton .chk$i -text "choice #$i" -variable selection2($i) -onvalue "$i" -offvalue 0
pack .chk$i -in .frmchk
}

button .but -text "show selection radio button" -command "push_button"
button .but2 -text "show selection checkbox" -command "push_button2"
button .but3 -text "toggle the selection of checkbox #1" -command "toggle"

pack .textarea
pack .frmchk

pack .but
pack .but2
pack .but3

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

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