On Wed, 12 Jan 2000, 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.

Here's a sample program you can actually run through tclsh or wish:

proc main {} {
    global var1 var2 var3 var4
    set var1 aaa
    set var2 bbb
    set var3 ccc
    set var4 ddd
    return
}

proc UseVars {} {
    global var1 var2 var3 var4
    puts "vars 1 to 4 are: $var1 $var2 $var3 $var4"
}

main
UseVars
exit


Here's an actual run where I pasted the code into an xterm running tclsh:

sys4:/prg/rickm> tclsh
% proc main {} {  
    global var1 var2 var3 var4
    set var1 aaa
    set var2 bbb
    set var3 ccc
    set var4 ddd
    return
}

proc UseVars {} {
    global var1 var2 var3 var4
    puts "vars 1 to 4 are: $var1 $var2 $var3 $var4"
}

main   
UseVars
% % % % % vars 1 to 4 are: aaa bbb ccc ddd

...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).

Reply via email to