mIRC Homepage
Posted By: pouncer evaluation question - 05/02/06 10:32 PM
%c set to 'there'
(below i have in a join event)
.timertst -m 1 100 echo -a hello [ $+ [ %c ] ]

echos hellothere

it should echo

hello there
Posted By: drc4 Re: evaluation question - 05/02/06 11:00 PM
the line
Code:
timertst -m 1 100 echo -a hello [ $+ [ %c ] ]

doesn't need the [ $+ [ ] ]
just change it to
Code:
timertst -m 1 100 echo -a hello %c

the $+ is combining the hello and there.
Posted By: pouncer Re: evaluation question - 06/02/06 12:42 AM
that just echos hello
Posted By: FiberOPtics Re: evaluation question - 06/02/06 01:04 AM
.timertst -m 1 100 echo -a hello %c

I have no idea why you would be using $+, since that concatenates strings, and you don't want it to be concatenated. The [ ] brackets serve no purpose here btw, they only serve a purpose when trying to evaluate dynamic variables, or when changing the order of evaluation. Yours is just a regular variable, so none of the cases apply.

EDIT: drc4 apparently already said this lol, didn't read his post. If it only echo's "hello", then it means that you don't have a global variable named %c. I put global in bold, because you say you have that code below in an on join event, this means it is seperated from where the variable is set. If you were setting %c as a local variable (/var or /set -l) then the variable is destroyed once the script finishes, so it would have no meaning in an on join event.
Posted By: pouncer Re: evaluation question - 06/02/06 12:56 PM
ok thanks, what about something like this then

Code:
elseif ($2 == JOIN) {
var %c = %testvar

.timertest -m 1 100 echo -a This is a %c
}


how can i get it to echo the %c bit, because it only echos
'This is a'
Posted By: FiberOPtics Re: evaluation question - 06/02/06 02:00 PM
If it only echoes 'this is a' then it means %c is $null, which in term means %testvar is $null, so you need to look at how and where %testvar is being set, because in its current state %testvar has no value.
Posted By: pouncer Re: evaluation question - 06/02/06 02:05 PM
but i just want to make it echo..

This is a %testvar
Posted By: FiberOPtics Re: evaluation question - 06/02/06 02:13 PM
I don't think you are understanding the concepts of variables in mIRC here.

You assign the value of %testvar to a variable named %c. You then echo the value of %c and it shows that %c is empty. What does that tell you about %testvar? It tells you it has no value, so your results are completely natural.

If you want it to echo something, you will need to set the %testvar to some value prior to the setting to %c.

Or do you mean you want to actually echo "%testvar"? To do that you do: //echo -a % $+ testvar

Or if you wanna do it with another variable it's like this:

var %c = % $+ testvar
echo -a %c

BUT in a timer, things are evaluated two times when called from a script! One time when you call the timer, and one time when the timer triggers. Let's see what that does to your example:

var %c = % $+ testvar
.timer 1 0 echo -a %c

--> when the timer is initiated %c is evaluated to %testvar
--> when the timer triggers %testvar again evaluates, this time to $null, because %testvar has no value set.

Solution:

var %c = % $!+ testvar
.timer 1 0 echo -a %c

--> evaluates %c to % $+ testvar
--> evaluates % $+ testvar to %testvar
Posted By: pouncer Re: evaluation question - 06/02/06 02:25 PM
thanks alot!!!
© mIRC Discussion Forums