comp.lang.tcl
[Top] [All Lists]

Re: Entry and -textvariable

Subject: Re: Entry and -textvariable
From: David Golightly
Date: Sat, 17 May 2008 10:00:54 -0700 PDT
Newsgroups: comp.lang.tcl

On May 12, 10:47 pm, Aric Bills <aric.bi...@xxxxxxxxx> wrote:
> Hi David,
>
> The $cmd you set and whose value you check in your proc is a local
> variable.  The $cmd you assigned to your entry widget as -textvariable
> is a global variable.  That's why you're seeing the behavior in
> question.
>
> To modify the global variable $cmd in your proc, you need to do ONE of
> the following things:
>
> * before your first use of the variable cmd, type "global cmd"; this
> tells the interpreter that within your proc, $cmd refers to a global
> variable rather than a local one.
>
> OR
>
> * before your first use of the variable cmd, type "variable cmd"; this
> tells the interpreter that within your proc, $cmd refers to a
> namespace variable rather than a local one.  This will only work if
> your proc is in the global namespace.
>
> OR
>
> * each time you want to modify the global variable $cmd, use it's
> fully-namespace-qualified name: ::cmd (so, [set ::cmd 6], [puts
> $::cmd], etc.).
>
> Hope that helps,
> Aric

That's an excellent explanation.  I've got it working now.  Thank you!

-David

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy