mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
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?


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Aug 2004
Posts: 7,252
R
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.

Joined: Jul 2007
Posts: 1,129
T
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?

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
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 ?


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Nov 2006
Posts: 1,559
H
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.
Joined: Jan 2007
Posts: 1,156
D
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.

Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
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.

Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-

Link Copied to Clipboard