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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array question - more than one data field

Status
Not open for further replies.

bgode

Programmer
Jan 6, 2004
5
0
0
US
Array question:
I've been using TCL, but this is the first time I've had a real use for arrays. I have rad the posts about multiple indexes, but what's the best,cleanest way to load and use an array with a single index and multiple data fields for each index? For example, I have data with employee number as key, and I want to load address, city, state, and zip as separate elements for each employee into an array. The data will be in simple text files that I have not built yet, so if there's some way I can set up the data to make coding simpler, I can do that too.
 
If I understand what you're trying to do, I think you might want an array of lists. That is, each element of the array would be a list whose elements, in turn, are address, city, state, and zip:
set a(i) {$address $city $state $zip}

If you build your list as a list of lists:
set datalist {$empNo1 {$address1 $city1 $state1 $zip1} $empNo2 {$address2 $city2 $state2 $zip2} ...},
then you can use:
array set a $datalist to build your array.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top