mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2003
Posts: 24
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Jul 2003
Posts: 24
add a -w parm to enable wildcards
for example /remini -w myfile.ini mysection location.*
will remove all keys that match location.*

Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Until Khaled integrate that feature you can use a script wink

Code:
Alias remini {
  if ($1 == -w) {
    var %filename = $2

    set -u0 %RemIni.Matches 0
    var %start = $read(%filename,s, $+([,$3,]) )
    var %start = $readn
   [color:blue] ;If %start is 0 that mean we don't find the section what we need[/color] 
    if (%start == 0) return
    [color:blue];Start search from the next line[/color] 
    var %i = $calc(%start + 1)
    var %lines = $lines(%filename)

    while (%i <= %lines) {
      var %CurLine = $read(%filename,%i)
      var %CurKey = $gettok(%CurLine,1,61)
      [color:blue];If is null that mean the curent line is somthink like [blabla].. Other section[/color] 
      if (%CurKey == $null) return
      if ($4 iswm %CurKey) {
        write -dl $+ %i %filename
        inc -u0 %RemIni.Matches
        [color:blue];DOn't do inc %i because we just deleted a line.. [/color] 
        [color:blue];And the next line is now curent line[/color] 
        goto Continue
      }
      inc %i
      :Continue
      ;End of while
    }
    ;End of If
  } 
  else {
    !remini $1-
  }
  ;End of alias
}




mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Apr 2003
Posts: 210
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Apr 2003
Posts: 210
That looks nasty. I wonder if there would be a more efficient way using /hload -i and the hash table wildcard searching, Or even using a @window ?


Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Indeed there is:
Code:
alias remini {
  if -*w* !iswm $1 { remini $1- | return }
  if !$regex($2-,/^("[^"]+"|\S+) (\S+) (\S+)/) { return }
  [color:green]; done with error checking[/color]
  tokenize 32 $regml(2) $regml(3) $regml(1)
  if $ini($3-,$1,0) {
    window -h @@
    loadbuf -t $+ $1 @@ $3-
    filter -wwcx @@ @@ $2=*?
    if $ifmatch != $filtered {
      remini $3- $1
      iline @@ 1 [ $+ $1]
      filter -wf @@ $3-
    }
    close -@ @@
  }
}


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Amazing ! Your code work's several hundred times faster than my script smile
(tested for ~300 lines)
Executed in: 3.688 seconds
Executed in: 0.032 seconds


How i sayd the standart function is always more faster than same think but scripted..
Also i found a bug i think.. If you chose a file with ~3000 lines.. mIRC just crash wink That cause remini -n i think..

MIRC caused a general protection fault
in module KRNL386.EXE at 0002:000064aa.
Registers:
EAX=53e7ffe0 CS=016f EIP=000064aa EFLGS=00000613
EBX=00001609 SS=6187 ESP=0000b1ee EBP=0000b1f6
ECX=0000ffdd DS=0197 ESI=0000ffdc FS=0000
EDX=0000019f ES=0197 EDI=0000ffff GS=0000
Bytes at CS:EIP:
f3 a4 fc 1f 8b 5e 04 8b 46 06 01 07 5e 5f c9 c2
Stack dump:
ffdd017f ffe00000 6517b20a 00231609 01970000 0000000e ffddffdd 6302b228 000015ff 00000197 0000018f 01970000 0000000e 018f0003 b3ce0197 0000537e


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I made an .ini with more than 4000 lines and it worked here (WinXP), but if there are problems on other systems, -n would perhaps be a good idea. -n isn't documented but I remember that it works. Thanks for the tip.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Dont forget that custom windows are never a good place to store large lists, as some users select Window Buffers as low as 500 lines.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The window buffer limit doesn't apply to text added to windows by /*line, /filter or /loadbuf. Only /echo obeys that limit.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2003
Posts: 210
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Apr 2003
Posts: 210
Not bad, Shame we can't /filter to and from hash tables (can we?), I think that would increase the speed even more..

There must atleast be a little overhead with the creation of a window and the drawing to it.

Joined: Apr 2003
Posts: 414
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
With this file.. The mIRC crash when you try to remove a big section(with ex. 3000 items)..
/!remini Hehe.ini chanfolder - allways crash..
Tested on Win98SE.


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
There is definitely some overhead, but if the window is hidden, this overhead is so small that can be ignored (even on slow computers). That's because there is no drawing taking place in a hidden window, everything is done in memory. For example this:
//window -h @@ | var %i = 10000, %t = $ticks | while %i { aline @@ %i | dec %i } | echo -s $calc($ticks - %t) | close -@ @@
took 390 msecs while this:
//window -a @@ | var %i = 10000, %t = $ticks | while %i { aline @@ %i | dec %i } | echo -s $calc($ticks - %t) | close -@ @@
took 5391 msecs


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Nov 2003
Posts: 33
Ameglian cow
Offline
Ameglian cow
Joined: Nov 2003
Posts: 33
aight, i tried those 2 examples (Win98)
this is my results :
first : 820 805 810 (yes, i did do this one 3 times...)
second : 22475 (took so long, only did it once)

that is msecs...

shocked


--------------------
I may be insane, but I enjoy it!

Link Copied to Clipboard