use hash tables then, need to keep the info somewhere when the dialog is closed,
on *:topic:#:{
hadd -m topics $+($cid,:,#,:,$calc($hmatch(topics,$+($cid,:,#,:*),0)+1)) $1-
}
then you can get the history with:
alias topichistory {
var %x = 1
while ($hget(topics,$+($cid,:,$active,:,%x))) {
echo -a $ifmatch
inc %x
}
}
not tested but something like that should work.
if you replace $cid for $network you could keep the topics after you quit just using /hsave to save the table, as $cid's might be different when you connect again.