mIRC Home    About    Download    Register    News    Help

Print Thread
Houston, We Have a Problem #170269 06/02/07 05:49 AM
Joined: Dec 2006
Posts: 3
I
iMuller Offline OP
Self-satisified door
OP Offline
Self-satisified door
I
Joined: Dec 2006
Posts: 3
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 -.-)

Re: Houston, We Have a Problem [Re: iMuller] #170319 07/02/07 02:25 AM
Joined: Dec 2002
Posts: 43
P
psycogod Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Dec 2002
Posts: 43
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)

Re: Houston, We Have a Problem [Re: psycogod] #170330 07/02/07 10:41 AM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
$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.