mIRC Homepage

$read() random line from file [section]

Posted By: Raccoon

$read() random line from file [section] - 19/04/22 07:37 PM

I wouldn't ask this unless there wasn't a terribly elegant scripting solution.

$read(file.txt) allows you to pick a random line out of a file. Very handy for all sorts of reasons.

But if you have a large variety of lists, they each need to be put into their own separate files. There's no meaningful way to divide a single file into several sections.

The request is to allow $read() to pick a random line from a [section] in a file. Like an INI section.

$read(file.txt, i, section)

Picks a random line from file.txt beneath the named [section] if it exists.

$read(file.txt, i, section, N)

Returns line N from the named [section] in file.txt. If N=0 then returns the number of lines in that section.
Blank lines before the next [section] should be ignored.
© 2022 mIRC Discussion Forums