mIRC Home    About    Download    Register    News    Help

Print Thread
#260452 22/04/17 04:00 PM
Joined: Dec 2016
Posts: 18
A
apoio82 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Dec 2016
Posts: 18

Which command should I use so that several words written in several lines of the .txt are read in sequence each time it is requested. I just know how to make random $ read (phrases.txt)

ex:
First line1
Second row2
Third line3
....

thank you

apoio82 #260453 22/04/17 05:28 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
if you know which specific line of the file you need:

echo -a $read(file.txt,nt,specific_number)

if you want to scan for the first line your word appears:

set %text $read(file.txt,ntw,*word*,%starting_line)

The %starting_line is optional parameter that lets you start deeper in the file than line 1. If you want a complete word, you'll need more processing to make sure it didn't find 'sword' or 'wordsmith'. You probably wouldn't want to avoid false matches by having spaces between the asterisks and your searchword, because that wouldn't find when the word was at the start of a line, or touched by a comma, period, quote, etc.

If you want to scan for ALL the lines in a file containing your various words, you can have a loop where you search again starting with $calc($readn +1) until you get nothing.

A faster way to process a text file is to

filter -fw text.txt @window *

to fetch all the lines into the @window, then use $fline to search the window. You can get the text either by:

var %line $fline(@window,1,*wildstring*) to get the line number
var %text $line(@window,%line)

or

var %text $fline(@window,1,*wildstring*).text


Link Copied to Clipboard