mIRC Home    About    Download    Register    News    Help

Print Thread
drop down list #214527 07/08/09 12:09 AM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
imagine this, 1 dialog with 1 dropdown list (combo)
and i'm doing, if selected is not blank, then set %variable to some value but if blank, delete variable

problem is how does one make line to be blank
but that in same time mirc gets .sel is 0
"" does not do it
$chr(32) appears blank but still is value

any ideas ?


Re: drop down list [Re: vinifera] #214529 07/08/09 01:43 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You can't have a completely blank line in a dialog list box and still have it take up room in the list.

In a combo list, line 0 is the edit box.

Re: drop down list [Re: vinifera] #214535 07/08/09 08:20 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
if ($did(id).seltext = $chr(32)) ??

Re: drop down list [Re: DJ_Sol] #214536 07/08/09 02:03 PM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
nah doesnt trigger :P

edit
----

i sorted it with strict order :P
by using .sel #

Last edited by vinifera; 07/08/09 02:17 PM.
Re: drop down list [Re: vinifera] #214537 07/08/09 02:20 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You could use some other character to indicate a blank line, such as - or . or * and then match that character.

Or, you may be able to match the length of the selected text. Assuming that none of the other lines can have only 1 character, use if($len([text]) == 1) {

-genius_at_work

Re: drop down list [Re: genius_at_work] #214563 08/08/09 11:22 AM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
not to spam another thread related to combo drop down...
i have 1 question related to init selection


example:
Code:
dialog bla {
  title "blaaah"
  size -1 -1 122 122
  option dbu
  combo 1, 32 13 75 11, drop
  combo 2, 32 43 75 11, drop
  button "OK", 3, 81 75 34 12, ok
}

on *:dialog:bla:init:0:{ 
  did -a $dname 1 -
  did -a $dname 1 Snail
  did -a $dname 1 Snail & Slyth
  did -a $dname 2 -
  did -a $dname 2 Snail
  did -a $dname 2 Snail & Slyth
  if (!%A1) { return } | else { did -c $dname 1 %A1 }
  if (!%A2) { return } | else { did -c $dname 2 %A2 }
}

on *:dialog:bla:sclick:*:{
  if ($did = 3) { 
    if ($did(1).sel == 1) { unset %A1 } | else { set %A1 $did(1).seltext } 
    if ($did(2).sel == 1) { unset %A2 } | else { set %A2 $did(2).seltext }
  }
}



so concept would be that if %A1 or %A2 have value (from selected drop down list), that on next init they would be selected already
on combo drop down

but they are not even if values are alright
may i ask what i am not understanding ? :P

Re: drop down list [Re: vinifera] #214570 08/08/09 06:06 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Change the last two lines of your init event to this:
Code:
if (%A1) { did -c $dname 1 $findtok(-.Snail.Snail & Slyth,%A1,1,46) }
if (%A2) { did -c $dname 2 $findtok(-.Snail.Snail & Slyth,%A2,1,46) }

Your basic mistake is that your specified a value (a name) instead of the Nth entry (a number) in the combo box.

As you can see it's also useless (in this case) to check for !%A1 and *then* use an else-statement. And using return is even harmful here:

Say someone selects - for combo 1 and Snail for combo 2.
%A1 will not be set
on init %A1 will result in a /return
result is: the next script line, which checks %A2, will never be executed

Last edited by 5618; 08/08/09 06:32 PM.
Re: drop down list [Re: 5618] #214588 08/08/09 11:57 PM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
is there any other way than using findtok ?
i am using reading from INI file to get "the list"
so cant write it "fixed" since it is made that user
can change the list

Code:
alias -l load-list {
  ; Reads only sections
  ; Syntax: /load-list inifile
  if (!$isfile($1-)) .echo -a File doesn't exist. $+($chr(40),$1-,$chr(41))
  else {
    did -r dialog_name 1-2
    var %i = 1
    while ($ini($1-,%i) != $null) {
      did -a dialog_name 1-2 $v1
      inc %i
    }
  }
}

on *:dialog:dialog_name:init:0:{ 
  load-list $mircdir\list.ini
}



also thanks for clarification for awrong code.
just to ask, for future reference regarding "return"
if i cant use if(!%A1) { return }
nor "halt", what can i use ?

Re: drop down list [Re: vinifera] #214597 09/08/09 06:43 AM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Code:
alias -l load-list {
  ; Reads only sections
  ; Syntax: /load-list inifile
  if (!$isfile($1-)) .echo -a File doesn't exist. $+($chr(40),$1-,$chr(41))
  else {
    did -r dialog_name 1-2
    var %i = 1
    while ($ini($1-,%i) != $null) {
      did -a dialog_name 1-2 $v1
      set %combo.list $+(%combo.list,|,$v1)
      inc %i
    }
    if (%A1) did -c dialog_name 1 $findtok(%combo.list,%A1,1,124)
    if (%A2) did -c dialog_name 1 $findtok(%combo.list,%A2,1,124)
  }
}

on *:dialog:dialog_name:init:0:{ 
  load-list $mircdir\list.ini
}


And you *can* use structures like "if (!%var) return", but you have to make sure your script requires no further processing. Usually you can just not script for the opposite event. E.g.:
Code:
on *:TEXT:indeed:#:{
  if (!%var) {
    set -u10 %var on
    msg $chan Yes, indeed.
  }
}

You could script...
Code:
on *:TEXT:indeed:#:{
  if (%var) return
  else {
    set -u10 %var on
    msg $chan Yes, indeed.
  }
}

...but that's just extra code you don't need.

Re: drop down list [Re: 5618] #214600 09/08/09 12:25 PM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
hmm
the alias code is a bit buggy

on dialog click vars A1 and A2 do get .seltext value as
selected, but on alias load it checks the value -1 of the one
saved/was selected

Re: drop down list [Re: vinifera] #214603 09/08/09 12:59 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
This ought to work (try clearing your variables first, perhaps):
Code:
on *:dialog:dialog_name:init:0:{ 
  load-list $mircdirlist.ini
}
on *:dialog:dialog_name:sclick:3:{
  if ($did(1).sel == 1) { unset %A1 } | else { set %A1 $did(1).seltext } 
  if ($did(2).sel == 1) { unset %A2 } | else { set %A2 $did(2).seltext }
}
alias -l load-list {
  ; Reads only sections
  ; Syntax: /load-list inifile
  if (!$isfile($1-)) echo -a File doesn't exist. $+($chr(40),$1-,$chr(41))
  else {
    did -r dialog_name 1-2
    var %i = 1
    while ($ini($1-,%i)) {
      did -a dialog_name 1-2 $v1
      set %combo.list $+(%combo.list,|,$v1)
      inc %i
    }
    if (%A1) did -c dialog_name 1 $findtok(%combo.list,%A1,1,124)
    if (%A2) did -c dialog_name 2 $findtok(%combo.list,%A2,1,124)
    unset %combo.list
  }
}

Re: drop down list [Re: 5618] #214604 09/08/09 01:08 PM
Joined: Jun 2009
Posts: 91
V
vinifera Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 91
same :P

edit:
------

nevermind, ill try another way, but thanks for trying to help ^^
i do apreciate it

Last edited by vinifera; 09/08/09 05:10 PM.