mIRC Home    About    Download    Register    News    Help

Print Thread
#156689 19/08/06 12:50 PM
Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
Hi, I am trying to $read from a text file which has lines like this:

"50479","+43.077155","-093.312569","THORNTON","IA","CERRO GORDO","STANDARD"
"00604","+18.493520","-067.135883","AGUADILLA","PR","AGUADILLA","STANDARD"

when i try reading a random line from the file, it works perfectly, but when i try /echo -a $read(file.txt,S,"50479") mirc returns * /echo: insufficient parameters. What i eventually want to do is parse the line from the text file and use the parsed line in a socket script. Can someone tell me what i am doing wrong?


keek: Scots - intr.v. keeked, keek·ing, keeks
To peek; peep.
#156690 19/08/06 01:05 PM
Joined: May 2006
Posts: 93
Babel fish
Offline
Babel fish
Joined: May 2006
Posts: 93
try
/echo -a $read(file.txt,s,"50479")
instead of
/echo -a $read(file.txt,S,"50479")

if it doesn't work maybe is a problem of "" in "50479"...

#156691 19/08/06 01:23 PM
Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
still wont work, i have tried all the types of $read that i can remember (with and without quotes, wildcards, and both S and s. If i cannot find an easy way to read the liine, i will have to convert the zipcodes.txt file to an ini file, and i have no way of doing that easily without $read, other than retypeing the whole file, and that is a task I do not want to undertake because there are over 42,000 lines in the file. Any and all help would be appreciated.


keek: Scots - intr.v. keeked, keek·ing, keeks
To peek; peep.
#156692 19/08/06 01:29 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The s switch makes $read() look for a line that begins with the specified word(s). "50479" is not a word because it's not separated from the rest of the line by a space but by a comma.

Use the w switch instead: //echo -a $read(file.txt,w,"50479"*)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#156693 19/08/06 01:29 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Quote:
try
/echo -a $read(file.txt,s,"50479")
instead of
/echo -a $read(file.txt,S,"50479")


The capital S returns the first line text, but it also does that even if I do:
//echo -a $read(file.txt,S,xyz)

From mirch.hlp, small-s "Scans the file info.txt for a line beginning with the word your_word and returns the text *following* the match value."

Since your line has no spaces in it, then there's no following word to find. If you put the entire line#1 into a %variable, and then did:

//echo -a $read(file.txt,s,%variable) . $readn

... you will see that even without returning the text, it did identify the correct line.

Perhaps you should instead use: //echo -a $read(file.txt,w,"50479"*)

#156694 19/08/06 01:31 PM
Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
holy crimeny qwerty, nowi see why the made you a mod here smile works perfectly, thank you very much


keek: Scots - intr.v. keeked, keek·ing, keeks
To peek; peep.

Link Copied to Clipboard