Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read an Integer from the entry box

Status
Not open for further replies.

schpezi

Programmer
Sep 7, 2001
1
DE
Hi,

I wanted to form the input of the
user into an integer...

I used an entry-box:

# entry .psetup.q1a -width 3

after pressing "Ok", a procedure will start:

# button.psetup.bcont -text "OK" -command player_inputbox
..
# proc player_inputbox {} {
# set vari [.psetup.q1a get]
# if {$vari>6} then {
# label .psetup.error1 -text "Wrong, maximum of 6 Players"
# grid .psetup.error1 -row 2 -column 0
# }
..
# for {set j 0} {$j < 6} {incr j 1} {
# if {$vari==[expr$j+1]} then {
# des...

What's my mistake, I believe he works with
a string instead of a integer, because the
Error I get is the follow:

wrong # args: should be &quot;for start test next command&quot;
while compiling
&quot;for {set j 0} {[expr $j] < [expr 6]} {incr j 1} {
if {$vari==[expr $j+1]} then {
destroy .psetup.q1a
destroy .psetup.bcont
...&quot;

Can u help me ???

Sorry, I'm a newbie and my English isn't so good.

Thank you, Stefan
 
As the error message explains, your error is inside the for statement.
I believe you missed a line feed and tcl understands something like

for {set j 0} {$j < 6} {incr j 1} {...} other_command

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top