[vtkusers] tlcTK problems
Christian Poecher
poecher at icom-consulting.de
Tue Apr 9 06:40:33 EDT 2002
For Tcl questions you'd better try the newsgroup comp.lang.tcl.
The problem with your code is, that the scope of variable a is just
crea. the line "global a" does exactly nothing. You must declare a
outside of the vars, if you want to work with globals.
The second error is, that you need a line "global a" in scrivi, to
access the var a.
I'd recommend reading the tcl-man entry for global for details on scope
of variables.
The corrected code is:
proc crea {} {
global a
set a 4
}
proc scrivi {} {
global a
puts stdout $a
}
wm withdraw .
set a init
crea
scrivi
Giancarlo Amati schrieb:
>
> Hi everybody, I know that this is a Vtk mailing list, but I will disturb
> you for a tcl problem that concerning execution of tcl procedure; I have
> the following code:
>
> proc crea {} {
> global a
> set a 4
> }
>
> proc scrivi {} {
> puts stdout $a
> }
>
> wm withdraw .
>
> crea
> scrivi
>
> the tcl interpreter give me the followind error:
>
> Error in startup script: can't read "a": no such variable
> while executing
> "puts stdout $a"
> (procedure "scrivi" line 2)
> invoked from within
> "scrivi"
> (file "scrivi.tcl" line 13)
>
> it seems that tcl interpreter executes scrivi procedure before crea
> procedure. Why? isn't tcl a sequential iterpreter?
> Any idea how to executer crea procedure before the second one?
>
> Thank you very much.
>
> Best regards,
> Giancarlo
>
> ----------------------------------------
> dott. Giancarlo Amati |
> (amati at ira.cnr.it) |
> |
> National Research Council |
> RadioAstronomical Institute |
> office phone n. +39 051 6399405 |
> via Gobetti 101 - Bologna (Italy) |
> ----------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
--
________________________________________________________________________
Christian Poecher mailto:poecher at icom-consulting.de
ICOM GmbH Phone: +49 241 9367-1554
Schloss-Rahe-Str. 15, 52072 Aachen, Germany Fax : +49 241 9367-1589
________________________________________________________________________
More information about the vtkusers
mailing list