mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
#148756 10/05/06 07:11 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
to not post whole dialog + code i jump on important...

everything that i have in init event ~20 lines of code/events work exept this one (any only one that wont work)

if ( $lines($mircdirsystem\spam_channels.txt) = 0 ) { .did -m protect 49 }

and it doesnt matter if i put it on begining of init or whereever...

but when i try it debug like this:

//if ( $lines($mircdirsystem\spam_channels.txt) = 0 ) //echo -a empty | else //echo -a not empty

it works...
so why wont it disable ID in dialog init if it is correct syntax ?


IceCapped
#148757 10/05/06 07:27 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
where you have if ( $lines($mircdirsystem\spam_channels.txt) = 0 ) { .did -m protect 49 }

did you mean if ( $lines($mircdirsystem\spam_channels.txt) == 0 ) { dialog -m protect 49 }

#148758 10/05/06 07:31 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Make sure it's an edit box you're trying to disable.

/did -b Will disable ID's.

#148759 10/05/06 07:42 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
oh god... im so stupid
lol

answer was in -b =)

/me hides

thanks heh


IceCapped
#148760 10/05/06 07:47 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
try this to test, in the init section put
echo -a file test: $lines($mircdirsystem\spam_channels.txt)

if that line comes back with nothing after the "file test" then its $null

then this should work

if ( $lines($mircdirsystem\spam_channels.txt) == $null ) { did -m protect 49 }

-b disable id
-m disables editbox


#148761 10/05/06 08:40 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
yeah =)
i messed up with editbox where i should use ID
(not -m but -b)

also i wish to ask, what code should it go for LIST control
that for example when it is empty (nothing is SELECTED) id is disabled, and when there is something SELECTED that ID becomes enabled.

because for now i have dialog on init to check if file.txt is empty or not, and same goes in dialog sclick events
but kinda looks stupid to have ID (Button) enabled if nothing is selected (i use dialog thru which user can add something to list(.txt file) and remove things from same)

i can post full code if it is needed

Last edited by raZOR; 10/05/06 08:41 PM.

IceCapped
#148762 10/05/06 09:09 PM
Joined: May 2006
Posts: 1
P
Mostly harmless
Offline
Mostly harmless
P
Joined: May 2006
Posts: 1
hey guys

#148763 11/05/06 03:19 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
on *:dialog:[color:red]name[/color]:init:*: did -b $dname [color:red]ID_OF_BUTTON[/color]
on *:dialog:[color:red]name[/color]:sclick:[color:red]ID_OF_LISTBOX[/color]: did -e $dname [color:red]ID_OF_BUTTON[/color]


Half of this stuff is explained in the help file.. Feel free to read it some time smile

#148764 11/05/06 02:20 PM
Joined: May 2006
Posts: 25
A
Ameglian cow
Offline
Ameglian cow
A
Joined: May 2006
Posts: 25
Using this thread... could someone tell me if it is possible to define many Default buttons, one per tab?

I have something like that:

Code:
  button "Add", 7, 112 40 20 10, flat default tab 1
  button "Add", 14, 112 40 20 10, flat default tab 2


And so on... but it doesn't seem to work, I only get the first button like default, ignoring the rest of declarations. Any idea?

Thanx!


==================
Abstraction is art.
#148765 11/05/06 02:30 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
You need to do it at runtime: use the sclick event to watch for tab clicks and the /did -t command to dynamically set the default button.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#148766 11/05/06 04:03 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
Quote:
Code:
on *:dialog:[color:red]name[/color]:init:*: did -b $dname [color:red]ID_OF_BUTTON[/color]
on *:dialog:[color:red]name[/color]:sclick:[color:red]ID_OF_LISTBOX[/color]: did -e $dname [color:red]ID_OF_BUTTON[/color]


Half of this stuff is explained in the help file.. Feel free to read it some time smile


yes i understand those events :P
but i dont understand what should i write in List SCLICK
so it detects if LIST is empty or not ?

i have this code:

if ($did = 46) {
if ($did(46).lines == 0) { .did -b protect 49 }
}

where 46 is list control and 49 is button
and when list control is clicked on (and has no lines)
button does NOT become disabled


IceCapped
#148767 11/05/06 04:08 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The sclick event isn't fired unless an item is selected in the listbox, so your script will never run.

#148768 11/05/06 04:09 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
so in other words, this is impossible what i need ?


IceCapped
#148769 11/05/06 04:26 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Yes but you could work around it. Check out this example:

Code:
dialog t {
  title ""
  size -1 -1 300 300
  option dbu
  list 1, 0 0 300 270, vsbar
  button "clear", 2, 270 270 20 20
  button "add item", 3, 240 270 20 20
}
on *:dialog:t:mouse:*:{
  if ($did(2).enabled) && (!$did(1).lines) did -b $dname 2
  elseif ($did(1).lines) && (!$did(2).enabled) did -e $dname 2
}
on *:dialog:t:sclick:2: did -r $dname 1
on *:dialog:t:sclick:3: did -a $dname 1 test

#148770 11/05/06 04:55 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Or you could employ a different logic altogether: since your script always knows when text is added/removed (assuming the user doesn't type /did -a/-r himself!), you can do what you want at those moments. More specifically

[*]Open your dialog with the button disabled.
[*]Whenever the sclick event for that listbox fires, it means a (non-empty) line was selected, so enable the button.
[*]Whenever something is removed from the listbox, check $did().sel (either $did(id,0).sel or $did(id,1).sel). If it's 0, disable the button.
[*]Whenever the listbox is overwritten with text (eg a file is loaded over any existing text), disable the button.

Last edited by qwerty; 11/05/06 05:01 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#148771 11/05/06 05:00 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
nice =)
thanks

@qWerty

will try =)
thanks

Last edited by raZOR; 11/05/06 05:01 PM.

IceCapped
#148772 11/05/06 05:30 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
well now i have this
Code:
  
  if ($did = 49) { 
    if ($did(46,1).sel) { 
 some code that re-loads contents of .txt into list
    }
    if ($did(46,0).sel) { .did -b protect 49 }
  ;this is where it should disable button 49
  }



but its not working


IceCapped
#148773 11/05/06 05:33 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
    if ([color:red]![/color]$did(46,0).sel) { .did -b protect 49 }

#148774 11/05/06 05:36 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Try

Code:
  if ([color:red]![/color]$did(46,0).sel) { .did -b protect 49 }


Edit: hixxy beat me to it.

#148775 11/05/06 05:37 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
if ($did(46,0).sel) { .did -b protect 49 }

This will disable the button if nothing is selected in the listbox. Isn't that the opposite of what you want? Also, if you reload a .txt by overwriting the listbox (and not by appending to it), no line will be selected after the file is reloaded, so you can just disable the button without checking anything.

Edit: SladeKraven beat me to it :tongue:

Last edited by qwerty; 11/05/06 05:40 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Page 1 of 3 1 2 3

Link Copied to Clipboard