Tk Library Source Code

View Ticket
Login
Ticket UUID: 625327
Title: Problem using i as a counter at level 0
Type: Bug Version: None
Submitter: lduperval Created on: 2002-10-18 17:26:53
Subsystem: smtp Assigned To: gwlester
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2002-12-02 11:25:22
Resolution: Works For Me Closed By: gwlester
    Closed on: 2002-12-02 04:25:22
Description:
set mailHost localhost
set mailPort 25
set myAddress [email protected]

set addresses {
[email protected]
}

proc send_simple_message {recipient subject body} {
    package require smtp
    package require mime
    global mailHost
    global mailPort
global myAddress

    set token [mime::initialize -canonical text/plain
-string $body]
    mime::setheader $token Subject $subject
    smtp::sendmessage $token -recipients $recipient
-servers $mailHost\
      -ports $mailPort -originator $myAddress
    mime::finalize $token
}

for {set i 0} {$i < [llength $addresses]} {incr i} {
puts "Sending [expr {$i+1}]/[llength $addresses]"
send_simple_message [lindex $addresses $i] "Test: ne
pas répondre"\
  "Ceci n'est qu'un test. Il n'est pas nécessaire de
répondre.\n\nL"
}

This is the error I get:

Sending 1/1
can't read "i": no such variable
    (reading value of variable to increment)
    invoked from within
"incr i"
    ("for" loop-end command)
    invoked from within
"for {set i 0} {$i < [llength $addresses]} {incr i} {
puts "Sending [expr {$i+1}]/[llength $addresses]"
send_simple_message [lindex $addresses $i] "Te..."
    (file "sendmail.tcl" line 27)

Now, if I change "i" to "ii", it works.
User Comments: gwlester added on 2002-12-02 11:25:22:
Logged In: YES 
user_id=121110

Laurent,

I just tried your example and encountered no problems.

Please verity weither you are still having the problem and
post results here (you may want to put an unset trace on i
and print out the call tree at that point).

If I don't see anything in a week or two I'll close this bug
as non-reproducable.