mIRC Home    About    Download    Register    News    Help

Print Thread
parameter count and read #69967 01/02/04 12:08 PM
Joined: Jan 2004
Posts: 79
C
cmad Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Jan 2004
Posts: 79
This is really simple I know but I just can seem to be able to do it mad

1) How do I get the parameter count of an alias (or event)

example: /test_alias abc1 d2 f e
that should return 4.

How do I do that?

2) And I want to be able to read the contents of the parameters like

$%i

but it won't work.

I hope you know what i mean smile


My ally is the compiler, and a powerful ally it is!
Re: parameter count and read #69968 01/02/04 12:20 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
/alias test_alias echo -a $0 parameters; $!1 = $1 ; $!2 = $2 ; $!3- = $3- ; $!1-3 = $1-3

Re: parameter count and read #69969 01/02/04 12:31 PM
Joined: Jan 2004
Posts: 79
C
cmad Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Jan 2004
Posts: 79
the $0 works

but about the other ones

it's not what I want

let's say I got a variable %i that contains the integer for example 2.

I wanna be able to do something like $%i

i.e. the i-th parameter


My ally is the compiler, and a powerful ally it is!
Re: parameter count and read #69970 01/02/04 12:36 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
$ [ $+ [ %i ] ]
or
$eval($ $+ %i,2)
$eval($+($,%i),2)

Re: parameter count and read #69971 01/02/04 03:42 PM
Joined: Feb 2003
Posts: 2,642
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,642
Or, for greater flexibility...

$numtok($1-,32)
$gettok($1-,0,32)
and
$gettok($1-,%i,32)

See also /help Token Identifiers for more info.
You'll want to learn these eventually.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!