Date: Thu, 11 Jul 2024 13:12:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to pass an object from inside its own method to a helper function Newsgroups: comp.lang.tcl References: Content-Language: en-US From: Schelte In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Organization: KPN B.V. Path: ...!2.eu.feeder.erje.net!feeder.erje.net!feed.abavia.com!abe007.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail Lines: 23 Injection-Date: Thu, 11 Jul 2024 13:12:56 +0200 Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com" Bytes: 1503 On 11/07/2024 12:03, Mark Summerfield wrote: > I worked out how to do it: > > proc make_file_menu {app} { > .menu.file add command -command [list ${app}::my on_quit] \ > -label Quit -underline 0 -accelerator Ctrl+Q > } > Or less hacky: proc make_file_menu {app} { .menu.file add command -command [list $app on_quit] \ -label Quit -underline 0 -accelerator Ctrl+Q } Originally you had $app inside curly braces, which prevented it from being substituted at definition time. At execution time, the app variable was out of scope. Schelte.