mIRC Homepage
Posted By: skovicniq Help on dialog - 18/12/07 08:37 AM
Code:
 
list 1, 5 5 70 60
  edit "", 2, 5 62 70 10, autohs
  button "rem", 5, 26 85 20 10

elseif ($did == 5) { did -d $dname 1 $did($dname,2).sel }


I tried to remove selected word on listbox 1. But didnt working. I got this

/did: invalid parameters (line 35, script3.ini)

Thanks
Posted By: Riamus2 Re: Help on dialog - 18/12/07 11:11 AM
.sel refers to a line number, not the text selected. For that, use .seltext
Posted By: Crinul Re: Help on dialog - 18/12/07 11:15 AM
Quote:
I tried to remove selected word on listbox 1


Code:
elseif ($did == 5) { did -d $dname 1 $did($dname,2).sel }


Should be:

Code:
elseif ($did == 5) { did -d $dname 1 $did($dname,1).sel }


Edit: This topic, to me, was very unclear... My bad, Riamus2 got the problem that you're having with the code.
Posted By: Lpfix5 Re: Help on dialog - 18/12/07 06:39 PM
Indeed, the only way to remove the selected word would be manually.. if you take the effort to highlight a word in one of your editboxs whats to press the backspace key or delete key on it?

Posted By: Riamus2 Re: Help on dialog - 18/12/07 09:09 PM
Code:
whats to press the backspace key or delete key on it?


That's not really difficult... just remove the pieces by editing the line in the edit box using the script. Depending on how you want to do it and what's the best method, you can use $remove, $remtok, $deltok, or getting more specific $pos and $left, $right, $mid... probably others as well.

However, I don't think the original request was about removing text in the edit box, but in the listbox, which is an entirely different matter ... and much easier to accomplish. The original request for help was a little ambiguous though and could be asking for a few different things, so more specifics would allow us to give a complete response... for example, is he trying to remove from the listbox whatever is highlighted in the editbox, or vice versa, or remove what was selected in the listbox from the listbox, or what? It's not really that clear.
Posted By: Lpfix5 Re: Help on dialog - 18/12/07 09:21 PM
Originally Posted By: skovicniq
Code:
 
list 1, 5 5 70 60
  edit "", 2, 5 62 70 10, autohs
  button "rem", 5, 26 85 20 10

elseif ($did == 5) { did -d $dname 1 $did($dname,2).sel }


I tried to remove selected word on listbox 1. But didnt working. I got this

/did: invalid parameters (line 35, script3.ini)

Thanks


Um when removing a line from a listbox you might want to use the SAME ID witrhin the did command example listbox

elseif ($did == 5) { did -d $dname 1 $did($dname,1).sel }

would remove the word in listbox one if listbox 1 had a word selectled

notice how you use $did($dname,2).sel

in a editbox you can clear the line by using did -r $dname ID this will clompletely erase a line in a editbox
Posted By: Riamus2 Re: Help on dialog - 19/12/07 01:38 AM
Yeah, that was mentioned before as well. However, I'm not sure that that's what is being requested. It sounds like the line being removed from the listbox is one matching text that is selected in the editbox. Of course, like I said, the explanation of what's wanted is so obscure as to mean multiple things and trying to guess is a waste of time and effort... especially when the OP hasn't come back to explain.
Posted By: skovicniq Re: Help on dialog - 19/12/07 01:16 PM
I just want to remove selected text in list box (1) by pressing remove button. Sorry for poor explaination.
Posted By: Bekar Re: Help on dialog - 19/12/07 02:04 PM
So, the entire content of the 'edit' (2) will have a string in it, and you want to find the matching string in the 'list' (1), and remove that line?

What do you want to happen if the string in the edit doesn't exist in the list?
Posted By: Crinul Re: Help on dialog - 19/12/07 05:18 PM
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 Some
  did -a $dname 1 Other
  did -a $dname 1 Help
  did -a $dname 1 Word
}
on *:dialog:test:sclick:*: {
  ;case 1 - Button: remove a selected word in the listbox - select word AND press Rem
  if ($did == 5) {
    did -d $dname 1 $did($dname,1).sel
  }
}
on *:dialog:test:edit:*: {
  ;case 2 - Edit : type some word in the edit, some word that exists in the ListBox
  if ($did == 2) {
    if $_found($dname,1,$did($did)) {
      did -c $dname 1 $ifmatch
      did -d $dname 1 $did($dname,1).sel
      did -r $dname 2
    }
  }
}

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
}


Case 1 - Button , Case 2 - Edit
One last effort :P
Posted By: Lpfix5 Re: Help on dialog - 20/12/07 03:19 PM
Originally Posted By: skovicniq
I just want to remove selected text in list box (1) by pressing remove button. Sorry for poor explaination.


elseif ($did == 5) {
if ($did($dname,1).seltext) {
did -d $dname 1 $did($dname,1).sel
}
if ($did($dname,2).seltext) {
did -d $dname 2 $did($dname,2).sel
}
}

Checks to see weather if listbox 1 has selected text or 2 or both

voila so anytime you select anything from weather whatever box it will delete contents
© mIRC Discussion Forums