|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
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 ?
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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.
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
if ($did(id).seltext = $chr(32)) ??
|
|
|
|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
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.
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
not to spam another thread related to combo drop down... i have 1 question related to init selection example:
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
|
|
|
|
Joined: Jun 2007
Posts: 933
Hoopy frood
|
Hoopy frood
Joined: Jun 2007
Posts: 933 |
Change the last two lines of your init event to this: 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.
|
|
|
|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
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
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 ?
|
|
|
|
Joined: Jun 2007
Posts: 933
Hoopy frood
|
Hoopy frood
Joined: Jun 2007
Posts: 933 |
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.: on *:TEXT:indeed:#:{
if (!%var) {
set -u10 %var on
msg $chan Yes, indeed.
}
} You could script... 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.
|
|
|
|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
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
|
|
|
|
Joined: Jun 2007
Posts: 933
Hoopy frood
|
Hoopy frood
Joined: Jun 2007
Posts: 933 |
This ought to work (try clearing your variables first, perhaps): 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
}
}
|
|
|
|
Joined: Jun 2009
Posts: 96
Babel fish
|
OP
Babel fish
Joined: Jun 2009
Posts: 96 |
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.
|
|
|
|
|