From WikiChip
Editing mirc/thread
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | + | This page aims to discuss threads in mIRC, delayed execution and non blocking while loop. | |
== Thread == | == Thread == | ||
− | mIRC is single threaded, | + | There are no thread in mIRC, mIRC is single threaded, always. |
Sometimes it looks like mIRC can do multiple things at the same time without freezing, this is never the case, below we will discuss the different illusions that can occur. | Sometimes it looks like mIRC can do multiple things at the same time without freezing, this is never the case, below we will discuss the different illusions that can occur. | ||
Line 22: | Line 22: | ||
mIRC itself, with $input, does this: | mIRC itself, with $input, does this: | ||
− | <source | + | <source> |
alias test { | alias test { | ||
− | + | set %test 1 | |
− | + | noop $input(text,e) | |
− | + | echo -a %test | |
} | } | ||
</source> | </source> | ||
Line 42: | Line 42: | ||
What this dll does is exactly what $input does, it calls the message loop and allow more message to be processed: | What this dll does is exactly what $input does, it calls the message loop and allow more message to be processed: | ||
− | <source | + | <source> |
while (condition) { | while (condition) { | ||
− | + | ;call the WhileFix routine | |
− | + | dll path\to\whilefix.dll WhileFix | |
− | + | your code here | |
} | } | ||
</source> | </source> | ||
Line 56: | Line 56: | ||
Since a very long time as well, {{mIRC|COM|COM}} script to pause the execution of your script exist (pausing can be done with timers, just not as handy): | Since a very long time as well, {{mIRC|COM|COM}} script to pause the execution of your script exist (pausing can be done with timers, just not as handy): | ||
− | <source | + | <source> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
alias mycode { | alias mycode { | ||
− | + | do something | |
− | + | ;wait 5 second before continuing | |
− | + | pause 5 | |
− | + | do something else | |
} | } | ||
</source> | </source> | ||
− | This time it's | + | This time it's mIRC again handling it, <need more info> |
== Critical and non critical events == | == Critical and non critical events == | ||
Line 79: | Line 71: | ||
Ever wondered why you can't call $input from an on text event? This is related to the message loop. | Ever wondered why you can't call $input from an on text event? This is related to the message loop. | ||
− | All messages from the message loop which are related to sockets (mIRC's internal socket | + | All messages from the message loop which are related to sockets (scripted socket or mIRC's internal socket) can be called critical events whereas any other message (clicking on a nick in the nicklist for example) is considered a non critical event. |
− | + | Socket related messages are called critical because mIRC cannot handle these messages if they are handled from a nested call to the message loop. | |
− | Socket related messages are called critical because mIRC cannot handle these messages if they are | + | Indeed, imagine if the following were allowed: |
− | + | <source> | |
− | Indeed, imagine if | ||
− | <source | ||
on *:text:!test:#test:noop $input(test,e) | on *:text:!test:#test:noop $input(test,e) | ||
on *:text:*:#test:do stuff | on *:text:*:#test:do stuff | ||
</source> | </source> | ||
If someone says !test on the channel, $input is called and as we saw above, mIRC will call the message loop until $input returns, now suppose a new message "test" is sent on the channel while your $input is running, since mIRC is processing the message loop, it would process this channel message and the second on text would trigger, this is not wanted, the first on text has to finish first to guarantee correct order of execution, this is why $input is not allowed in critical event, you can try to use $input inside mIRC's event to see if they are critical (as said only socket related events should return an error). | If someone says !test on the channel, $input is called and as we saw above, mIRC will call the message loop until $input returns, now suppose a new message "test" is sent on the channel while your $input is running, since mIRC is processing the message loop, it would process this channel message and the second on text would trigger, this is not wanted, the first on text has to finish first to guarantee correct order of execution, this is why $input is not allowed in critical event, you can try to use $input inside mIRC's event to see if they are critical (as said only socket related events should return an error). | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |