mIRC Homepage

Houston, We Have a Problem

Posted By: iMuller

Houston, We Have a Problem - 06/02/07 05:49 AM

I was happily scripting when a friend ask for a "little help". No problem, I said. But, actually, I've a little one.

Look this script:
Code:
alias list {
  var % 1
  while ($readini(%file,$ini(%file,%),chan)) { 
    var % 1
    while ($gettok($v1,%,44)) { echo -a $v1 | inc % }
  inc % }
}


... and it's ini's file:
Code:
[FirstNetwork]
chan=#chanone,#chantwo,#chantree
[SecondNetwork]
chan=#chan1,#chan2,#chan3,#chan4


It should list all chans of all networks. But it's echo only the first chan of each network ):. Does anybody know why?

(if u can't understand me 'cuz damn pro english just find nemo, i mean, the error -.-)
Posted By: psycogod

Re: Houston, We Have a Problem - 07/02/07 02:25 AM

I think your use of $v1 is confusing mIRC. Try this:
Code:
list {
  var %B 1
  var %chans = $readini(%file,$ini(%file,%B),chan)
  while (%chans) { 
    var %L 1
    while ($gettok(%chans,%L,44)) {
      echo -a $v1
      inc %L
    }
    inc %B
    var %chans = $readini(%file,$ini(%file,%B),chan)
  }
}

(Browser didn't handle utf8 right, had to change var names)
Posted By: hixxy

Re: Houston, We Have a Problem - 07/02/07 10:41 AM

$v1 works fine that way, but you're correct in thinking that his logic is incorrect. After the first loop, $v1 will be $gettok($v1,%,44) from the first loop.

--

OP, try this:

Code:
alias list {
  var % = 1, %, %v1
  while ($readini(%file,$ini(%file,%),chan)) { 
    % = 1
    %v1 = $v1
    while ($gettok(%v1,%,44)) { 
      echo -a $v1 
      inc % 
    }
    inc % 
  }
}


Btw, out of curiosity, why do you use such undescriptive variable names? It's only going to cause you some confusion if you go and look at a script after some time of not modifying it.
© 2022 mIRC Discussion Forums