mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Is there a way to halt script processing of an event without also doing a /haltdef?

If I use the "^" prefix on an event, then I can /haltdef to prevent mIRC displaying the event, or I can /halt to both /haltdef and stop the script running further, but AFAIK there is no way stop the script processing further without doing a /haltdef.

Does anyone know a way to halt the scirpt from running further without /haltdef the message?

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Give us an code example to understand your problem to help you further..


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
If "stop the script running further" means you want to stop it from running YOUR event-handler code but not hiding the event's messages, you can do it the same way you can stop any other alias you make:

1. return
2. returnex
3. GOTO label_at_last_line_of_your_event_handler
4. Call My_alias without a parameter, but my_alias contains $$1
5. //echo -a $sha1 | echo -a invalid syntax stops your script
etc.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
In an event like:

on *:text:*:#:{
/myalias
}

Inside the alias 'myalias', there is no way to halt the whole script engine without stopping default processing for that event.
The only good way is to make all your alias /return as mentioned, and finally one /return from the event itself


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
1. Return or returnex only work if called from the basic event handler - if called from several nested aliases below it doesn't work.

2. Goto presumably only works inside an alias - so doesn't actually halt processing.

3. Calling an alias which requires a parameter I will try.

4. Invalid syntax stops the script but produces an error message.

The use case is a very large script which is structured as many small aliases which each do simply things - and to halt all script processing for an event which might need to be /haltdef but not on this occasion (and so has a ^ prefix) from within an alias several nested calls deep but on this occasion without doing a /haltdef.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
3. won't work because it's calling /halt basically


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
At the moment the code looks a bit like this (grossly simplified - the real script is 100x as complicated):
Code:
on ^*:Text:*:#:*: {
  alias1 $1-
  halt
}

And what I want to do in the nested alias is to stop processing but not using /halt and avoiding /haltdef, so that the halt at the higher level is not processed.

(I should add that I have fixed my current code with something that looks like this - so this is now theoretical:
Code:
on ^*:Text:*:#:*: {
  if ($notify($nick)) return
  alias1 $1-
  halt
}

But it might be nice to have a /stop which does the same as /halt but without the implied /haltdef.)

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Yeah, you need to return to the event and return from there:
Code:
on ^*:Text:*:#:*: {
  if ($notify($nick)) return
  alias1 $1-
  if (%shouldreturn) return
  halt
}

alias1 {
eventual code..
if (shouldreturn) { set -u %shouldreturn | return }
eventual code..
}
Instead of a /stop command, maybe /halt could be improved with a switch so that /haltdef is not executed when /halt is used


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: Protopia

4. Invalid syntax stops the script but produces an error message.


there shouldn't be any invalid syntax. this is a fine solution that totally works. here's a related form:

Code:
on ^*:text:*:*:{
  myalias

  ; this doesn't execute
}

alias myalias {

  $$null
  
  ; this doesn't execute either
}


essentially /halt without the /haltdef component.

it should go without saying that you can also use "$$null" inside the event itself, or indeed anywhere else, to the same effect.

Last edited by jaytea; 09/08/18 06:12 AM.

"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
So tweaking this as follows effectively gives us a stop command?
Code:
alias stop { $$null }

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Aye. I had come up with /noop $$! on the second post down, but any line containing $$! or $$() or $$null will work.

Good stuff to know. I consider /halt and /haltdef to be rather confusing and inconsistent, and really appreciate where the OP is coming from here. Had somebody else ask the same question in the past day, too.

Here's a question for everyone. How can I take advantage of the $halted identifier across multiple script files, if using /halt is a disaster in itself?


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Originally Posted By: Raccoon
Here's a question for everyone. How can I take advantage of the $halted identifier across multiple script files, if using /halt is a disaster in itself?

I am not sure I would describe /halt as a "disaster".

Leaving aside potential issues of malicious scripts which use halt to hide messages and possibly replace them with something different, in my experience the only issue with /halt is ...

... that we cannot distinguish between scripts which use /halt to hide messages completely or those which /halt and then display the message themselves (e.g. in order to display the message somewhere other than mIRC's default window) ...

... and this is generally only an issue if the second script wants to hide or redirect the message too (rather than simply react or respond to it). It cannot hide a message which has been halted and then echoed, nor can it redirect the message somewhere else because it has already been echoed.

The solutions are IMO:

1. to use $halted to avoid echoing the message again or avoid echoing any message which assumes that the user has seen the original message, using code like:

Code:
if (!$halted) echo -s Stuff


2. to avoid halting and echoing the message by default (i.e. do it only when absolutely necessary) as some scripts like https://github.com/ElectronicWar/nbs-irc/issues/17 appear to do.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
When you halt an on text event in script file A, on text in others files are still triggered/checked.

@jaytea: I also didn't know that $$ wasn't calling /halt directly like that, good to know indeed.

Last edited by Wims; 11/08/18 03:52 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Originally Posted By: Wims
When you halt an on text event in script file A, on text in others files are still triggered/checked.

Exactly!!


Link Copied to Clipboard