>It wasn't called for type=2 but was called in the stage where VFP determines the size of the field. Looks like VFP evaluates both expressions in IIF() to get correct size of a field. Here's another test wich demonstartes that.
SELECT *, ;
> PADR(IIF(1=1, "1", myudf("2",RECNO())),1) ;
> FROM test
>* z.z
>2 1
>
>As you can see myudf shouldn't be ever executed but it is for record #1. And again I see the same result in VFP7 and 8.
So, as the record for Type=2 was the first in Temp, that explains why it was acting like this. That might also explain why I never faced that situation before as I probably never encountered that specific scenario.
I guess the best approach is to select only the New.Type field as is in the cursor and then apply a SCAN on that cursor to get specific evaluation.