mIRC Home    About    Download    Register    News    Help

Print Thread
#260862 27/06/17 12:17 PM
Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
is there a way to display message if text file is empty

I use this to msg $nick the contents of the file

Quote:
on *:Text:!read:#:{
play $nick system\birthday.txt }


This msg the nick the contents but also want to let him know if the file is empty

Thanks

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
if ($file(birthday.txt) == $null) msg $nick no such file birthday.txt
if ($file(birthday.txt) == 0) msg $nick birthday.txt has size zero

Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Both gives same message: no such file birthday.txt

If birthday.txt does not exist it should be = no such file
If birthday.txt does exist it should be = file is empty

Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
sorry my mistake
it works
fixed

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
when path is not given, mirc looks in this folder for the file:

//echo -a $mircdir

Is the file actually there?

Edit: your last post wasn't showing yet.

Last edited by maroon; 27/06/17 05:29 PM.
Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Yes the file is there
How will i find a specific word in the text file say find a nick and display the line


Quote:
on *:Text:!read:#:{
play $nick system\birthday.txt }


Last edited by raycomp; 11/08/17 05:27 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Your filename is a relative reference, where system\ is a subfolder of the same folder where your mirc.ini is located.

take a look at the s/w switches for $read. It depends on the format for your line. If the first word of each line is a nick and you want to display only the text following that first word:

$read(system\birthday.txt,nts,$nick)

This searches for a delimited word, so searching for the nick TEST won't find the line TEST1. It's equivalent to $gettok($read(system\birthday.txt,ntw,$nick *),2-,32)

If you want to find a line where $nick is a space delimited word in the line and return that entire line, your search should include the spaces: $read(system\birthday.txt,ntw,* $nick *)


Link Copied to Clipboard