mIRC Homepage

Have anybody any idea about this?

Posted By: westor

Have anybody any idea about this? - 23/02/09 10:02 PM

i want to ask something that i want to see the difference about the RETURN and the HALT command's what is the difference about these two commands?
Posted By: RusselB

Re: Have anybody any idea about this? - 23/02/09 10:22 PM

The return command can be used with a variable to return (hence the name) the value in the variable to a calling routine. This is the case if you have a script that calls an alias, then sends the results of that alias back to the main script.

The halt command, on the other hand, stops the processing of that script.
If you called an alias from the main script, and had a halt in the alias, then the entire script stops, not just the alias.
Posted By: Tomao

Re: Have anybody any idea about this? - 23/02/09 10:30 PM

I thought the /return could also be used to halt a script without completely stopping it to process?
Posted By: Wims

Re: Have anybody any idea about this? - 23/02/09 10:34 PM

To be more precise, the /return command stop the actual routine, whereas /halt stop the whole script.
Note that /halt is used to stop the default text in on ^:event, but it will as said also stop the whole script, /haltdef should be used when you want halting default text.
Posted By: westor

Re: Have anybody any idea about this? - 23/02/09 10:38 PM

so the RETURN command is not the same with the HALT command and the RETURN turns back the alias and the HALT command stop the alias ?
Posted By: Horstl

Re: Have anybody any idea about this? - 23/02/09 11:00 PM

Quoting the helpfile: "The /halt command halts a script and prevents any further processing."

Besides the use of return to actually return some data, return will only stop the current event definition/alias.
Halt will stop the current event definition/alias AND the calling script.

Compare the output of /returntest and /halttest:
alias returntest {
  echo -a returntest start
  echo -a returntest end

alias returncall { 
  echo -a doing something...
  echo -a doing something else

alias halttest {
  echo -a halttest start
  echo -a halttest end

alias haltcall {
  echo -a doing something...
  echo -a doing something else

Both the /return and /halt commands stop their returncall and haltcall aliases, thus you never read "doing something else".
The /halt in the haltcall alias stops the calling alias "halttest" as well (you won't read "halttest ended"), while the returntest alias keeps running and you can see "returntest end".

This example is far from comprehensive, I hope it helps none the less: /halt will halt the running script (not in sense of a scriptfile) - Wims' "routine" may be the better word. smile
Posted By: DJ_Sol

Re: Have anybody any idea about this? - 24/02/09 12:02 AM

Just in case you are still confused.

Yes return can be used to make a custonm identifier but you are asking about its simlarity to halt.

If you use halt, everything on mirc stops until the next request.

on *:text:*:#:{
if ($nick == $me) halt
This will halt every matching text event from any further processing. For instance, if you had a text event in another file that should have been triggered, it wont be.

Logic states that Script 1 will trigger first and so on.
I believe the ^ prefix supercedes script file order.

So halt will stop everything. Return, however, will only stop the currently executing script it is in.

on *:text:*:#:{
if ($nick == $me) return
This will stop this script from continuing, however, other text events in other mirc files will still trigger.

Halts are usefull for halting raw event messages. Halt is usefull if you truly want mirc to completely halt any processing of other similar events.

As a general rule, I use /return to halt a script, UNLESS of course I do want to halt all scripts from performing.

I hope this clears it up for you.
Posted By: westor

Re: Have anybody any idea about this? - 24/02/09 12:10 AM

hmm because my english is not very good i read the DJ_Sol post and i understand that the RETURN stops only the event,alias,... and the HALT command stops hole script event,alias,...

i understand this so if it is something else then :P
© 2020 mIRC Discussion Forums