mIRC Homepage
Posted By: cdwriter /remini [-w] <inifile> <section> <key> - 08/12/03 10:54 AM
add a -w parm to enable wildcards
for example /remini -w myfile.ini mysection location.*
will remove all keys that match location.*
Posted By: Adrenalin Re: /remini [-w] <inifile> <section> <key> - 08/12/03 02:21 PM
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 &lt;= %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
}


Posted By: saxon Re: /remini [-w] <inifile> <section> <key> - 08/12/03 04:30 PM
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 ?

Posted By: qwerty Re: /remini [-w] <inifile> <section> <key> - 08/12/03 05:43 PM
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 -@ @@
  }
}
Posted By: Adrenalin Re: /remini [-w] <inifile> <section> <key> - 08/12/03 07:51 PM
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
Posted By: qwerty Re: /remini [-w] <inifile> <section> <key> - 08/12/03 08:59 PM
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.
Posted By: Raccoon Re: /remini [-w] <inifile> <section> <key> - 09/12/03 08:09 AM
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.
Posted By: qwerty Re: /remini [-w] <inifile> <section> <key> - 09/12/03 11:26 AM
The window buffer limit doesn't apply to text added to windows by /*line, /filter or /loadbuf. Only /echo obeys that limit.
Posted By: saxon Re: /remini [-w] <inifile> <section> <key> - 09/12/03 01:40 PM
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.
Posted By: Adrenalin Re: /remini [-w] <inifile> <section> <key> - 09/12/03 02:17 PM
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.
Posted By: qwerty Re: /remini [-w] <inifile> <section> <key> - 09/12/03 02:23 PM
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
Posted By: AdmWiggin Re: /remini [-w] <inifile> <section> <key> - 11/12/03 03:05 AM
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
© mIRC Discussion Forums