mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
#128637 29/08/05 04:19 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try changing msg to echo and see what your output is. Maybe you just have too many results trying to be displayed too quickly. In that case, you'd want to play the results.


Invision Support
#Invision on irc.irchighway.net
#128638 29/08/05 04:41 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
I thought it might be too many also, so I made a temp file with only a few results and it still caused excess flood.

When I try echo it locks up the mirc process.

Edit:
I don't know if it matters but the lines of the text file are in this format

Name - IP
Name2 - IP2
Name3 - IP3
etc etc

Last edited by schaefer31; 29/08/05 04:44 PM.
#128639 29/08/05 04:59 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on 1:text:!search *:#mychannel:{
  var %search = $2
  var %lines = $lines(database.txt)
  var %currentline = 1
  var %total = 0
  while (%currentline <= %lines) {
    var %data = $read(database.txt,w,%search $+ *,%currentline)
    if (%data != $null) {
      msg #mychannel %data
      inc %total
    }
    var %currentline = $calc($readn + 1)
  }
  msg $mychannel %total found.
}


That will fix it. I forgot that $N's don't work in a loop.


Invision Support
#Invision on irc.irchighway.net
#128640 29/08/05 05:31 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
It still causes excess flood/locks up. I was able to quickly switch to the mirc process which the trigger is on and notice it endlessly echo'd the same results. I had to end process on it to kill it.

#128641 29/08/05 05:40 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Can you give me an example of how you're searching and of what lines you're expecting to see from the search? It's working fine here, though it is definitely fast enough to cause an excess flood if you're getting more than a few results.

Here's the code with /play so that you won't get excess flood with too many results being found. Though, something isn't right if you're getting it stuck on one thing. You do have the $readn line in there, right?

Code:
on 1:text:!search *:#mychannel:{
  var %search = $2
  var %lines = $lines(database.txt)
  var %currentline = 1
  var %total = 0
  while (%currentline <= %lines) {
    var %data = $read(database.txt,w,%search $+ *,%currentline)
    if (%data != $null) {
      write temp.txt %data
      inc %total
    }
    var %currentline = $calc($readn + 1)
  }
  write temp.txt %total found.
  play temp.txt 1500
  .remove temp.txt
}


Also, you can do this just for testing purposes... right after the inc %total line, add:

if (%total >= 10) { halt }

Then, it will stop after 10 rounds. You can then check your out from echo/msg, or you can open temp.txt if you're using /play from this updated script.

Let me know your search command you used, the results you expect to see, and the results you do see after using the halt line above.

#128642 29/08/05 08:32 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
As previously said, in the text file the lines are formatted like so:

Name1 - IP1
Name1 - IP2
Name1 - IP3
Name2 - IP1
Name2 - IP2

I used a temp file which only has these 5 lines.

In the channel I do the trigger '!search Name1' (I expect it to return any lines which contain 'Name1' in the first field) and it returns the first result 'Name1 - IP1' from the text file and then immediately afterwards is flooded off the server.

From your code, I made only the obvious change (the channel name). I replaced all 3 instances of 'mychannel' with the actual channel.

#128643 29/08/05 09:03 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, I'm beginning to feel stupid today... this makes 2 scripts with stupid mistakes in them. That's what I get for trying to code snippets in the middle of writing a mIRC RPG. smile

This will work for you. I wasn't incrementing properly. I also didn't give the proper /play syntax.

Code:
on 1:!search *:#mychannel: {
  var %search = $2
  var %lines = $lines(database.txt)
  var %currentline = 1
  var %total = 0
  while (%currentline <= %lines) {
    var %data = $read(database.txt,w,%search $+ *,%currentline)
    if (%data != $null) {
      write temp.txt %data
      inc %total
      var %currentline = $readn
    }
    inc %currentline
  }
  write temp.txt %total found.
  play $chan temp.txt 1500
  .remove temp.txt
}


Invision Support
#Invision on irc.irchighway.net
#128644 29/08/05 09:10 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Hehe, you forgot to add on 1: text :

But I noticed and corrected it. Thanks to you also for helping, I will find ways to use this for sure.

#128645 29/08/05 10:20 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:
Thanks for suggestion, I saved it in case I might have use for it later.

Though, I did a brief test and it caused an excess flood after returning the first line.


Did the script work for you the last one i wrote?


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#128646 29/08/05 10:22 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Yes, both scripts work just fine. Thanks again.

#128647 30/08/05 02:05 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
Hehe, you forgot to add on 1: text :

But I noticed and corrected it. Thanks to you also for helping, I will find ways to use this for sure.


Lol. I was using it as an alias to test it since I couldn't connect to IRC from where I was writing it and I missed that when converting it back to on text. smile


Invision Support
#Invision on irc.irchighway.net
#128648 30/08/05 10:22 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
One more question...

Assuming the same format of the database in the text file:

Name1 - IP
Name1 - IP2
Name1 - IP3
Name2 - IP1
Name2 - IP2
etc etc

If I do "!search ame" is it possible to make it search only the first field (names) for any line that contains "ame" and return then as a result? It's important that it only searches for "ame" in the first field and ignores the " - IP" part as I could do "!search 2" and it would return any line that contains a 2 in the IP. I don't want it to do that. I only want it to return lines that contain a 2 in the NAME.

Last edited by schaefer31; 30/08/05 10:23 PM.
#128649 01/09/05 12:46 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on 1:text:!search *:#mychannel: {
  var %search = $2
  var %lines = $lines(database.txt)
  var %currentline = 1
  var %total = 0
  while (%currentline <= %lines) {
    var %data = $read(database.txt,w,* $+ %search $+ *-*,%currentline)
    if (%data != $null) {
      write temp.txt %data
      inc %total
      var %currentline = $readn
    }
    inc %currentline
  }
  write temp.txt %total found.
  play $chan temp.txt 1500
  .remove temp.txt
}


That code will allow you to do what you want.

Examples:

Text file includes:

this is a test - 123.345.567.789
this is not a test - 234.546.123.56
neither is this - 546.234.123.64
44 but this is a test - 354.78.23.1
487 - 784.354.487.64

!search this
* returns the first 4 lines

!search test
* returns lines 1,2,4

!search 4
* returns lines 4,5

As a note, however, your first section cannot contain a hypen in it like this:

let's-go-do-this - 234.36.123.34

If you want to allow hyphens in the first section, change the - divider between the two sections to something that won't be used in the first section and then change the hyphen in *-* to whatever you're using.


Invision Support
#Invision on irc.irchighway.net
Page 2 of 2 1 2

Link Copied to Clipboard