Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with lists => parameter?

Status
Not open for further replies.

sergelaurent

Technical User
May 30, 2005
52
0
0
FR
#I have variable containing :
#array set toto [list {0} {} {1} {tom tim tam} {2} {fom fim fam}]

#I am using a function where I would like to use toto as an #input parameter!!!

proc essai {toto}{
...........
}

essai $toto
#When executing this command, I got an error message telling #me that it can't read toto as it is an array!!!!

So, can someone tell me how I can pass toto as a parameter?
 
Hi

As far as I know, arrays can not be passed directly, only with [tt]upvar[/tt], like this :
Code:
array set toto [list {0} {} {1} {tom tim tam} {2} {fom fim fam}]

proc essai {argument} \
{
  upvar $argument local
  puts "From the proc : $local(1)"
}

puts "From outside : $toto(1)"

essai toto

Feherke.
 
Alternatively, lists can be passed and the array set stuff done in the proc.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top