Re: want to spread my code over different files



On 29 mrt, 22:02, Ulrich Schöbel <ulr...@xxxxxxxxxxx> wrote:
Am Thu, 29 Mar 2007 00:11:53 -0700 schrieb Arjen Markus:





On 29 mrt, 07:29, "raul" <rahuldotpa...@xxxxxxxxx> wrote:
hi
i want to have a global array which is populated in one file say file1
and then accessed and printed in the other file say file2.how do i do
this.
can you please show me a small sample code for this?

Regards
raul

File 1: a.tcl

global myarr
set myarr(1) 2
set myarr(2) 3

File 2: b.tcl

global myarr
puts "$myarr(1), $myarr(2)"

File 3: c.tcl

# Put it all together
source a.tcl
source b.tcl

The global command gives access to one or more global variables
regardless of where they are defined in the source files.

Regards,

Arjen

Hi Arjen,

there's no need for the global commands in File 1 or File 2.

Regards

Ulrich- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi Ulrich,

yes, you are right, but I would use them anyway as a form
of documentation.

Regards,

Arjen

.



Relevant Pages