mIRC Home    About    Download    Register    News    Help

Print Thread
Have anybody any idea about this? #209802 23/02/09 10:02 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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?

Re: Have anybody any idea about this? [Re: westor] #209803 23/02/09 10:22 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Have anybody any idea about this? [Re: RusselB] #209805 23/02/09 10:30 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I thought the /return could also be used to halt a script without completely stopping it to process?

Re: Have anybody any idea about this? [Re: westor] #209806 23/02/09 10:34 PM
Joined: Jul 2006
Posts: 3,530
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,530
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Have anybody any idea about this? [Re: Wims] #209807 23/02/09 10:38 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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 ?

Re: Have anybody any idea about this? [Re: westor] #209811 23/02/09 11:00 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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:
Code:
alias returntest {
  echo -a returntest start
  returncall
  echo -a returntest end
}

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


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

alias haltcall {
  echo -a doing something...
  halt
  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

Last edited by Horstl; 23/02/09 11:05 PM.
Re: Have anybody any idea about this? [Re: westor] #209815 24/02/09 12:02 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.

Otherwise,
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.

Re: Have anybody any idea about this? [Re: DJ_Sol] #209816 24/02/09 12:10 AM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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

Last edited by westor; 24/02/09 12:11 AM.