I'm trying to create a list of arrays. In C this would be an array of structs, I guess. The idea is there's a number of records (the arrays) and the list just keeps 'em easy to look up. It doesn't work

For a sample, when the script starts it initialises an array and populates the list thus:
Code: Select all
global RecordList
unset RecordList
set ARecord ""
upvar $ARecord Record
set Record(Ref) "12345"
set Record(IP) "123.456.789.0"
set Record(nick) "ABotter"
lappend RecordList Record
set Record(Ref) "98765"
set Record(IP) "098.765.432.1"
set Record(nick) "BBotter"
lappend RecordList Record
set Record(Ref) "33333"
set Record(IP) "333.3.333.1"
set Record(nick) "CBotter"
lappend RecordList Record
unset ARecord
set maxrecs [llength $RecordList]
putlog "Records: $maxrecs"

$maxrecs says '3' so I assume the list is populated. Next, I try to pull out the last record:
Code: Select all
global RecordList
upvar #0 RecordList ARecordList
set LastRecord [llength $ARecordList]
upvar [lindex $ARecordList $LastRecord] Record
putserv "NOTICE $nick :Latest record is $LastRecord:"
putserv "NOTICE $nick :$LastRecord $Record(Ref) $Record(IP) $Record(nick)"
But... if I make $LastRecord '2' or '1' the thing just comes back and says "Tcl error [do_ABlistcmd]: can't read "Record(Ref)": no such variable".
This is doing my head in (even more so than the wallop thing). I think I'm going to cry.