mIRC Home    About    Download    Register    News    Help

Print Thread
Variable + a variable #116116 02/04/05 02:07 PM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
I'm sure I've managed this before, but I just cant get it working now. I'd apreciate any help.

I have the following variables: %var1 %var2... up to %var10

I also have a variable %chose which contains the numbers 1 to 10

What I'd like to do, is be able to do something like this:

/msg $chan %var%chose (Obviously that wont work, but hopefully you can see what I'm trying to achieve)

Therefore, it's got the %var bit + the number contained in %chose.

Unfortunately, I cant find anyway to join the %var and the %chose together in a way so mIRC parses them both at the same time as one variable.

Any ideas? Sorry I havent been able to explain myself very well, if you need more clarification I will try.

Any help apreciated,

thanks.

Re: Variable + a variable #116117 02/04/05 02:36 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
$+(%var,%chose)

Little example:

//var %x $mouse.x | var %y $mouse.y | echo -a Mouse Pos: $+(%x,x,%y)

Last edited by SladeKraven; 02/04/05 02:40 PM.
Re: Variable + a variable #116118 02/04/05 02:55 PM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
Thanks,

The example works, but I cant get it to work for myself, I'm sure I'm missing something dreadfully obvious

I used

/msg $chan $+(%var,%chose)

But all I get is the value of %chose, rather than %var%chose

The variable is correctly defined in the variables page

%var1 18

So when %chose is 1, and the output should be %var1
All I get is

1

If I use %var1 directly, without the %chose, it comes up right, just for some reason, the joining isnt working frown

Thanks

Re: Variable + a variable #116119 02/04/05 03:08 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Sorry mate I'm pretty tired so my apologies in advanced if I didn't understand you fully.. smile

$+($eval(%var,0),%chose)

I did a little test and did...

//var %var | var %chose 5 | echo 3 -a $+($eval(%var,0),%chose)

Which echoed:


%var5

Re: Variable + a variable #116120 02/04/05 03:20 PM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
Thanks a lot, I apreciate the help and it's useful for future reference even if it's not quite what I was trying to achieve smile

Sorry for not explaining myself properly frown

I'll try and explain a little better:

%var is not a variable. But %var1, %var2, %var3, %var4 and %var5 are. %chose is a variable which contains just the numbers 1 2 3 4 5.

So basically, say that

/set %var5 test
/set %chose 5

What I want to output to the channel is the actual value of %var5. But I cant use %var5 directly because the end number changes according to what %chose is.

So %var5 is the variable. I know the %var part never changes. %chose contains the end number. What I want to output is the value of %var5 (the variable). Or %var4 or %var3 or whatever %chose is which is added onto the end of %var.

IE

%var1 = test
%var2 = test2
%var3 = testing

%chose = 1
output test (%var1)

%chose = 2
output test2 (%var2)

%chose = 3
output testing (%var3)

Now, I could do it with a lot of if's, but there are a lot of %vars, and it'd be easier if I could just stick %var and %chose together to get a single variable reference to %varN.

I hope that explains it a bit better, I'm confusing myself smile

I'm very apreciative for the help.

Re: Variable + a variable #116121 02/04/05 04:00 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
//echo -a $($+(%,var,%chose),2)


Gone.
Re: Variable + a variable #116122 03/04/05 01:05 AM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
Perfect smile

Thanks a lot to both of you, it's been a great help smile

Re: Variable + a variable #116123 03/04/05 07:06 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You're welcome. smile