mIRC Homepage
Posted By: MrNard $var(%var,N) - 18/11/07 11:49 PM
can anyone explain to me about this identifier..

/var %x = hello, %y, %z = $me

loop {

var %x = 1
:next
echo item %x
inc %x
if (%x < 10) goto next
}

i think $var(%var,N) works not like this example..
Posted By: Wims Re: $var(%var,N) - 19/11/07 12:09 AM
There nothing special with $var, the help file is already very explicit, what the problem ?
Posted By: Bekar Re: $var(%var,N) - 19/11/07 03:51 AM
Be aware of two issues with your code here:

1) /var is for local variables. They are only valid in the event or alias you have called, not outside of it.

2) Unless you put the 'loop' code directly into the 'Aliases' section, it's probably not going to work.

Now, these things being said, using a 'goto' is very old school, and using a 'while' loop is strongly recomended:

Code:
set %x hello
set %y
set %z $me
alias loop {
  var %count = 1, %top = $var(0)
  while (%count < %top) {
    echo -a Item %count = ' $+ $var(%count) $+ '
    inc %count
  }
}

Now, I can't remember what properties $var() takes, but I think there's a .item and/or .value.
Posted By: MrNard Re: $var(%var,N) - 19/11/07 11:59 AM
Yaa.. Thanks for the reply..
I know that var is a local variable. its only work in that scope only. but $var() is an identifier. Maybe its can work faster rather than %var if i use to call it??

Var %x = $1-

$var(%x) <-- its can work, but whats is the function for N. $var(%var,N)
If N = 0, returns total number of matching variable names.

I'm not clear about that N function..
Posted By: Bekar Re: $var(%var,N) - 19/11/07 02:36 PM
It's a typo for me.. sorry smile

Should read: $var(*, 0) and $var(*, %count)

And no. If you know the name of a variable, it's *ALWAYS* quicker to use the named variable, than some identifier which then looks up a table to get the value.
Posted By: Horstl Re: $var(%var,N) - 19/11/07 06:31 PM
Originally Posted By: MrNard
(...) but whats is the function for N. $var(%var,N)
If N = 0, returns total number of matching variable names.

I'm not clear about that N function..

This is quite important if you use wilcards inside some $var(), think of "arrays" of dynamically named variables and the like smile
Posted By: Wims Re: $var(%var,N) - 19/11/07 07:08 PM
Originally Posted By: Bekar
Now, I can't remember what properties $var() takes, but I think there's a .item and/or .value.

Originally Posted By: /help $var

$var(%var,N)
Returns the Nth matching variable name.
Properties: value, local


the prop .local return $true or $false depending if the variable is local or not

Edit :
Originally Posted By: Bekar
And no. If you know the name of a variable, it's *ALWAYS* quicker to use the named variable, than some identifier which then looks up a table to get the value.
This is because $var search for local and global variable
Posted By: MrNard Re: $var(%var,N) - 20/11/07 05:37 AM
Okay guys.. Thanks for thats reply n nice opinion..
© mIRC Discussion Forums