Sujet : Re: How to pass an object from inside its own method to a helper function
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tclDate : 11. Jul 2024, 13:55:53
Autres entêtes
Message-ID : <ygamsmo2ili.fsf@akutech.de>
References : 1 2 3 4
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* Mark Summerfield <
mark@qtrac.eu>
| On Thu, 11 Jul 2024 13:12:52 +0200, Schelte wrote:
| > 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.
>
| Thank you, that works great.
To save you trouble on your TCL-road ahead, make sure you understand the
difference between
-command {$app on_quit}
which you had originally in your code and
-command [list $app on_quit]
which is the correct way of doing things and
-command "$app on_quit"
which also most probably would "work" right now,
until some day it won't :-)...
HTH
R'