Deutsch   English   Français   Italiano  
<nnd$51f688df$79eeaed5@f984d21cd0a14d8f>

View for Bookmarking (what is this?)
Look up another Usenet article

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: <mwSdnbvrgID6NBL7nZ2dnZfqnPednZ2d@brightview.co.uk>
 <mwSdnbrrgIByMBL7nZ2dnZfqnPcAAAAA@brightview.co.uk>
Content-Language: en-US
From: Schelte <nospam@wanadoo.nl>
In-Reply-To: <mwSdnbrrgIByMBL7nZ2dnZfqnPcAAAAA@brightview.co.uk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$51f688df$79eeaed5@f984d21cd0a14d8f>
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.