mIRC Home    About    Download    Register    News    Help

Print Thread
Halting script WITHOUT haltdef #263462 08/08/18 02:13 PM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
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?

Re: Halting script WITHOUT haltdef [Re: Protopia] #263463 08/08/18 02:33 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Give us an code example to understand your problem to help you further..

Re: Halting script WITHOUT haltdef [Re: Protopia] #263466 08/08/18 03:37 PM
Joined: Jan 2004
Posts: 1,230
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,230
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.

Re: Halting script WITHOUT haltdef [Re: Protopia] #263467 08/08/18 04:22 PM
Joined: Jul 2006
Posts: 3,588
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,588
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Halting script WITHOUT haltdef [Re: maroon] #263468 08/08/18 04:25 PM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
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.

Re: Halting script WITHOUT haltdef [Re: Protopia] #263469 08/08/18 04:39 PM
Joined: Jul 2006
Posts: 3,588
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,588
3. won't work because it's calling /halt basically


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Halting script WITHOUT haltdef [Re: Wims] #263470 08/08/18 05:10 PM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
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.)

Re: Halting script WITHOUT haltdef [Re: Protopia] #263471 08/08/18 05:27 PM
Joined: Jul 2006
Posts: 3,588
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,588
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Halting script WITHOUT haltdef [Re: Protopia] #263473 09/08/18 06:08 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
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
Re: Halting script WITHOUT haltdef [Re: jaytea] #263474 09/08/18 08:10 AM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
So tweaking this as follows effectively gives us a stop command?
Code:
alias stop { $$null }

Re: Halting script WITHOUT haltdef [Re: Protopia] #263491 11/08/18 07:55 AM
Joined: Feb 2003
Posts: 2,669
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,669
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!
Re: Halting script WITHOUT haltdef [Re: Raccoon] #263492 11/08/18 08:32 AM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
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.

Re: Halting script WITHOUT haltdef [Re: Raccoon] #263493 11/08/18 03:48 PM
Joined: Jul 2006
Posts: 3,588
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,588
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Halting script WITHOUT haltdef [Re: Wims] #263494 11/08/18 04:11 PM
Joined: Aug 2003
Posts: 246
P
Protopia Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 246
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!!