Warning 511 Assignment within IIF function arguments

Since a lot of people are making basic mistakes in 6.40.1 there will be a new warning for incorrect use of IIF:

An attempt to use incorrect code like this

IIf( C > 2, x = 4, x = 2 ); // BAD, DON'T DO THIS!

results now with warning 511 Assignment within IIF function arguments. Use IIF() return value instead

A proper usage of IIF is always using return value that contains result of IIF evaluation for the assignment like this:

x = IIF( C > 2, 4, 2 ); // CORRECT, no assignments inside IIF arguments

A quick question for you. Do you think of better wording for the message than "Assignment within IIF() function arguments. Use IIF() return value instead"


Good idea to add warning.

Perhaps some more hint what to do

"Warning 511: Remove all assignments within IIF() function and use IIF() return value instead"

without "Assignment within IIF() function arguments."

The design rule for error messages is that first sentence always describes the problem.
Such as "syntax error" or "missing arguments" or "number expected" or "missing parenthesis" or "assignment within conditional". It does not say "you need to add parenthesis here" in first sentence. Typically hint what to fix is given in second sentence.

Was trying to keep message short.
For example in analysis if an error or warning shows up there and message is too long then (at least on my end) the formula sometimes does not open when clicking "Details" button to see complete one.
Alright let's keep "Assignment within IIF() function arguments.".

You might include something like, "Hey dummy, did you even try reading the manual?"
You know, to gently guide the user. :angel:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.