mIRC Home    About    Download    Register    News    Help

Print Thread
#228340 19/12/10 02:37 AM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Hello,

I don't know since now if it is an mIRC bug but i can't find any other solution to this, i have a dialog, on dialog init i have putted 3 timers that only the 2 working and the second return an error check:

Code:
      .timer[BL_UPDATE_CHECK_FAIL] -o 1 10 $iif($dialog(banlist_settings),did -ra banlist_settings 15 Error: Connection problem $+ $chr(44) Please try again later!) 
      .timer[BL_UPDATE_CHECK_FAIL_1] -o 1 9 $iif($dialog(banlist_settings),did -e banlist_settings 11)
      .timer[BL_UPDATE_CHECK_FAIL_2] -o 1 9 $iif($dialog(test),echo -s it is already opened)


ERROR MESSAGE:

* /timer[bl_update_check_fail_2]: insufficient parameters (line 328, BanList.mrc)

NOTE: 328 line is there that i have the ($dialog(test)) ..

- Thanks!


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #228345 19/12/10 04:38 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It's not a good idea to use $iif() in a timer like that without both a true and false. If $dialog(test) is $null, your timer will have insufficient parameters. This is true for all 3 timers you have.

Also, identifiers in a timer are evaluated immediately instead of when the timer triggers. If you want it to evaluate at the time that it is triggered, use $! instead of just $ before the identifier. For example, $!iif().

If you want to see what the difference is, here's an easy test for you. Try these two timers and compare the seconds in the output:

//timer 5 1 echo -a $time(hh:nn:ss)
//timer 5 1 echo -a $!time(hh:nn:ss)


Invision Support
#Invision on irc.irchighway.net
Riamus2 #228385 20/12/10 07:41 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
well i did not understand very good the difference but with this alias that i give you now it returns $true in both methods

Code:
alias test {
  .timer 1 5 $!iif($dialog(mydialog),echo -s it is opened)
  .timer 1 5 $iif($dialog(mydialog),echo -s opened)
}


as far i try to understand the $! hide any resault information am i wrong?


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #228392 20/12/10 09:31 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
No. All identifiers and variables are evaluated immediately by a timer. That means that in your example, if mydialog is open **at the time the timer is activated**, then it will trigger the true response (the echo) every time the timer triggers. Even if you close the dialog while the timer is running, it will always return the true response because it was true when the timer was activated.

If you want that it to check the status of the dialog every time it triggers, then you need to use $! instead. That tells the identifier to be evaluated each time the timer triggers. In the example I gave you, $time() never changed, but $!time() did change. That was why I said it was an easy example to show the difference. It's clear that the first one only evaluated the time when the timer was created and never again, while the second one evaluated it every time the timer triggered.

Typically if you're checking something on a timer, you want it to be evaluated when the timer triggers, so you usually want to use $! to make it evaluate every time. Of course, there are situations where you only want it to trigger initially. It depends on what you need it to do.

In either case, my comment on how you're using $iif() is still valid. If the dialog is closed, you will get an error message about the timer not having sufficient parameters. That's rarely a good way to set up a script. If you do not want anything to happen if the dialog is closed, then you should have the false part of $iif() be something like RETURN or NOOP. That lets you have a valid false option while still not doing anything. Note that depending on how and where that is in your script and what you want the script to do or not do, NOOP may be the better option as RETURN will stop the remainder of the script from running. Or, if you do want everything after it to be stopped if false, then RETURN would be the better option. In either case, you really should put a false option there because /timer requires that parameter.

If you were just doing something like:

Code:
echo -a Testing $iif(%var == 1,this)


Then that doesn't need a false because the echo will still work since "Testing" is going to be echoed anyhow. If you had:

Code:
echo -a $iif(%var == 1,Testing)


Then that would need a false option just like /timer because /echo requires somethign to echo. Because this one doesn't have something that is guaranteed to echo, the $iif() needs to provide something no matter what (true or false).


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard