as you've observed, $eval() only lets you evaluate a piece of text a certain number of times, it has no regard for command separators inside that text :P

special constructs such as if/while and even local variables declared with /var are interpreted before the routines that evaluate $eval() even come into play, which is why the following doesn't behave as intended:

Code:
  var %cmd = if (1) echo success
  $eval(%cmd, 2)


what you want can be done quite simply using functions of mIRC that are able to perform a series of commands (almost) as though they were simply inserted into your scripts editor. the multi-server related commands /scon and /scid will execute the given text as a line of code within the context of the current routine (that is to say, local variable declared within the scope in which the command is performed are accessible). unfortunately, $1- is not carried over which is rather regrettable :P

some examples:

Code:
  var -s %cmd = if (1) echo success
  scid $cid %cmd


Code:
  var -s %cmd = var $(%cmd2 = another variable |,) echo $(%cmd2,)
  scid $cid %cmd


Code:
  var -s %cmd = var $(%var2 = 1 |,) while (%var2 <= 5) $({ echo -a %var2 |,) inc $(%var2 },)
  scid $cid %cmd


$( ,) is simply short for $eval( ,0). as you can see, as long as you construct the line of code properly (preventing and delaying evaluations wherever necessary), you can create even the most complex series of commands. /timer also has a command parameter and thus can also be used in an equivalent manner to run lines of code. however, timers trigger commands in their own scope (as though a separate alias was called) which may or may not be more appropriate for you.

there's definitely a lot to say on the subject of mIRC's interpreter, if you have any other questions or run into any problems do let us know!


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde