Unexpected complex data in expression.

or

Boolean expression expected after IF.

These errors indicate that the IF  THEN  ELSE  ELSIF  END_IF condition used in the application code does not evaluate to a BOOL expression.

Controller:------------- Compile PLC ---------------

Controller:PLC:MCFB_Jog
Controller:PLC:MCFB_Jog: (16): Unexpected complex data in expression
Controller:PLC:MCFB_Jog: (16): Boolean expression expected after IF
Controller:PLC:MCFB_Jog: (19): END_IF: New statement expected

Controller:PLC:Error(s) detected
Controller:------------- PLC failed ---------------
Controller:------------- Device compile failed ---------------
...
Project compile failed

This compile error can happen when a non-compliant syntax is used for verifying the function block outputs.

  • In KAS v4.0 and earlier releases, it was possible to use the function block return statement in the same way as function return values.
    • This could result in undefined behavior.
  • In KAS v4.0 and later releases, the compiler generates a an Unexpected complex data in expression error for non-compliant syntax.
IEC 61131-3 Non-Compliant Syntax: 
If inst_functionBlock(myVar1) Then
   // ...
End_If;
IEC 61131-3 Compliant Syntax:
inst_functionBlock(myVar1);
If inst_functionBlock.Q Then
   // ...
End_If;

Error Correction

  1. Identify the code that caused compile error.
  2. If the error is due to non-compliant syntax, replace this code using compliant syntax for the corresponding function block.

Example: Non-compliant Syntax

   IF Inst_r_trig(Inst_TON.Q) THEN
     Inst_DriveParamRead( TRUE, any_to_int(Inst_MC_ReadParam.Value), 'DRV.FAULT1' );
   END_IF;

Example: Compliant Syntax

   Inst_r_trig(Inst_TON.Q);
   IF Inst_r_trig.Q THEN

     Inst_DriveParamRead( TRUE, any_to_int(Inst_MC_ReadParam.Value), 'DRV.FAULT1' );
   END_IF;

  • If you prefer to not update a KAS project to use compliant syntax, select the Allow non-compliant syntax to evaluate function block outputs check box in the Project Settings dialog box.


  • UDFBs and libraries can have improper syntax.

These Kollmorgen UDFBs have been corrected and can be re-imported into the application code.

See Re-import Kollmorgen UDFBs.

See Also