mIRC Homepage
Posted By: LostShadow Dynamically link variables.. - 18/07/07 06:58 AM
alias seen {
%nick = $1
set -u30 %readn $+ %nick 0
$read() stuff
set -u30 %readn $+ %nick $readn
echo -a %readn $+ %nick
echo -a $readn
}

At the end of the alias.

%readn $+ %nick always says 0, different than $readn

I've tried

echo -a $+(%readn,%nick)
echo -a $+(%,readn,%nick)
echo -a $+($eval(%readn,%nick),2)
echo -a $+($eval(%,readn,%nick),2)

None luck.

Since %nick = $1, in the alias, I also used $1 too.

alias seen {
%nick = $1
set -u30 %readn $+ $1 0
$read() stuff
set -u30 %readn $+ $1 $readn
echo -a %readn $+ $1
echo -a $readn
}

%readn $+ $1 also always says 0, different than $readn

I've tried

echo -a $+(%readn,$1)
echo -a $+(%,readn,$1)
echo -a $+($eval(%readn,$1),2)
echo -a $+($eval(%,readn,$1),2)

Still none like $readn.
Posted By: Bekar Re: Dynamically link variables.. - 18/07/07 07:46 AM
You're doing the $eval() backwards:

Code:
echo -a Value: $eval($+(%,readn,%nick),2)

In this, there are about 3 things you need to be aware of:

- String concatenation : $+()
- Separation of variable componants : %, readn, %nick
- Double-evaluation : $eval(<string>,2)

The first part is making up your full variable name '%readnLostShadow'.

The second part is the breaking up of '%' and 'readn'. As you're double-evaluating next, you don't wand '%readn' to be evaluated yet, thus the splitting up.

The third part is the two-pass evaluation. The first pass does this (where '%nick = LostShadow'):

Code:
$+(%, readn, %nick) -> %readnLostShadow

The second pass then evaluates the resultant string.

Throughout this, you can use either %nick or $1. Using $1 will probably make it easier/faster however.

Here's a question for you however.. You're using 'set -u30'. As you are zeroing out the %readn<nick> variable every time you execute it, is there really any reason for the variable to stick around for 30 seconds? I'd suggest you use '/var' instead, a localized variable which unsets once complete.
Posted By: LostShadow Re: Dynamically link variables.. - 18/07/07 08:21 AM
Alright, thank you so much. Everything works great now. Althought I needed to use the %variable instead of $1.
© mIRC Discussion Forums