mIRC Home    About    Download    Register    News    Help

Topic Options
#214527 - 07/08/09 01:09 AM drop down list
vinifera Offline
Babel fish

Registered: 21/06/09
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 ?


Top
#214529 - 07/08/09 02:43 AM Re: drop down list [Re: vinifera]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#214535 - 07/08/09 09:20 AM Re: drop down list [Re: vinifera]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
if ($did(id).seltext = $chr(32)) ??

Top
#214536 - 07/08/09 03:03 PM Re: drop down list [Re: DJ_Sol]
vinifera Offline
Babel fish

Registered: 21/06/09
Posts: 91
nah doesnt trigger :P

edit
----

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


Edited by vinifera (07/08/09 03:17 PM)

Top
#214537 - 07/08/09 03:20 PM Re: drop down list [Re: vinifera]
genius_at_work Offline
Hoopy frood

Registered: 08/10/05
Posts: 1741
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

Top
#214563 - 08/08/09 12:22 PM Re: drop down list [Re: genius_at_work]
vinifera Offline
Babel fish

Registered: 21/06/09
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

Top
#214570 - 08/08/09 07:06 PM Re: drop down list [Re: vinifera]
5618 Offline
Hoopy frood

Registered: 18/06/07
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


Edited by 5618 (08/08/09 07:32 PM)

Top
#214588 - 09/08/09 12:57 AM Re: drop down list [Re: 5618]
vinifera Offline
Babel fish

Registered: 21/06/09
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 ?

Top
#214597 - 09/08/09 07:43 AM Re: drop down list [Re: vinifera]
5618 Offline
Hoopy frood

Registered: 18/06/07
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.

Top
#214600 - 09/08/09 01:25 PM Re: drop down list [Re: 5618]
vinifera Offline
Babel fish

Registered: 21/06/09
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

Top
#214603 - 09/08/09 01:59 PM Re: drop down list [Re: vinifera]
5618 Offline
Hoopy frood

Registered: 18/06/07
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
  }
}

Top
#214604 - 09/08/09 02:08 PM Re: drop down list [Re: 5618]
vinifera Offline
Babel fish

Registered: 21/06/09
Posts: 91
same :P

edit:
------

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


Edited by vinifera (09/08/09 06:10 PM)

Top