mIRC Home    About    Download    Register    News    Help

Print Thread
#203279 10/08/08 07:56 PM
Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

I have two quick questions,

1. How do I go about deleting a value from a listbox

ex.
==========
Tom
Jerry
George
Tim

How would I go about deleting "George"

2. How would I search a listbox for the name: "Tim" where in the listbox it would automactically select the value: "Tim"

Thanks a bunch.

Cheers,


J

Last edited by Buggs2008; 10/08/08 07:57 PM.
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Code:
dialog test {
  title "mIRC"
  size -1 -1 110 100
  option dbu
  list 1, 15 34 80 48
  edit "", 2, 15 22 80 10, autohs
  button  "Rem", 5, 40 82 30 10
}

on *:dialog:test:init:*: {
  ;Add some words
  did -a $dname 1 Tom
  did -a $dname 1 Jerry
  did -a $dname 1 George
  did -a $dname 1 Tim
}
on *:dialog:test:sclick:*: {
  if ($did == 5) && ($did($dname,1).sel) did -d $dname 1 $did($dname,1).sel
}
on *:dialog:test:edit:*: {
  if ($did == 2) {
    if ($_found($dname,1,$did($did))) did -c $dname 1 $ifmatch
  }
}

alias _found {
  var %f = $did($1,$2).lines
  while (%f >= 1) {
    if ($gettok($did($1,$2,%f),1,32) == $3) return %f
    dec %f 
  }
  else return 0
}

Originally Posted By: Buggs2008
How would I go about deleting "George"

select from the list George and click the button Rem
Originally Posted By: Buggs2008
2. How would I search a listbox for the name: "Tim" where in the listbox it would automactically select the value: "Tim"


Type in the editbox: Tim

Read the help file for more details:
/help /did


Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
1) Use /did -d $dname <ID> $did(<ID>).sel
Replace <ID> with the appropriate number.
The -d switch deletes the line, and $did(<ID>).sel returns the line number of the selected item.

2) Use $didwm($dname,<ID>,Tim,1)
This will return the line number in the list box that matches the first occurrence of Tim in the list box that matches the <ID>

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I'm not sure if it's about dialog lists or window listboxes... I'll show both smile

----- Dialog -----
Code:
; call or close example dialog
alias testdialog { dialog $iif($dialog(test),-c,-m) test test }

; dialog definition
dialog test {
  title test
  size -1 -1 200 240
  list 1, 10 10 180 220
}

; put some example items in the list
on *:dialog:test:init:*: { echo -s triggert | didtok $dname 1 32 Tom Jerry George Tim }

1) To delete the line matching text "george" in the list (dialog ID 1):
Code:
did -d test 1 $didwm(test,1,George)
$didwm(test,1,George) returns the matching line number of the list. You may use wildcards and the N parameter for $didwm(), but you don't need to.

2) To select a matching line use the -c swich instead of -d. E.g.:
Code:
did -c test 1 $didwm(test,1,Tim)
If you specified the extsel/multsel style property for your list, you can keep a previous selection if you use -c toghether with the -k switch.

----- List Window -----
Code:
alias testwindow { 
  if ($window(@testwindow)) { window -c $v1 }
  else {
    window -l @testwindow -1 -1 200 300
    aline @testwindow Tom
    aline @testwindow Jerry
    aline @testwindow George
    aline @testwindow Tim
  }
}

1) Delete matching line for text "george" in the listwin:
Code:
dline @testwindow $fline(@testwindow,George).
Again, you may use wildcards or the N parameter but don't have to.

2) Select matching line:
Code:
sline @testwindow $fline(@testwindow,Tim)
You can keep a previous selection by adding the -a switch.

______
I'm not sure if it's about dialog lists or window listboxes... I'll show both smile

----- Dialog -----
Code:
; call or close example dialog
alias testdialog { dialog $iif($dialog(test),-c,-m) test test }

; dialog definition
dialog test {
  title test
  size -1 -1 200 240
  list 1, 10 10 180 220
}

; put some example items in the list
on *:dialog:test:init:*: { echo -s triggert | didtok $dname 1 32 Tom Jerry George Tim }

1) To delete the line matching text "george" in the list (dialog ID 1):
Code:
did -d test 1 $didwm(test,1,George)
$didwm(test,1,George) returns the matching line number of the list. You may use wildcards and the N parameter for $didwm(), but you don't need to.

2) To select a matching line use the -c swich instead of -d. E.g.:
Code:
did -c test 1 $didwm(test,1,Tim)
If you specified the extsel/multsel style property for your list, you can keep a previous selection if you use -c toghether with the -k switch.

----- List Window -----
Code:
alias testwindow { 
  if ($window(@testwindow)) { window -c $v1 }
  else {
    window -l @testwindow -1 -1 200 300
    aline @testwindow Tom
    aline @testwindow Jerry
    aline @testwindow George
    aline @testwindow Tim
  }
}

1) Delete matching line for text "george" in the listwin:
Code:
dline @testwindow $fline(@testwindow,George).
Again, you may use wildcards or the N parameter but don't have to.

2) Select matching line:
Code:
sline @testwindow $fline(@testwindow,Tim)
You can keep a previous selection by adding the -a switch.

______
Edit: OK.. I'm last and rereading the subject makes clear it's about dialogs. But there's no need to perform a custom loop if you use didwm (RusselB already pointed at it regarding your second question)

Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Thanks so much for all the replies.

That helped so much.

Cheers,

J


Link Copied to Clipboard