ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> incrtcl-develop
incrtcl-develop
[Incrtcl-develop] [ incrtcl-Bugs-2840994 ] itk_component createCmds in wrong scope
by SourceForge.net other posts by this author
Aug 20 2009 4:03AM messages near this date
[Incrtcl-develop] [ incrtcl-Bugs-2856166 ] no Tcl version screen in index script | [Incrtcl-develop] [ incrtcl-Bugs-2837655 ] Namespace import fails to properly create class commands
Bugs item #2840994, was opened at 2009-08-20 12:02
Message generated for change (Tracker Item Submitted) made by pwdraper
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=113244&aid=2840994&group_id=13244

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Other
Group: 4.0*
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Peter W. Draper (pwdraper)
Assigned to: Arnulf Wiedemann (wiede)
Summary: itk_component  createCmds in wrong scope

Initial Comment:
Hi,

when I create components using the itk_component command I frequently use
loops, so need to access local variables in the createCmds. That no longer
seems to work. For instance the following script:


package require itcl
package require itk

itcl::class Test {

   inherit itk::Toplevel

   constructor {args} {
      puts "Construction: $this ->  $args"
      eval itk_initialize $args

      for {set i 0} {$i<10} {incr i} {
         itk_component add button$i {
            button .b$i -command "puts $i"
         }
         pack $itk_component(button$i)
      }
   }

   destructor {
      puts "Destruction: $this"
   }
}

Test .t -title "New window"



now produces the error:



Error in startup script: can't read "i": no such variable
    while executing
"button .b$i -command "puts $i""
    (while creating component "button0" for widget "::.t")
    invoked from within
"::itcl::builtin::Archetype itk_component $option {*}$args"
    (object "::.t" method "::itk::Archetype::itk_component" body line 2)
    invoked from within
"itk_component add button$i {
            button .b$i -command "puts $i"
         }"
    while constructing object "::.t" in ::Test::constructor (body line 6)
    invoked from within
"Test .t -title "New window""
    (file "vartest.tcl" line 25)

So the loop variable "i" is no longer in scope during the execution
of the createCmd.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=113244&aid=2840994&group_id=13244

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Incrtcl-develop mailing list
Incrtcl-develop@[...].net
https://lists.sourceforge.net/lists/listinfo/incrtcl-develop

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved