mIRC Home    About    Download    Register    News    Help

Print Thread
/remini [-w] <inifile> <section> <key> #63321 08/12/03 10:54 AM
Joined: Jul 2003
Posts: 24
C
cdwriter Offline OP
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.*

Re: /remini [-w] <inifile> <section> <key> #63322 08/12/03 02:21 PM
Joined: Apr 2003
Posts: 414
Adrenalin Offline
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 &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
}




mIRC Chm Help 6.16.0.3 Full Anchored!
Re: /remini [-w] <inifile> <section> <key> #63323 08/12/03 04:30 PM
Joined: Apr 2003
Posts: 210
S
saxon Offline
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 ?


Re: /remini [-w] <inifile> <section> <key> #63324 08/12/03 05:43 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: /remini [-w] <inifile> <section> <key> #63325 08/12/03 07:51 PM
Joined: Apr 2003
Posts: 414
Adrenalin Offline
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!
Re: /remini [-w] <inifile> <section> <key> #63326 08/12/03 08:59 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: /remini [-w] <inifile> <section> <key> #63327 09/12/03 08:09 AM
Joined: Feb 2003
Posts: 2,711
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,711
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!
Re: /remini [-w] <inifile> <section> <key> #63328 09/12/03 11:26 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: /remini [-w] <inifile> <section> <key> #63329 09/12/03 01:40 PM
Joined: Apr 2003
Posts: 210
S
saxon Offline
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.

Re: /remini [-w] <inifile> <section> <key> #63330 09/12/03 02:17 PM
Joined: Apr 2003
Posts: 414
Adrenalin Offline
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!
Re: /remini [-w] <inifile> <section> <key> #63331 09/12/03 02:23 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: /remini [-w] <inifile> <section> <key> #63332 11/12/03 03:05 AM
Joined: Nov 2003
Posts: 33
AdmWiggin Offline
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!