For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2005 > Problem With Variables Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem With Variables Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
gio0166

2005-10-25, 7:58 am

hi . I' m gr so sorry for my bad english. I've written a program in
tcl and i have a problem about setting entyfields values of each page
to variables and then print them to the screen. So here is the code:

#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

###################################
# set the main window
###################################
set w .button
catch {destroy $w}
toplevel $w
wm title $w "Gui"
wm iconname $w "main"


###################################
# set the iwidget
###################################
package require Iwidgets 4.0

option add *textBackground seashell
option add *Tabnotebook.backdrop DimGray
option add *Scale.width 8
.. configure -background white

iwidgets::tabnotebook $w.tnb -width 8i -height 1.4i
pack $w.tnb -padx 4 -pady 4


###################################
# make and display frames objects
#+ validation
###################################
for {set i 1} {$i <= 31} {incr i} {
set page [$w.tnb add -label "$i"]

label $page.numb -text "Current Page $i"
pack $page.numb -side bottom

iwidgets::entryfield $page.da -labeltext "Destination \nAddress:"
-labelpos nw -width 12 -command {set da [$page.$da get]}
pack $page.da -side left -padx 1
iwidgets::entryfield $page.sa -labeltext "Sourse \nAddress:"
-labelpos nw -width 12 -command {set sa($i) [.$sa get]}
pack $page.sa -side left -padx 1
iwidgets::entryfield $page.len -labeltext "Packet \nLength:"
-labelpos nw -width 2 -command {set len($i) [.$len get]}
pack $page.len -side left -padx 35

iwidgets::radiobox $page.rb -labeltext "Packet data:"
$page.rb add increm -text "Incremental" -command {$page.fixed
configure -state disabled}
$page.rb add rand -text "Random" -command {$page.fixed configure
-state disabled}
$page.rb add fixed -text "Fixed" -command {$page.fixed configure
-state normal}
pack $page.rb -side left -padx 5

iwidgets::entryfield $page.fixed -labeltext "Fixed:" -labelpos nw
-width 4 -command {set fixed($i) [.$fixed get]}
pack $page.fixed -side left
iwidgets::entryfield $page.clk -labeltext "Time:" -labelpos nw
-width 3 -command {set clk($i) [.$clk get]}
pack $page.clk -side left -padx 10


scale $page.rate -label Rate -length 180 -bigincrement 0.0 -from
0.0 -orient horizontal -resolution 1.0 \
-tickinterval 0.0 -to 100.0 -width 20 -variable rate
pack $page.rate -side left -padx 20



iwidgets::buttonbox $page.bb -orient horizontal
$page.bb add OK -text Run -command {
puts stdout "value da is : $da\
value i is: $i\
value sa is : $sa \
value length is : $len \
value time is : $clk \
value rate is : $rate"}
$page.bb add Cancel -text Cancel -command {destroy $w}
$page.bb default OK
pack $page.bb -expand yes -fill both -side right

}


I want to print each variables of all pages to the screen so please
help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!
Thanks A lot.
Please send me a mail if is Possible at : gio0166@gmail.com

suchenwi

2005-10-25, 7:58 am

Do you need something like this? Prints all global variables, scalars
and arrays, to stdout:

proc print_all_vars {} {
foreach name [lsort [info globals]] {
upvar #0 $name var
if [array exists var] {
parray ::$name
} else {puts "$name = $var"}
}
}

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com