What defines them as the top5? Would they be #1 in each channel?

$read doesn't work right with ini files. That is what $readini and $ini is for.

File.ini
[Topic]
item=data

$readini(file.ini,section,item) = data

Use $ini to find information in your ini file if you dont have a direct path to "data", or want information other than "data".

Originally Posted By: mirc help file
$ini(file,topic/N,item/N)

Returns the name/Nth position of the specified topic/item in an ini/text file.

$ini(mirc.ini,0) returns total number of topics in mirc.ini

$ini(mirc.ini,1) returns name of 1st topic in mirc.ini

$ini(mirc.ini,help) returns Nth position of topic help if it exists, or returns 0 if it doesn't exist

The item/N parameter is optional. If you specify N = 0, it returns the total number of topics/items.


With $readini you have to have the actual values, you cannot use $readini to tell you what the 1st item is or how many items there are in a topic. You use $ini for that. So if you want the 1st data in each topic, you have to use $ini to return the 1st item name, then $readini to return the data for that item.

I think your overall problem is how you want to organize your ini file. I'd suggest numbering them consistently within each topic (Channel). Which means

[#Channel1]
1=first test line chan1
2=second test line chan1
3=third test line. chan1
[#Channel2]
1=first test line. chan2
2=second test line chan2
3=third test line chan2

If you want, you can make a seperate topic named Top5 which has the 5 favorite quotes, or you can use a while loop to find the top results for each channel.


This code will scan your file.ini and return the 1st items data for each topic.

Code:
;find how many topics
var %ini = $ini(file.ini,0), %x = 1, %topic, %item
while (%x <= %ini) {
  ;Loop through topics to gather data from each one.
  ;Topic %x
  %topic = $ini(file.ini,%x)
  echo -a Topic %x is %topic

  %item = $ini(file.ini,%topic,1)
  ;%item = 1st item under %topic

  echo -a Result %x : $readini(file.ini,%topic,%item)
  ;return the first item under %topic

  inc %x
}