mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Initially I thought that using a hash table would be best for this, but then when trying to get the information to save correctly, I encountered some problems. Some of these problems can be handled by using an ini file, instead...however, that still doesn't seem to be ideal.
Part of the problem, is that for each entry, there would be a minimum of 35 sections (for lack of a better term)...and some of these sections can have multiple entries.

This is for a sophisticated message monitor script.

This is an example picture of the layout that I'm currently working with.
[img=http://img117.imageshack.us/img117/4535/untitlednq3.th.jpg]

In that example, if either of the checked nicks in the first column said a word that's checked in the second column, and was said in one of the channels checked in the 4th column (referencing the 3rd column for network relay if necessary), then a message is echoed to me in the channels that are listed in the 6th column (again, referencing the 5th column for network if necessary). The 7th column (which I haven't got completed yet) would have a check box beside each of the checked channels that are in the 6th column, and would switch between an echoed display, and a message that was sent to the actual channel.

I realize that there's a lot of information here, and that this is complicated, but I'm hoping that (with the assistance of the other excellent helpers on this forum), that I'll be able to get this completed and the full script posted online for others to use.

P.S.: I hope I've covered all the information needed, however, if I missed something, please do your best to indicate what was missed and I'll post it ASAP.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
IM curious as to what issues you came upon with using hash tables. I would probably go with hash tables on this. Or split it between an ini file and hash table(s).

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Kindly post your current code so we can point out things that needs to be fixed or how we can code it better. I would agree that combination of hash tables & INI files would be better. We'll see. smile


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
This is what I currently have, and while it comes up with the correct information, I'm quite sure there's at least one better way to do this. I have included both the hash table and ini file lines, but have them remarked in the code.
Code:
on *:dialog:msg_monitor:sclick:35:{
  var %a = 1, %b = $did(3,0).csel
  while %a <= %b {
    set %nick $did($did(3,%a).csel)
    var %c = 1, %d = $did(6,0).csel
    while %c <= %d {
      set %word $did($did(6,%a).csel)
      var %e = 1, %f = $did(9,0).csel
      while %e <= %f {
        set %network.mon $did($did(9,%e).csel)
        var %g = 1, %h = $did(12,0).csel
        while %g <= %h {
          set %chan.mon $did($did(12,%g).csel)
          var %i = 1, %j = $did(15,0).csel
          while %i <= %j {
            set %network.ann $did($did(15,%i).csel)
            var %k = 1, %l = $did(18,0).csel
            while %k <= %l {
              set %chan.ann $did($did(18,%k).csel)
              ;             .hadd -m Watch %nick %word %network.mon %chan.mon %network.ann %chan.ann
              ;              .writeini -n Watch.ini %nick %word %network.mon %chan.mon %network.ann %chan.ann
              inc %k
            }
            inc %i
          }
          inc %g
        }
        inc %e
      }
      inc %c
    }
    inc %a
  }
}



Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The main issue that I came across, was that of a secondary entry over-writing a previous entry, when I actually wanted both entries...noting as how this is for a monitor/relay script, there's probably going to be multiple entries for each nick in regards to the word(s) being watched for.

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Why not use SQLlite ?
seems to me you would benefit alot from a solid structered referential database.

for pure hash tables
.hadd -m Watch $+(%nick,<>,$md5($ticks)) %word %network.mon %chan.mon %network.ann %chan.ann
Code:
var %t = $hfind(Watch,$nick $+ <>*,0,w) , %c = 1,%rule
while (%c <= %t) { 
   %rule = $hfind(Watch,$nick $+ <>*,%c,w))
   ;parse and validate rule here
}

something like that:)

I sure hope that dialog is for coding purposes only right now. confuses the shiz out of me :P

Last edited by Mpdreamz; 09/03/07 10:28 AM.

$maybe
Joined: Jan 2007
Posts: 259
K
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
Why the $md5? That would use more space than $ticks.
You could use $+($ctime,.,$ticks), IMO this would work better.


Those who can, cannot. Those who cannot, can.
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
True that would be better for uniqueness. I was merely trying to state to fix it by appending a unique suffix didn't think it through thoroughly smile


$maybe
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
At first I was thinking that you could use a hash table for each column, or a single hash table with structured item names (ie nick.1, nick.2, etc). But now I think that the way you are doing it would be more suitable, especially since hash tables support wildcard and regex searching.

You obviously figured out how to compile the columns into a string to store in the hash table (I would use hash tables because of the high search load required in this script). In your nested while loops, you use %a, %b, %c (or similar) to loop through each item in each column. As item names, I would use something like:

hadd Watch $+(%a,.,%c,.,%e,.,%g,.,etc) %col1 %col2 %col3 %col4 etc

That will guarantee you unique item names, and it will also allow you to reverse match which set of items in the columns were actually matched. You may be able to use that information for something.

-genius_at_work

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Quote:
Why not use SQLlite ?

1) I'd never heard of it before.
2) I plan on making this available to the general public, seeing as how I've seen a lot of requests for relay scripts (of various kinds), so I would prefer to use mIRC scripting, since anyone that does use this script will have to have mIRC to start with.

Regarding the dialog, what I posted is just for the single event that was relevant to my post. I prefer to get code working, then make it look nice, rather than have it look nice and then try to get it working.

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
One problem that I can see, is that those variables always start as 1 and then go up to the count of the number checked.
So, if I was to have items 1, 3 & 5 checked the first time, %a would become 1, 2, & 3 (referencing the 1st, 2nd & 3rd checked items).
If, later on, I ran the dialog again, and checked 2, 4 & 6, %a still has values of 1, 2 & 3, since it's still only seeing 3 items checked.

Therefore, using %a in the item name, would return 1, 2 & 3, during both runs, making the 2nd run overwrite the first run.

Either that or I'm misunderstanding your post regarding the unique item names.

Note: I only used %a in the above, but since the others work in similar manners, the same would (I think) apply to them.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Presumably, the hash table would be rebuilt each time the dialog is closed. I might do it like this:

[original hash already exists]
- open dialog
[original hash remains]
- columns are changed by user
[original hash remains]
- user clicks 'save'
[original hash is renamed (hsave + hload)]
[new hash is created (with old name)]
[while loops populate hash as 1.1.1.1.1.1, 1.1.1.1.1.2, etc]

Essentially, don't try to convert or preserve the original hash, just rebuild it each time changed are made and saved. The old hash should be hsaved in case the new hash fails to be created properly.

-genius_at_work


Link Copied to Clipboard