I'm not sure if it's about dialog lists or window listboxes... I'll show both
----- Dialog -----
; 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):
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.:
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 -----
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:
dline @testwindow $fline(@testwindow,George).
Again, you may use wildcards or the N parameter but don't have to.
2) Select matching line:
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
----- Dialog -----
; 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):
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.:
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 -----
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:
dline @testwindow $fline(@testwindow,George).
Again, you may use wildcards or the N parameter but don't have to.
2) Select matching line:
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)