mIRC Home    About    Download    Register    News    Help

Print Thread
#140146 22/01/06 07:26 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Hi,
I have this alias to delete a line from a text file, but it isn't working and I'm not sure why. I have a blacklist script that writes addresses to ignore in $wildsite format. I know that it's the same as using $address(PersonsName,2), but this alias won't delete the line.
Code:
/delbad {
  var %line = $read(badlist.txt,w,$address($1,2))
  var %linenum = %readn
  write -dl %linenum C:\mirc\badlist.txt
}


Thanks for any help.

#140147 22/01/06 07:40 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You can't have a space between the -l and the line number.

Try it like this:

write -dl $+ %linenum C:\mirc\badlist.txt

Also, you have %readn when it should be $readn .

-genius_at_work

#140148 22/01/06 07:40 PM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
/delbad { var %line = $read(badlist.txt,w,$address($1,2)) var %linenum = %readn write -dl %linenum C:\mirc\badlist.txt}

how about $readn

#140149 22/01/06 07:49 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
LOL, oops about the $readn thing. And as for the -l thing, when I've used "write -l", it let me put a space after the -l, but I'll try it that way. Thanks for catching my mistakes. smile

#140150 22/01/06 07:54 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
OK, I've tried it with the corrections, and it still won't delete the line. I tried with -dl %linenum and -dl $+ %linenum. The usage of this alias is "/delbad Blake". Here's the alias again
Code:
/delbad {
  var %line = $read(badlist.txt,w,$address($1,2))
  var %linenum = $readn
  write -dl %linenum C:\mirc\badlist.txt
}

#140151 22/01/06 08:45 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Why but why dont you try debugging it?

/delbad {
///echo -s $!address( $1 ,2)) = $address($1,2))
var -s %line = $read(badlist.txt,w,$address($1,2))
var -s %linenum = $readn
///echo -s write -dl %linenum C:\mirc\badlist.txt
write -dl %linenum C:\mirc\badlist.txt
}

I would say your most likely result is that the $read failed to located the speciifeid line, makling $readn = $null, causing the /write to fail.

#140152 23/01/06 01:47 AM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I've worked on debugging it and found that my variables echo what I want them to, but this still won't work, with or without the $+ between the -dl and the %linenum variable.
Code:
/delbad {
  var %line = $read(badlist.txt,w,$address($1,2) $+ *)
  var %linenum = $readn
  echo -a Line %line Linenum %linenum
  write -dl $+ %linenum C:\mirc\badlist.txt
}

#140153 23/01/06 02:47 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
The problem might be that you are using different paths for the read file and the write file. Try it like this:

Code:
/delbad {
  var %file = "badlist.txt"
  var %line = $read(%file,w,$address($1,2) $+ *)
  var %linenum = $readn
  echo -a Line %line Linenum %linenum
  write -dl $+ %linenum %file
}


-genius_at_work

#140154 23/01/06 04:46 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
good point! that or the files read only access.

#140155 23/01/06 02:04 PM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Thank you for that catch. The read and the write were happening in two different files in two separate directories. I really appreciate your help.

#140156 23/01/06 10:13 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
might have been nice to have said it to genius_at_work then smile

#140157 24/01/06 12:38 AM
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Not sure what you meant there. If you meant that I replied to your post to say thank you, I always reply to the last post when adding to a thread...didn't mean not to include genius_at_work in the "thank you". Thanks to all of you for taking the time to look at this and offer suggestions.


Link Copied to Clipboard