mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 13
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Mar 2004
Posts: 13
hey, i have about 300+ values stored in an ini. i have an alias that adds them all togeather. but it takes like 5 seconds and freezes mirc the whole time. is there a better way to do this? here is the code i wrote:
Code:
  
ttrans {
  echo -a start ttrans $time
  var %found = $findline(%info.ini,trans=*,0), %total.trans = 0
  while (%found > 0) {
    var %trans = $remove($findline(%info.ini,trans=*,%found),trans=,gb)
    var %total.trans = $calc(%total.trans + %trans)
    dec %found
  }
  set %stats.trans $round(%total.trans,2)
  echo -a done ttrans $time
}

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
I don't see how an .ini file can have 300 "trans=" entries, but anyway...
Code:
ttrans {
  var %tt = 0,%t = $ticks
  .fopen tt %info.ini
  while !$feof {
    .fseek -w tt trans=*
    if $fread(tt) { inc %tt $remove($gettok($ifmatch,2,61),gb) }
  }
  .fclose tt
  set %stats.trans $round(%tt,2)
  echo -a done in $calc($ticks - %t) ms: % $+ stats.trans = %stats.trans
}


Joined: Sep 2003
Posts: 20
E
Ameglian cow
Offline
Ameglian cow
E
Joined: Sep 2003
Posts: 20
$readini

Joined: Mar 2004
Posts: 13
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Mar 2004
Posts: 13
lol, no that really wouldn't work because 1, there are 300+ and 2, i wouldn't have to get the section names for all 300+. im trying to make things faster, not slower. but thanks anyway.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
You're not going to find anything in mIRC any faster than Iori's example, although I'd change $remove($gettok($ifmatch,2,61),gb) to $remove($ifmatch,trans=,gb).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Mar 2004
Posts: 13
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Mar 2004
Posts: 13
yea, that example worked great guys. lol went from like 5 seconds for each stat i was calulating to like 40ms lol.


Link Copied to Clipboard