I have a script that does something like this...
(1) A variable %reply_message exists, which defines the format of a message to send a user. Specifically, [username] will be replaced by the actual username when the message is sent.
(2) Upon a certain event, a message is sent to the user. Specifically, %reply_message is the message that is sent where [username] is replaced by some other value. Also, other identifiers should be allowed in this variable definition (e.g. $iif(..), $duration(..), etc.)

Variable definition:
Code:
%reply_message You are $iif([username] == $null, not logged in, logged in as [username]) $+ .


The following code is trigged by some event:
Code:
msg $nick $eval($replacex(%reply_message, [username], %username), 2)


Let's break this down into the steps the computer will follow when evaluating this code...

Case 1: %username has been set to "test_username"
(1) Replace all occurrances of [username] with test_username
Code:
You are $iif([username] == $null, not logged in, logged in as [username]) $+ .
becomes
Code:
You are $iif(test_username == $null, not logged in, logged in as test_username) $+ .

(2) Because of the $eval(.., 2) all identifiers are then evaluated. The $iif(..) is false, and so it becomes
Code:
You are logged in as test_username.

(3) Then this message is sent to the user.
THIS WORKS!

Case 2: %username has not been set
(1) Replace all occurrances of [username] with (nothing)
Code:
You are $iif([username] == $null, not logged in, logged in as [username]) $+ .
becomes
Code:
You are $iif( == $null, not logged in, logged in as ) $+ .

(2) Because of the $eval(.., 2), all identifiers should then be evaluated. Uh oh! mIRC gives an error when it sees $iif( == $null, .......)
This doesn't work frown

Conclusion:
Instead of giving an error, mIRC should realize this expression evaluates to TRUE.