mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2005
Posts: 37
G
gans Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
hi everyone im trying to search thru hash tables
im using while() at the min but its using alot of cpu
im not sure how else to do it i need it to search thru $strip($2-) in hash to see if it matches %pack
if it does then ignore it or add the new pack to hash tables
has anyone here got any other ways of doing this
im using $strip cous its got colors in hash and i need to keep the colors there

thanks.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Can you be more explicit about what you want to search with your hash table ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2005
Posts: 37
G
gans Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
ok hash table kinda looks like this

table packs hash info
Latest Pack-1 [700M] FILE WITH COLORS

and %pack = FILE WITHOUT COLORS
i want to use $strip() so when it searches the hash table it ignores the colors ect

im using while to loop thru the hash table it is working fine tho but it gets used alot and its using alot of cpu

Last edited by gans; 23/08/07 04:51 PM.
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
can you show us your code?


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Jul 2005
Posts: 37
G
gans Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
%Result = Its found right format for text for %pack ect

Code:
  if (%Result == Yes) { var %Loop = 1
    while ($strip($gettok(Latest),%Loop).data, 2-, 32) {
      if ($ifmatch == %Pack) { var %Latest = Yes | break }
      inc %Loop
    }
    if (!%Latest) {
      Hadd -m Latest $+(Pack-,$calc($hget(Latest,0).item + 1)) %Pack-Size %Pack | UnSet %Latest
      msg %TChan 15Added 11= $gettok($hget(-Latest,$+(Pack-,$hget(-Latest,0).item)), 2-, 32) 11=15 To !Latest
    }
  }


its working ok but when the hash log is big it can use alot of cpu im just wondering if theres a better way that dont use alot of cpu

Joined: Jul 2006
Posts: 107
L
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
I'm not very experienced with hash tables, but
this:
Code:
while ($strip($gettok(Latest),%Loop).data, 2-, 32)

makes no sense at all.

And why are you searching -Latest, when your table is Latest?

Perhaps you should post your entire code


LonDart
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
I think you're going the wrong way about this, check out /help $hfind with respect to the "r" switch.

Code:
alias example {
  var %pack = text to find
  hadd -m example item some 00,02text 11t04O 11f00iND
  if $hfind(example,$+(/,%pack,/Si),1,r).data {
    echo -ag $v1 = $hget(example,$v1) $+([Searched for: ",%pack,"])
  }
  hfree example
}

Joined: Jul 2005
Posts: 37
G
gans Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
LonDart:
i set that code to hash table Latest in that code only to show you all how it works
the proper code is abit diff as its $network-%tchan-Latest so i set it to just Latest
to make it look more simple for you lot to understand it as my code works on multi servers chans
and as for the while() loop i did it that way to see if its true if it is it will loop thru
then i used $ifmatch to get the info that the while loop used

deegee:
thanks for that example its working fine i was trying to use $hfind with the r switch
but nothing was working for me u gave me a nice example but can u explane this bit for me
$+(/,%pack,/Si) whats the / and /Si for?


hmm theres sumthing rong it dont work with [ or ] how can i make it work with them?

Last edited by gans; 24/08/07 11:02 AM.
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Originally Posted By: gans
deegee:
thanks for that example its working fine i was trying to use $hfind with the r switch
but nothing was working for me u gave me a nice example but can u explane this bit for me
$+(/,%pack,/Si) whats the / and /Si for?

/../Si
"/" mark the beginning and end of the search pattern
"S" is a switch to strip color/bold/etc before matching
"i" is case insensitive



Originally Posted By: gans
hmm theres sumthing rong it dont work with [ or ] how can i make it work with them?

Code:
alias example {
  var %pack = text to find
  var %re = $+(/\Q,$replacecs(%pack,\E,\E\\E\Q),\E/Si)
  hadd -m example item some 00,02text 11t04O 11f00iND
  if $hfind(example,$+(/,%pack,/Si),1,r).data {
    echo -ag $v1 = $hget(example,$v1) $+([Searched for: ",%pack,"])
  }
  hfree example
}

\Q and \E : Characters in between are treated literally, no special regex meanings apply.
However, the string may contain "\E", so "\E" needs to be replaced with "\E\\E\Q" to restart the escape sequence.


Joined: Jul 2005
Posts: 37
G
gans Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
thanks deegee i finaly got it working the way i want it to work
but where do u find info about \Q\E ect theres nothing in mirc help file about them

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Regular expressions are a broad issue, start out a google search for PCRE (Perl-compatible regular expressions), that's the library mIRC uses.
Here's the wiki entry , the "pcre homepage" is down atm. This page might be a point of reference, too.

In addition, there is a really helpful "introduction to regular expressions" and a "extract from pcre manual" for mIRC in the "mIRC Script Box" available at Merlin's page (online and .chm file) - unfortunately this page is down as well. Maybe one of your friends did download this comprehensive file and can share it with you. smile
I also like this tool.

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Oop just saw that I forgot to change the $hfind call.. shocked

PCRE site is down, as Hortsl said, but luckily there is a Google cache wink Google cache of PCRE Man page


Joined: Jul 2006
Posts: 107
L
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
Merlin's mScriptBox 1.20 is available at mirc.net
mScriptBox v1.20

tg!

a very good reference/learning tool


LonDart
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
ty, I'm frequently pointing at this reference if asked where to start reading besides mIRC.chm by users that seriously want to take up scripting */advertising off* smile


Link Copied to Clipboard