mIRC Home    About    Download    Register    News    Help

Print Thread
#155653 08/08/06 06:03 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
 dialog Channel_Control {
  title "Channel_Control"
  size -1 -1 1215 550
  option pixels
  text "Network", 1, 10 30 200 15, tab 6 center
  list 2, 10 45 200 465, tab 6 size
  text "Server list", 113, 210 30 200 15, tab 6 center
  list 116, 210 45 200 465, tab 6 size
on *:dialog:Channel_Control:init:*:{
  var %connected = 0
  var %a = 1, %connected = 0
  while %a <= $scon(0) {
    .scon %a 
    did -a $dname 2 $network $scon(%a).status
    $iif($scon(%a).status == connected,inc %connected)
    inc %a
  }
  .scon -r
  did -kc $dname 2 $cid
  if $scon(%cid).status == connected {
    .enable #RKB.CC.Links
    did -r $dname 116
    .links
  }
  set %cid $cid
 [color:red]   var %a = 1, %b = $did(116).lines
  while %a <= %b {
    if $did(116,%a) == $server {
      did -kc $dname 116 %a
      %a = %b
    }
    inc %a
  }
 [/color] 
}
#RKB.CC.Links off
raw 364:*:{
  did -a Channel_Control 116 $2
}
raw 365:*:{
  .disable #RKB.CC.Links
  haltdef
}
#RKB.CC.Links end

 

I don't know if I've included enough of the code for this to make sense, but the section in red isn't working.
For some reason, that I can't figure out, the number of lines for dialog id 116 always comes back as 0, even though that's an impossible number, since it's a list of linked servers, one of which I have to be connected to in order to get the list.

I've only posted what I think are the relevant parts of the code, but if there's something missing and you can give me an idea as to what would be in the missing part, I'll post it. Posting the whole thing would be too much for this little bit (I think) and the entire code is currently at nearly 1000 lines.

#155654 08/08/06 06:12 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Is it safe to assume links in the if $scon(%cid).status == connected { ... } portion is supposed to populate the 116 dialog? If so, i would go with the basis that it hasn't been populated yet. Even though you've called it, and it's supposed to evaluate, i don't think the raws have entered anything in yet by the time it hits the loop. Try this:

at the bottom of the init dialog code, add: /echo -s Dialog Init: $ticks
then in the raw (364) add: /echo -s Add: $ticks

Granted, that latter will echo more, but I'm betting the init ticks value is before the add's, which would explain a 0 line count when it hits the loop, but the list being populated (what appears to be) instantly.


-KingTomato
#155655 08/08/06 07:26 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Good call, and it's confirmed, now, how can I get around or resolve this timing problem?
I added a few extra timers and also included a description for each so that I could tell easily what each one was for.
My results (in case they matter) are
Quote:
Before links 103805304
End of initialization 103805304
Links 103806195
Links 103806195
Links 103806210
After links 103806210


I think you should be able to determine where I put the actual echo commands based on the description with each.

#155656 08/08/06 03:36 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
I think your best bet is to put the while loop in your raw 365, (after the list has been populated), or a condition in raw 364 (s it's populating). This would almost guarantee the list has the information in it. You could also save a step, and use this in 364:

/did $iif($2 == $server, -ack, -a) Dialog_control 116 $2

And as I look at the loop, a /break would be better then %a = %b, as your condition for the loop is "<=". So, you're still going to iterate once more through it, even though you've found your match.


-KingTomato
#155657 08/08/06 11:52 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thank you, putting that line you suggested in 364 does the job perfectly.

#155658 09/08/06 10:38 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Quote:
And as I look at the loop, a /break would be better then %a = %b, as your condition for the loop is "<=". So, you're still going to iterate once more through it, even though you've found your match.


/break would work fine.

Though, about your comment on %a = %b, it wouldn't actually iterate once more through it. If you set %a to the total amount of lines which is %b, and then increase %a by one (which inc %a does right after that if statement), then the while loop won't trigger again, because %a would be 1 over the total amount of lines.

Example:

Code:
alias repexample {
  var %a = 1 , %b = 5 , %z = 10
  while (%a &lt;= %z) {
    echo -ag This has triggered %a $iif(%a == 1,time,times)
    if (%a == %b) { var %a = %z }
    inc %a
  }
}


Last echo would be "This has triggered 5 times"

#155659 09/08/06 07:44 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Another case of coding whewn I'm not awake. Thanks for the overview, I just happened to miss it. wink


-KingTomato

Link Copied to Clipboard