mIRC Homepage
Posted By: curillo Displaying variables in a while loop - 09/12/11 03:32 PM
I have been searching and trying for hours, but I can't make it work:

Let's say I have variables called
%test.1
%test.2
...
%test.10

Now I want to use a while loop to display them all. Something like:

var %i = 1
while (%i <= 10) {
echo 2 %test.%i
inc %i
}

The above code doesn't work. How do I make it work?

Thanks!
Posted By: maroon Re: Displaying variables in a while loop - 09/12/11 04:44 PM
try changing

echo 2 %test.%i

into

echo 2 %test. [ $+ [ %i ] ]
Posted By: Riamus2 Re: Displaying variables in a while loop - 09/12/11 09:08 PM
Or:

Code:
echo 2 $($+(%,test.,%i),2)
Posted By: curillo Re: Displaying variables in a while loop - 09/12/11 11:14 PM
Thanks for the replies. Unfortunately, neither of those work for me.
Posted By: curillo Re: Displaying variables in a while loop - 09/12/11 11:19 PM
Oh, wait... the second one works when put in an alias, but not when doing a straight /echo
Posted By: curillo Re: Displaying variables in a while loop - 09/12/11 11:20 PM
Never mind. I must have mistyped something. They both work in an alias.

Thanks!
Posted By: Loki12583 Re: Displaying variables in a while loop - 10/12/11 01:29 AM
You need to use two slashes to evaluate identifiers in the edit box: //echo -a $pi (and of course your variable would need to be global or defined in the same command)
© mIRC Discussion Forums