mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 271
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
hey, am workin on something, and there is an option to delete an item from an ini file, items are set in the ini file like this:

1=this
2=that
3=these
4=those
5=etc

now, i am trying to delete one of those items, then reorder the remaining items so they are still in order of 1,2,3,4 etc...tried a whole bunch of stuff, still dont work, always something wrong, lol this is what i am up to now :S

Code:

 var %a = 1
  while ( $ncenc(keys,%a) ) {
    if ($ifmatch == $2-) break
    inc %a
  }
  var -s %b = 1, %d = $ini(ncenc.isu,keys,0)
  while ( $ini(ncenc.isu,keys,%b) ) {
    var %c = $ifmatch
    if (%c == %a) { 
      ncenc keys %b $ncenc(keys,$calc(%c + 1))
      inc %b
      continue
    }
    ncenc keys %b $ncenc(keys,%c)
    inc %b
  }
  while ( $ini(ncenc.isu,keys,%d) ) {
    ncenc -r keys $ifmatch
    inc %d
  }
  


$ncenc and /ncenc are simple alias to write and read from the ini file "ncenc.isu", ir $1 == -r it will remini $2-

thanks for any help in advance, and that code was smaller, and i tried MANY different ways, but i either end up with two words the same, or skiping a number, 1 2 4 5 6...

Joined: Jan 2003
Posts: 94
S
Babel fish
Offline
Babel fish
S
Joined: Jan 2003
Posts: 94
maybe you could do somthing like (lets say %x is the item u delete)
Code:
var %i = %x + 1
while ($ncenc(keys,%i)) { ncenc keys $calc(%i -1) $ifmatch | inc %i }
ncenc -r keys $calc(%i -1)


Haven't tried it but i think it will work.


-
E-Mail: mirc_sabby@hotmail.com
Network: irc.enterthegame.com
Channel: #Helpdesk
Joined: Dec 2002
Posts: 271
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
cool, thanks, it works, wasnt thinkin that way, as to only rearage items AFTER then one i deleted, lol, ty again smile


Link Copied to Clipboard