Each function that uses or modifies these global variables must declare them
with "global".

proc main {} {
    global glob_var
    set glob_var 1
    ...
}

proc func {} {
    global glob_var
    set glob_var 2
    ...
}

Gilles


Otto Stolzenberger wrote:

> I guess I should explain my problem a bit more.  I have some variables
> that I need to set to a default value when the application is first run.
>  These values will change as the user modifies settings.  I set these
> default values in the Main function and then made them global.  Is this
> correct?  My other procedures still complain about the variable.
>
> On Wed, 12 Jan 2000 13:03:33 Rick Macdonald wrote:
> > On Wed, 12 Jan 2000, Otto Stolzenberger wrote:
> >
> > > How can I set global variables in Visual TCL?  Thanks.
> >
> > You just delcare them global in the procs that need to access them. You do
> > not have to declare them anywhere outside of these procs.
> >
> > proc DoIt {args} {
> >     global goodstuff widget
> >     puts "global stuff=$goodstuff(junk)"
> >     Window show $widget(GetUserId)
> >     ...etc...
> > }
> >
> > This is how you use the vTcl global "widget" array that contains widget
> > aliases (as shown in the tutorial).
> >
> > ...RickM...
> ---------------------------------------------------------------------------
> To unsubscribe from the Visual Tcl mailing list, please send a message
> to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
> message body (where [EMAIL PROTECTED] is your e-mail address).

---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).

Reply via email to