Hi, i am new to tcl programming. i have one question about array. i store data from .txt files in an array call country.
[highlight #EF2929]array set country {$food $place}[/highlight]
where $food and $place is the data that i get from the .txt file. i want to display them so i do:
foreach {$food $place} [array get country] {
puts "Food : $food Where? : $place"
}
and the output is:
Food : Burger Where? : Mexico
Food : Curry Where? : India
Food : Sushi Where? : Japan
now i want to count the total elements in array country. i try [highlight #EF2929]puts "[array size country]"[/highlight] but the output is 1.
the expected output:
Food : Burger Where? : Mexico
Food : Curry Where? : India
Food : Sushi Where? : Japan
Total elements : 3
Please help, thanks in advance
[highlight #EF2929]array set country {$food $place}[/highlight]
where $food and $place is the data that i get from the .txt file. i want to display them so i do:
foreach {$food $place} [array get country] {
puts "Food : $food Where? : $place"
}
and the output is:
Food : Burger Where? : Mexico
Food : Curry Where? : India
Food : Sushi Where? : Japan
now i want to count the total elements in array country. i try [highlight #EF2929]puts "[array size country]"[/highlight] but the output is 1.
the expected output:
Food : Burger Where? : Mexico
Food : Curry Where? : India
Food : Sushi Where? : Japan
Total elements : 3
Please help, thanks in advance