mIRC Homepage
Posted By: Prizm New on event - 03/06/03 04:13 PM
I don't know if this has ever been suggested before, but I think there should be a on COMMAND event along with identifiers to check command and alias output. This event would be very useful checking command errors or just to see if a command was successful.

Format: on <level>:COMMAND:<command name>:<commands>

* Examples

Let's say I did this:

/remove

I would get an insufficient parameters error.

Let's say I did:

/remove temp.txt

I would then get:

-
* Removed 'C:\PROGRAM FILES\MIRC\temp.txt'
-

So here's the event example:

on ^*:COMMAND:remove:{
if ($cmsg == insufficient parameters) {
echo -a * Remove Error
haltdef
}
elseif (* Removed ' $+ $1 $+ ' isin $cmsg) {
echo -a * $1 was successfully removed!
haltdef
}
}

Notes:

The $1 identifier used in my example returns the specified file you specified to remove using the /remove command.

The $cmsg identifer holds the command's output info.
Posted By: nimper Re: New on event - 03/06/03 11:39 PM
You can use the on INPUT event.

on *:input: {
if ($1 == /remove) { whatever }
}
Posted By: Prizm Re: New on event - 04/06/03 12:36 AM
That is altogether different from what I'm asking for. It's not totally possible to check the command output using the on INPUT event. It can be done to an extent with the /filter command, but there would be some conflicts.
Posted By: codemastr Re: New on event - 04/06/03 06:33 AM
alias remove {
; your param count checking here

; your other check here

; more checks here

.remove $1-
}
Posted By: Prizm Re: New on event - 04/06/03 01:15 PM
How does that check if the command was successful or not? It doesn't. The whole point of this new event would to grab the result of the command!
Posted By: ScatMan Re: New on event - 04/06/03 01:38 PM
do u need it for mirc commands or your own aliases?
Posted By: Prizm Re: New on event - 04/06/03 02:14 PM
Both, but mostly mIRC's built in commands.
Posted By: ScatMan Re: New on event - 04/06/03 02:19 PM
both?
well how that will know the error msg if it's your own alias
it can't know if it's an error or it's just an echo
Posted By: Prizm Re: New on event - 04/06/03 02:54 PM
Example:

Alias:

alias del {
remove $1-
}

Call alias from command line:

/del

on COMMAND event checks the command's output:

on ^*:COMMAND:del:{
if ($cmsg == insufficient parameters) {
echo -a An error has occured
haltdef
}
elseif ($cmsg == * Removed ' $+ $1- $+ ') {
echo -a File removed
haltdef
}
}

Very simple. I'm not sure how it would work with an alias that has multiple commands, but I'm sure there could be away to check the output on all of them with the proper identifiers.
Posted By: ScatMan Re: New on event - 04/06/03 04:38 PM
ok i understand u, this event will be good only for mirc commands cuz for aliases it's not make sense, output can be in many different ways so it's impossible
Posted By: codemastr Re: New on event - 04/06/03 09:18 PM
Not to mention the things he assumes are errors may not be errors in custom aliases, perhaps I have an alias that has "insufficient parameters" returned when it succeeds, and I do have an alias like that. I made a /invalpara aliasname
It prints out the Insufficient parameters line rather than me having to retype it for each alias I make. So you his code would see /invalpara as failing, when in fact it is succeeding.
Posted By: Raccoon Re: New on event - 04/06/03 11:14 PM
Try this script for error handling/trapping.

It's actually quite pretty, and one of the better uses of Signals I know of. Basically, you execute your command in a Signal -n bubble, which almost acts like creating a new thread... because when the command causes an error, the script still returns where you left off, and you can detect if the signal event didn't finish because commands errored, and trap their messages.

- Raccoon
Posted By: codemastr Re: New on event - 04/06/03 11:20 PM
I still say mIRC should have support for exception handling though smile
© mIRC Discussion Forums