EDIT: This was meant as a reply to the OP.

If you really need every line's information, $fread is probably going to be the most efficient. If you want to search for a given text in the file, then $read() with -r,-s,-w options is probably the best for a single match (as would be the case for most spam/language catchers), or for multiple matches with a search text, /filter is probably the best option.

With more details on what the script is meant to do, the best option could be given. But, a real basic script if you don't want to learn anything beyond $read() would be...

Code:
alias ReadFile {
  var %counter = 1, %total = $lines(file)
  while (%counter <= %total) { 
    var %line = $read(file,%counter)
    ; Do whatever you want with %line here (such as the following echo command)
    echo -a %line
    inc %counter
  }
}


Replace the two instances of "file" with the filename (and path if it's located somewhere other than $mircdir).

Use: /readfile

Again, there are better options, but this is about as basic as you can get.

Here's a basic spam/language check...

Code:
on *:text:*:#: {
  var %counter = 1, %total = $0
  while (%counter <= %total) {
    if ($read(file,w,$+(*,$($+($chr(36),%counter),2),*))) { echo -a spam/language found... | break }
    inc %counter
  }
}


The file can then be set up as:
badword1
badword2
badword3
etc...

Of course, such a filter wouldn't just echo something. You'd usually kick/ban the person or something along those lines. This is just a really basic example.

Last edited by Riamus2; 21/02/11 10:57 PM.

Invision Support
#Invision on irc.irchighway.net