mIRC Home    About    Download    Register    News    Help

Print Thread
identifier $cmdprefix for on input #220982 04/05/10 12:54 PM
Joined: Dec 2002
Posts: 198
T
Talon Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Dec 2002
Posts: 198
a simplistic on input event which i'm sure loads of people are quite fond of using lacks one key argument. A way to detect weither or not someone is entering a command into that active windows editbox. You can determine if your pasting to it with $inpaste or even determine if ctrl+enter was pressed with $ctrlenter but theres no identifier that I could find in the mirc help file which returns your command prefix set in Options->Other->Command Prefix

most peoples on input events start out with something like this:
Code:
on *:input:#: {
  if ($left($1,1) != /) || ($ctrlenter) {
    haltdef and do some kinda text theming and hide messaging the room.
  }
}


which is fine and dandy, but what if a user decides they don't like "/" as their command prefix? I know there is a simplistic solution for this problem, which is:
Code:
$readini($mircini,text,commandchar)


but once again, that is only a temporary solution as mIRC develops the mirc.ini doesn't necessarily stay backward compatible, like stated in the mIRC 7 beta. There really should be an identifier to return this since it is a changable option.

Re: identifier $cmdprefix for on input [Re: Talon] #220984 04/05/10 06:22 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
That's a good point. Another suggestion besides (or in addition to) a $cmdprefix identifier would be some kind of $command identifier for the ON INPUT event specifically. This would return whether or not mIRC is about to process the line as a /command, abstracting the common

Code:
ON *:INPUT:*:if (/* !iswm $1- || $ctrlenter) ...


to:

Code:
ON *:INPUT:*:if (!$command) ...


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: identifier $cmdprefix for on input [Re: argv0] #220985 04/05/10 06:57 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
I have nothing against your suggestion, but you're the one that usually comment on feature that can be easily scripted, what's happening ?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: identifier $cmdprefix for on input [Re: Wims] #220987 04/05/10 07:30 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Scripting $command is not easy enough; if you're a new scripter (or in a hurry) then taking into account things like ctrl+enter, $inpaste and the optional command char can get more complicated than it's worth.

Re: identifier $cmdprefix for on input [Re: Collective] #220989 04/05/10 09:38 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Well, your explanation might answer my question, but I disagree, imo the on input event is one of the most used event by new scripter, and they don't have any problem with it, $ctrlenter or $inpaste is easy to understand, as would be $cmdprefix.

Last edited by Wims; 04/05/10 09:39 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: identifier $cmdprefix for on input [Re: Wims] #220990 04/05/10 09:57 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I am also one who normally feels that anything easily scripted doesn't really need to be added, but in this case, I also agree that it would be better to have some $command ($iscmd maybe) check. Because it IS so heavily used, this is one of those times when it would make the most sense to have it added even though it can be scripted easily. It's also something that can be added with *very* minimal time or effort and doesn't break any existing scripts. That's why it's worth adding. Other types of requests that take a lot of time, aren't used often, break scripts, *and* are easily scripted aren't worth doing.


Invision Support
#Invision on irc.irchighway.net
Re: identifier $cmdprefix for on input [Re: Wims] #220991 04/05/10 09:58 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
If $cmdprefix was added, having $command wouldn't be necessary, but they might as well be added together. Basically, one or the other (or both) would do. However, since it's likely that $cmdprefix will be used pretty much exclusively to test ON INPUT events, it would be wiser to just consolidate the big if statement into a simple $command event rather than giving you one extra tiny part.

Also, as Collective pointed out, there are more factors that people don't take into account like $inpaste, which even the example scripts above ignore-- $command would be able to deal with such omissions a lot more elegantly than simply providing the $cmdprefix.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: identifier $cmdprefix for on input [Re: Wims] #220992 04/05/10 10:00 PM
Joined: Dec 2002
Posts: 198
T
Talon Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Dec 2002
Posts: 198
Not everyone has as much scripting experience as the rest of us, I don't think feature suggestions should be limited to next-to-impossible to script scenereos. And like I mensioned, there is no garuntee that the mirc.ini will always be formatted the same in newer releases. Anything I feel could make life easier for any newcommer interested in learning mIRC Scripting should be a valid feature suggestion no matter how simplistic it would be to implement. Theres loads of examples of identifiers that are in there for conveniance. Heck since this stuffs so easily scripted, then any event like on text for example, $nick, $fulladdress or any of those in your eyes shouldn't have been supported because its simple to extract from $rawmsg?

Re: identifier $cmdprefix for on input [Re: Riamus2] #220993 04/05/10 10:00 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
$iscmd is a better name.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: identifier $cmdprefix for on input [Re: argv0] #220994 04/05/10 10:08 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Yeah, as I said, I have nothing against the $command suggestion.. but :

$cmdprefix is needed, or at least we need a way to know for any version of mirc which characters can be used to execute a command.

$command would just tell you if mirc would handle the line as a command or not, it's not needed if we have $cmdprefix (which is needed anyway)

so it's not really one or the other, we do need $cmdprefix, not $command, which would be still good to have.

Talon : I do support $cmdprefix and why not $command, at first I was just surprised to see argv0 wanting such an easy thing since he usually is the one arguing against "easy do-able" suggestion, which I think is a good thing to do.

Last edited by Wims; 04/05/10 10:13 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: identifier $cmdprefix for on input [Re: Wims] #220995 04/05/10 10:18 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Not really. The prefix check is helpful, but when would you use it other than in input scripts as a way to determine if you want to use your script on it or leave it as-is so the command works? If there is some other need for it, then I agree that it would be worth adding that. But I can't really think of any other time you're using that.

And if you're using the prefix in a check to see if you should run your script or leave it as-is, then you should also be checking for $ctrlenter and $inpaste. Rather than having to check all of them in every input event, an $iscmd check (aka $command check) would make a lot more sense.

So from my point of view, $iscmd makes the most sense. If there's a reason why you'd only want the command character, then adding a prefix identifier as well is okay and it would make sense if you did that at the same time anyhow. But having a prefix check without the command check just doesn't make any sense.

EDIT: Btw, I was thinking of $iscmd just because $command was mentioned. I'm not sure it's the best name for it since we're also checking $ctrlenter and $inpaste. But I'm not sure what else we'd name it. $isspecialinput is way too long and hard to read. smile Maybe $safeinput or $protectedinput, but even those just aren't very good either. Maybe $iscmd would be fine and just clearly explain everything it checks in the help file.

Last edited by Riamus2; 04/05/10 10:22 PM.

Invision Support
#Invision on irc.irchighway.net
Re: identifier $cmdprefix for on input [Re: Riamus2] #221000 04/05/10 11:05 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
I don't script any on input event myself so I won't use any of these, this is just for consistency.

There's no point saying "not really" because you "can't really think of any other time ...", that's saying you don't see why the OP suggested this in the first place.

It is much more important to have a "safe" way of knowing which characters can be used as a command prefix than having a new identifier that just save bytes, even if this new identifier handle 99% of cases that would require $cmdprefix.

What if I want to count how many command I typed, regardless of $ctrlenter or $inpaste ? This is just one exemple, part of the 1%..


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: identifier $cmdprefix for on input [Re: Wims] #221007 05/05/10 01:18 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Which still leaves that potential case being in the minority of use, which is what I was pointing out. $iscmd or whatever would be much more widely used and would be more of a requirement.

It is highly unlikely that the command character setting in mirc.ini will ever change as it's used by so many scripts. Khaled would be crazy to change that. So there isn't a requirement for a "safe" way to get it. As I said, it would make sense to add both, but the $iscmd would be much more important and is what the OP was really asking for anyhow.


Invision Support
#Invision on irc.irchighway.net
Re: identifier $cmdprefix for on input [Re: Riamus2] #221008 05/05/10 01:58 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
^ that summarizes my position on this issue. In the context it was suggested, $iscmd is more useful than a $cmdprefix. Though I could see edge cases where the latter might be useful too, those users/cases could still manage with $readini.

@Wims, PS. I do believe in people scripting things when they can-- but I'd like to think "is scriptable" implies "is reliably scriptable" in a non error-prone manner. As we've seen, it's not that simple to get $iscmd right on your own, there are a few cases even knowledgeable scripters can miss. Yes, it's easily scriptable, but scripting it is not obvious. IMO that makes it an exception (I also make exceptions for things that are *too complex* to script, btw, but we've rarely seen those cases, so you've never seen me suggest it :)).


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: identifier $cmdprefix for on input [Re: Riamus2] #221009 05/05/10 02:09 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Quote:
Which still leaves that potential case being in the minority of use, which is what I was pointing out. $iscmd or whatever would be much more widely used and would be more of a requirement.
Yeah I agree but still, $iscmd is unneeded and $cmdprefix is, that's the whole point.
Quote:
As I said, it would make sense to add both
I'm sorry but no, you never said that, otherwise I wouldn't spend time re-explaining.

argv0 : It's ok

Last edited by Wims; 05/05/10 02:18 AM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: identifier $cmdprefix for on input [Re: Wims] #221016 05/05/10 10:08 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Originally Posted By: Wims

Quote:
As I said, it would make sense to add both
I'm sorry but no, you never said that, otherwise I wouldn't spend time re-explaining.

argv0 : It's ok


Originally Posted By: Riamus2
If there's a reason why you'd only want the command character, then adding a prefix identifier as well is okay and it would make sense if you did that at the same time anyhow.


Actually, yes, I did. smile


Invision Support
#Invision on irc.irchighway.net
Re: identifier $cmdprefix for on input [Re: Talon] #222748 01/07/10 07:55 PM
Joined: Jul 2006
Posts: 248
B
bwuser Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jul 2006
Posts: 248
By the way, documentation states:
Quote:
Regardless of the character you choose here, mIRC still recognizes the / character and uses it internally.


Re: identifier $cmdprefix for on input [Re: bwuser] #222833 05/07/10 08:58 PM
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
Hmm, wouldn't an $iscmd be the equivalent of a $islias?
If you don't set your aliases to be local ones, then a $isalias($right($1,$len($1))) should do.

Of course, there's a catch with built in aliases, but that just makes $cmdprefix even more useful.
You set $cmdprefix to the first character and check it in the if against w/e you want.

Personally, I never use mirc's ini file for this, I usually use a hash value, which is more easily messed with, and independent of mIRC's version. Compatibility.

Then again...I guess I'm a little more advanced then your average scripter, and enjoy wasting my time on occasion, or just going for the more complicated thing for the heck of it x>

Considering you're going to use w/e will be added in an if statement, the same way you would use the existing method, I'm gonna go ahead and say this is pointless. :>

ziv.

Re: identifier $cmdprefix for on input [Re: ziv] #222843 06/07/10 12:23 PM
Joined: Dec 2002
Posts: 339
D
drum Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Dec 2002
Posts: 339
Originally Posted By: ziv
Hmm, wouldn't an $iscmd be the equivalent of a $islias?
If you don't set your aliases to be local ones, then a $isalias($right($1,$len($1))) should do.


This would basically not work at all. Checking whether the first character is the command prefix character is absolutely necessary, as it is literally the only distinction between a command and a regular line of text. Whether the command is a scripted alias, built-in mIRC command, or server command is irrelevant, so $isalias does not help.

Even if there is a convoluted workaround, it would certainly seem more ideal to simply have an identifier like $cmdprefix or $iscmd instead. (Personally, I think it's a waste of time for mIRC to even support alternate command prefixes, but that's beside the point.)

Re: identifier $cmdprefix for on input [Re: drum] #222845 06/07/10 03:09 PM
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
-_-

I clearly stated that it would still require the same method of if-ing, which makes it pointless.
I was merely showing that you can achieve at least a partial $iscmd with the existing $isalias.

I suppose it wouldn't cover server commands or built in mIRC ones though...

Well, good luck with w/e.
ziv.