mIRC Home    About    Download    Register    News    Help

Print Thread
#15049 12/03/03 05:06 PM
Joined: Feb 2003
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Feb 2003
Posts: 4
What this script is supposed to do is to smooth out the "bumps" in a numbered section of an ini file. For example:
1=asdf
2=asd
5=as
8=a

Should turn out to:
1=asdf
2=asd
3=as
4=a

Instead, it turns out like:
1=asdf
2=asd
8=a
4=as

Any idea why?

alias smoothini {
set %tmp.la2 1
while (%tmp.la2 <= $ini(ini.ini,$1,0)) {
if ($ini(ini.ini,$1,%tmp.la2) != %tmp.la2) {
writeini ini.ini $1 %tmp.la2 $readini(ini.ini,$1,$ini(ini.ini,$1,%tmp.la2))
remini ini.ini $1 $ini(ini.ini,$1,%tmp.la2)
}
inc %tmp.la2
}
}

Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
alias smoothini {
  var %i = 1
  while $ini(ini.ini,$1,%i) {
    if $ini(ini.ini,$1,%i) != %i {
      [color:green]; Find the line number by $read()/$readn, first to find the section, then the item
      ; this also serves to grab the info :)[/color]
      var %a = $read(ini.ini,w,$+([,$1,])),%b = $read(ini.ini,nw,$ifmatch $+ =*,$readn)
      [color:green]; Insert the new line into the original position[/color]
      write -il $+ $readn ini.ini $+(%i,=,$gettok(%b,2,61))
      remini ini.ini $1 $ifmatch
    }
    inc %i
  }
} 


Link Copied to Clipboard