Search code examples
automationplccodesysstructured-text

Shift operation returning weird error


I'm programming a plc by ABB in the codesys environment, and I can't figure out why I'm getting this error:

Error 4024: ... Expecting ELSIF,  ELSE or END_IF before 'SHL' 

The code returning this error is something like:

IF flag THEN
    iState := 0;
    Step := false;
    SHL(1,iReg);
END_IF 

Basically two assignments and a shift left operation on an unsigned integer. The shift is what gives the error, and commenting the line eliminates it.

I've checked the syntax many times, also inverted the arguments a few times following contradicting documentation.

Can anyone tell me what I'm missing?


Solution

  • your SHL needs to have a result

    IF flag THEN
        iState := 0;
        Step := false;
        result := SHL(1,iReg);
    END_IF