mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2010
Posts: 45
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: May 2010
Posts: 45
I'd like to suggest an addition to the /! command. It would be nice if the last command would also be stored in a variable (like eggdrop's $lastbind variable) so it can be re-used later.

I'm making some aliases script which acts as wrapper to other aliases and in command usage messages such a builtin variable would be awesome to have, rather than having to implement this myself, because those commands can be called directly by the user too and it would simplify things greatly.

It should store the command right after it is called and is not finished yet, so that it can be used in itself too, again similar to how eggdrop's $lastbind works.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Easy to do with a script:

Code:
on *:INPUT:*:if (/* iswm $1-) set %lastbind $1-
alias lastbind return %lastbind


If you really need it, the above can do it.

Typing //echo -a $lastbind would produce a Quine

If you wanted extra parsing of specifics (like separating command name from args, making .show and .builtin props for "." and "!" prefix chars respective) you could script this on as well. You could probably do a better job of anything mIRC did builtin, so you have more power/flexibility scripting this anyway.

Given that it is essentially a one-liner (with small identifier alias for convenience), I don't see why it needs to be builtin. Users who really need this (I've never ever needed this kind of behaviour myself, and can't think of any situations where I would) can already add it.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
For the sake of completeness you may as well support the additional command char as it's not a lot of extra work:

Code:
on *:INPUT:*:if ($istok(/ $readini($mircini,text,commandchar),$left($1,1),32)) set %lastbind $1-
alias lastbind return %lastbind


Or to save on disk accesses:

Code:
on *:start: set %mcommandchar $readini($mircini,text,commandchar)
on *:INPUT:*:if ($istok(/ %mcommandchar,$left($1,1),32)) set %lastbind $1-
alias lastbind return %lastbind

Joined: May 2010
Posts: 45
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: May 2010
Posts: 45
Thank you both for the idea and help, I'm using this solution for a while now and it works great. smile

Commandchar however would be nice to have as a builtin variable so that disk/file access is not needed, your workaround is nice but only takes effect when mIRC is restarted, nonetheless it is the next best thing indeed.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You don't need ON START to save on disk access, it's very easy to cache the result at runtime.

Code:
alias commandchar {
  if (!%mcommandchar) set %mcommandchar $readini($mircini,text,commandchar)
  return %mcommandchar
}


And there is your identifier.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard