mIRC Home    About    Download    Register    News    Help

Print Thread
New on event #27887 03/06/03 04:13 PM
Joined: May 2003
Posts: 177
P
Prizm Offline OP
Vogon poet
OP Offline
Vogon poet
P
Joined: May 2003
Posts: 177
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.

Re: New on event #27888 03/06/03 11:39 PM
Joined: Dec 2002
Posts: 17
N
nimper Offline
Pikka bird
Offline
Pikka bird
N
Joined: Dec 2002
Posts: 17
You can use the on INPUT event.

on *:input: {
if ($1 == /remove) { whatever }
}

Re: New on event #27889 04/06/03 12:36 AM
Joined: May 2003
Posts: 177
P
Prizm Offline OP
Vogon poet
OP Offline
Vogon poet
P
Joined: May 2003
Posts: 177
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.

Re: New on event #27890 04/06/03 06:33 AM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
alias remove {
; your param count checking here

; your other check here

; more checks here

.remove $1-
}

Re: New on event #27891 04/06/03 01:15 PM
Joined: May 2003
Posts: 177
P
Prizm Offline OP
Vogon poet
OP Offline
Vogon poet
P
Joined: May 2003
Posts: 177
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!

Re: New on event #27892 04/06/03 01:38 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
do u need it for mirc commands or your own aliases?

Re: New on event #27893 04/06/03 02:14 PM
Joined: May 2003
Posts: 177
P
Prizm Offline OP
Vogon poet
OP Offline
Vogon poet
P
Joined: May 2003
Posts: 177
Both, but mostly mIRC's built in commands.

Re: New on event #27894 04/06/03 02:19 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
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

Re: New on event #27895 04/06/03 02:54 PM
Joined: May 2003
Posts: 177
P
Prizm Offline OP
Vogon poet
OP Offline
Vogon poet
P
Joined: May 2003
Posts: 177
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.

Re: New on event #27896 04/06/03 04:38 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
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

Re: New on event #27897 04/06/03 09:18 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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.

Re: New on event #27898 04/06/03 11:14 PM
Joined: Feb 2003
Posts: 2,700
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,700
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


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: New on event #27899 04/06/03 11:20 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
I still say mIRC should have support for exception handling though smile