mIRC Home    About    Download    Register    News    Help

Print Thread
#266472 16/12/19 05:26 PM
Joined: Jul 2006
Posts: 4,144
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
The help file mentions that for both $hfind and $findfile/$finddir, /halt halts only the search and not the full script execution.

It's correct for $findfile/$finddir, but it's not the case for $hfind, which halts the full script, it should be halting the $hfind search only.

Related to halt halting search, /halt in the alias called by /filter -k does not work (it's doing a /return basically), it should also halt the /filter search.

Last edited by Wims; 16/12/19 08:43 PM. Reason: details

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
I agree with Wims that this looks like a bug as $hfind is operating differently to the help file statement that it halts $hfind and not the script calling $hfind, because it inconsistent with $finddir/$findfile and because this makes it extremely difficult indeed if nbot impossible for a scripter to stop a million iterations of the command/alias in $hfind without terminating the calling script.

Whilst we are looking at these, it would be extremely helpful to scripters if $hfind, $finddir and $findfile had a .halted property as an easier way for the script calling the identifier to know when /halt has been called in the inside command/alias.

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Thanks for your bug report. As far as I can tell, this behaviour was never supported by $hfind() and should not have been in the help file. /halt was specifically coded to halt the script completely in $hfind(). I believe this was requested at the time.

For a command/identifier that supports alias calls, /halt support has to be specifically added to change its behaviour. The default behaviour is to only check if there was an error.

I could change $hfind(), /filter, $regex(), and other commands/identifiers to interpret /halt as to stop the processing of the command/identifier but not the script. However, this needs to be added on a per command/identifier basis as the side-effects may not always be obvious. This would also affect backwards compatibility.

Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Yes - it would potentially affect backwards compatibility however whilst I can think of many circumstances why you would want to halt the $hfind but not the script which called it, I cannot see any reason why you would want /halt to halt the entire script and indeed this only seems to cause headaches when you want to halt the $hfind and NOT the script that called it.

The trouble is that you never really know when someone, somewhere, has coded a script that does rely on this however unlikely it may seem. Backwards compatibility is a real yoke to bear if you are truly committed to it - regardless of how unlikely it seems that someone is using a function a specific way, it is always a possibility.

As an alternative suggestion which adds entirely new functionality, why not leave the /halt functionality exactly as it now is, and create /haltfind which can ONLY be used in $hfind, $finddir,, $findfile, /filter etc. and which ends these commands but NEVER halts the calling script. At the same time, you could implement $haltfind ($true/$false) to allow scripts to see if the last use of one of these functions was halted.

Joined: Jul 2006
Posts: 4,144
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Given the way it's documented etc, I think it's also best to change $hfind to halt only the search, same for filter -k, this indeed gives us control, we can always set a variable and halt from the routine calling the $hfind/$findfile/etc to halt the full script.

However the list of features calling an alias like that is indeed not that short, I think you meant $regsub & $regsubex rather than $regex though, I don't see where /halt would be called with $regex.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 252
T
Fjord artisan
Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
I'd much rather see /break extended for this purpose, so /halt does what's listed.

There's several instances where doing "while (1) {" has been handy and only stopping the runaway loop with /break when conditions have been fulfilled, without having to quantify it in a way that satisfies conditions within the "while" parameters and there's no need to /return a value.

It may already work, I haven't tested this, but if it doesn't, I highly doubt the added functionality to allow breaking on any internal-looping identifier would cause any issues from backward compatibility, and less confusion too, as /break is for breaking out of a loop, where /halt is intended to abruptly prevent further processing.

Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
I thought about using /break BUT the alias called inside e.g. $hfind might have a while loop which needs /break in it. I suppose you could detect use a /break outside of a while loop but that means that if you want to halt from inside a while loop you would have to /break, and immediately outside the while loop detect that you did a /break and do another one. It just seems cumbersome.

So that is why I suggested a NEW /haltfind.

Last edited by Protopia; 17/12/19 08:31 PM.
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
I think the simplest change would be to make /halt stop $hfind() as described in the help file. This will be in the next beta.


Link Copied to Clipboard