mIRC Home    About    Download    Register    News    Help

Topic Options
#263462 - 08/08/18 03:13 PM Halting script WITHOUT haltdef
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
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?

Top
#263463 - 08/08/18 03:33 PM Re: Halting script WITHOUT haltdef [Re: Protopia]
westor Online
Hoopy frood

Registered: 27/12/08
Posts: 1510
Loc: Greece
Give us an code example to understand your problem to help you further..
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#263466 - 08/08/18 04:37 PM Re: Halting script WITHOUT haltdef [Re: Protopia]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 966
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.

Top
#263467 - 08/08/18 05:22 PM Re: Halting script WITHOUT haltdef [Re: Protopia]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3435
Loc: France
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

Top
#263468 - 08/08/18 05:25 PM Re: Halting script WITHOUT haltdef [Re: maroon]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
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.

Top
#263469 - 08/08/18 05:39 PM Re: Halting script WITHOUT haltdef [Re: Protopia]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3435
Loc: France
3. won't work because it's calling /halt basically
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#263470 - 08/08/18 06:10 PM Re: Halting script WITHOUT haltdef [Re: Wims]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
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.)

Top
#263471 - 08/08/18 06:27 PM Re: Halting script WITHOUT haltdef [Re: Protopia]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3435
Loc: France
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

Top
#263473 - 09/08/18 07:08 AM Re: Halting script WITHOUT haltdef [Re: Protopia]
jaytea Offline
Fjord artisan

Registered: 23/02/06
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.


Edited by jaytea (09/08/18 07:12 AM)
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#263474 - 09/08/18 09:10 AM Re: Halting script WITHOUT haltdef [Re: jaytea]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
So tweaking this as follows effectively gives us a stop command?
Code:
alias stop { $$null }

Top
#263491 - 11/08/18 08:55 AM Re: Halting script WITHOUT haltdef [Re: Protopia]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2498
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?
_________________________
doin´┐Ż things a particle can

Top
#263492 - 11/08/18 09:32 AM Re: Halting script WITHOUT haltdef [Re: Raccoon]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
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.

Top
#263493 - 11/08/18 04:48 PM Re: Halting script WITHOUT haltdef [Re: Raccoon]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3435
Loc: France
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.


Edited by Wims (11/08/18 04:52 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#263494 - 11/08/18 05:11 PM Re: Halting script WITHOUT haltdef [Re: Wims]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 216
Loc: UK
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!!

Top