mIRC Homepage
Posted By: The_Only Again combo box... - 04/04/05 01:27 PM
So... here's the problem.
I made a combo box type "list". But when I add a new item through the button i designed, it appears at the top. Is there a way to make the list-box fill in the same order as the data is stored as different lines in the *.ini file? I mean... the new item to be added is stored as a new line at the bottom of the *.ini. So can the item appear at the bottom in the box too?
Posted By: SladeKraven Re: Again combo box... - 04/04/05 02:05 PM
Just something I whipped up, it doesn't read from an INI file though. Simple *.txt.

But it does load the data the order you added it.

Code:
dialog com {
  title "Com"
  size -1 -1 64 116
  option dbu
  combo 1, 2 2 60 90, size
  button "Add", 2, 11 94 15 8
  button "Del", 3, 38 94 15 8
  button "Close", 4, 4 106 55 8
}


On *:Dialog:com:init:0: {
  if ($lines(com.txt) >= 1) { .play -s com.txt 10 }
}

On *:Dialog:com:sclick:2: {
  if ($did(1)) {
    if ($read(com.txt,w,did -a com 1 $did($dname,1))) { echo -a $did(1) already exists. | halt }
    did -a $dname 1 $did(1)
    write com.txt did -a com 1 $did($dname,1)
    echo -a Added $+($did($dname,1),.)
  }
}

On *:Dialog:com:sclick:3: {
  if ($did(1).sel) {
    did -d $dname 1 $did(1).sel
    write -dw $+("*,$did(1).sel,*") com.txt
    echo -a Deleted $+($did($dname,1),.)
  }
}

On *:Dialog:com:sclick:4: {
  dialog -x com com
}
Posted By: The_Only Re: Again combo box... - 04/04/05 02:18 PM
Thanks.

Oh yeah! Another question. Since the data in my "database" *.txt file is a list of IPs (each on new line) to be ignored, is there a way to make mirc always add them to the ignore list in the Address Book on start?
Posted By: SladeKraven Re: Again combo box... - 04/04/05 02:22 PM
Code:
On *:Start: {
  var %x = $lines(database.txt)
  while (%x) {
    ignore $gettok($read(database.txt,%x),5,32)
    dec %x
  }
}

dialog database {
  title "The Only"
  size -1 -1 64 116
  option dbu
  combo 1, 2 2 60 90, size
  button "Add", 2, 11 94 15 8
  button "Del", 3, 38 94 15 8
  button "Close", 4, 4 106 55 8
}


On *:Dialog:database:init:0: {
  if ($lines(database.txt) >= 1) { .play -s database.txt 10 }
}

On *:Dialog:database:sclick:2: {
  if ($did(1)) {
    if ($read(database.txt,w,did -a database 1 $did($dname,1))) { echo -a $did(1) already exists. | halt }
    did -a $dname 1 $did(1)
    write database.txt did -a database 1 $did($dname,1)
    echo -a Added $+($did($dname,1),.)
  }
}

On *:Dialog:database:sclick:3: {
  if ($did(1).sel) {
    did -d $dname 1 $did(1).sel
    write -dw $+("*,$did(1).sel,*") database.txt
    echo -a Deleted $+($did($dname,1),.)
  }
}

On *:Dialog:database:sclick:4: {
  dialog -x database database
}
Posted By: The_Only Re: Again combo box... - 04/04/05 02:23 PM
by the way... sorry it wasn't a combo box frown
Code:
list 4, 7 50 134 154, size extsel vsbar

A list box...
Sorry
Posted By: SladeKraven Re: Again combo box... - 04/04/05 02:36 PM
Ok, well I've added an edit control and a list to make it look like a combo hehehe...
Code:
On *:Start: {
  var %x = $lines(database.txt)
  while (%x) {
    ignore $gettok($read(database.txt,%x),5,32)
    dec %x
  }
}

dialog database {
  title "database"
  size -1 -1 66 116
  option dbu
  list 1, 3 14 60 80, size
  button "Add", 2, 11 96 15 8
  button "Del", 3, 38 96 15 8
  button "Close", 4, 4 106 55 8
  edit "", 5, 3 2 60 10
}

On *:Dialog:database:init:0: {
  if ($lines(database.txt) >= 1) { .play -s database.txt 10 }
}

On *:Dialog:database:sclick:2: {
  if ($did(5)) {
    if ($read(database.txt,w,did -a database 1 $did($dname,5))) { echo -a $did(5) already exists. | halt }
    did -a $dname 1 $did(5)
    write database.txt did -a database 1 $did($dname,5)
    echo -a Added $+($did($dname,5),.)
  }
}

On *:Dialog:database:sclick:3: {
  if ($did(1).sel) {
    did -d $dname 1 $did(1).sel
    write -dw $+("*,$did(1).sel,*") database.txt
    echo -a Deleted $+($did($dname,1),.)
  }
}

On *:Dialog:database:sclick:4: {
  dialog -x database database
}
Posted By: The_Only Re: Again combo box... - 04/04/05 03:23 PM
Thanks pal smile It works great!

And sorry that I said "combo" box... They look almost the same and I got confused :P

Offtopic: Can anyone see my avatar? Because it's uploaded on a Bulgarian free server and I'm not sure if the server could be accessed from foreign countries.
Posted By: SladeKraven Re: Again combo box... - 04/04/05 03:26 PM
You're welcome mate. smile
Posted By: The_Only Re: Again combo box... - 04/04/05 03:42 PM
Doh I found a bug.

When you open the dialog "database" ( /dialog -m database database ) and for example you fill in 4 texts. They appear and when you load the dialog again they appear at the same order. But when you select for example the last one or the 3rd one or whatever and press "del" it deletes it but when you reopen the diaolg you can see that it actually deleted the first line, not the one you selected,
Posted By: SladeKraven Re: Again combo box... - 04/04/05 03:54 PM
Woops, my apologies!

Well this seems to work, thus far.

Code:
On *:Start: {
  var %x = $lines(database.txt)
  while (%x) {
    ignore $gettok($read(database.txt,%x),5,32)
    dec %x
  }
}

dialog database {
  title "database"
  size -1 -1 66 116
  option dbu
  list 1, 3 14 60 80, size
  button "Add", 2, 11 96 15 8
  button "Del", 3, 38 96 15 8
  button "Close", 4, 4 106 55 8
  edit "", 5, 3 2 60 10
}

On *:Dialog:database:init:0: {
  if ($lines(database.txt) >= 1) { .play -s database.txt 10 }
}

On *:Dialog:database:sclick:2: {
  if ($did(5)) {
    if ($read(database.txt,w,did -a database 1 $did($dname,5))) { echo -a $did(5) already exists. | halt }
    did -a $dname 1 $did(5)
    write database.txt did -a database 1 $did($dname,5)
    echo -a Added $+($did($dname,5),.)
  }
}

On *:Dialog:database:sclick:3: {
  if ($did(1).sel) {
    write -dw $+("*,$did(1,$did(1).sel),*") database.txt
    did -d $dname 1 $did(1).sel
  }
}

On *:Dialog:database:sclick:4: {
  dialog -x database database
}
Posted By: The_Only Re: Again combo box... - 04/04/05 04:06 PM
Thanks smile
Posted By: SladeKraven Re: Again combo box... - 04/04/05 04:07 PM
You're welcome. smile
Posted By: The_Only Re: Again combo box... - 04/04/05 04:12 PM
Oh and by the way... is there a way not to add the network i'm logged on to when ignoring? Cause when I type "/ignore -pcntdik *!*@whatever.com" it also adds the network I'm logged on to in the Address Book.
Posted By: SladeKraven Re: Again combo box... - 04/04/05 04:18 PM
Sorry mate I'm a little tired, so I'm having trouble understanding hehe. Do you want the ignore to function on all networks?
Posted By: The_Only Re: Again combo box... - 04/04/05 04:29 PM
Am... so when you log on to a server to chat, and when you tipe "/ignore -pcntdik *!*@blablabla.bla" it ignores that Host/IP right? And when you go to the Address Book -> Control -> Ignore you can see "*!*@blablabla.bla" added with parameters "pcntdik" (private, ctcp etc.) but you can also see the network group/server address you were logged on to or to when ignoring. That makes the ignore valid only on this server/group. So I want to ignore someone with the /ignore command without adding the network/server address. Is it possible?

Sorry for explaining it like that but it will make it easier for you to understand me smile
Posted By: SladeKraven Re: Again combo box... - 04/04/05 04:33 PM
/ignore -w <Host/IP>
Posted By: The_Only Re: Again combo box... - 04/04/05 04:37 PM
LOL! Looks like I have to re-read the mirc help file about ignore again :P It seems i've missed it the last time I read it smile

Thanks again for everything smile
Posted By: SladeKraven Re: Again combo box... - 04/04/05 04:39 PM
Hehe, you're welcome smile
© mIRC Discussion Forums