mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2019
Posts: 3
F
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Aug 2019
Posts: 3
How would you pass "a b c" and "1 2 3" to a command and still be able to reference these parameters as $1 and $2 in the corresponding alias?

For the sake of clarification, the following alias would print "a b c 1 2 3" instead of "a b":

Code
alias test {
  echo -g $1 $2
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
only way is to call this as an identifier.

Instead of
/test a b c 1 2 3
it would be
//noop $test(a b c,1 2 3)

The tokenize command can group them together by using something besides space as delimiter:
//tokenize 46 a b c . 1 2 3 | echo -a $1 and $2
however as soon as you called your test alias as a /command
//tokenize 46 a b c . 1 2 3 | /test $1 $2
... then your /test alias would not retain the original definition of $1

Joined: Aug 2019
Posts: 3
F
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Aug 2019
Posts: 3
I already knew I could use identifiers but I was wondering if there was an elegant way to do it with commands, I guess there isn’t…

I’ll just stick to identifiers only.

Joined: Mar 2010
Posts: 146
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 146
There is, as maroon mentioned you can use a different delimiter and /tokenize.


Nothing...
Joined: Aug 2019
Posts: 3
F
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Aug 2019
Posts: 3
Sure, but if I’d like all my custom commands to have this nice feature, I’d have to come up with a common delimiter I could use in all of them. So I’d have to use a delimiter that wouldn’t appear in a regular string, in other words a character which doesn’t appear on a keyboard. Now, let’s say I choose `$chr(31)`. I can use `tokenize 31 $1-` and then I’ll get my parameters nicely numbered but I still need to format the parameters when calling my fancy aliases. So I’d have to add `$chr(31)` between each parameter and that’s why it doesn’t seem to be an elegant solution to me.

Last edited by FraPooChino; 25/08/19 11:05 AM.

Link Copied to Clipboard