mIRC Home    About    Download    Register    News    Help

Print Thread
#190312 18/11/07 11:49 PM
Joined: Nov 2007
Posts: 7
M
MrNard Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Nov 2007
Posts: 7
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..

MrNard #190313 19/11/07 12:09 AM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
There nothing special with $var, the help file is already very explicit, what the problem ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
MrNard #190320 19/11/07 03:51 AM
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

Bekar #190341 19/11/07 11:59 AM
Joined: Nov 2007
Posts: 7
M
MrNard Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Nov 2007
Posts: 7
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..

MrNard #190345 19/11/07 02:36 PM
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

MrNard #190359 19/11/07 06:31 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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

Bekar #190365 19/11/07 07:08 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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

Last edited by Wims; 19/11/07 07:38 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #190390 20/11/07 05:37 AM
Joined: Nov 2007
Posts: 7
M
MrNard Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Nov 2007
Posts: 7
Okay guys.. Thanks for thats reply n nice opinion..


Link Copied to Clipboard