clabacchio
clabacchio

Reputation: 1057

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?

Upvotes: 1

Views: 320

Answers (1)

mrsargent
mrsargent

Reputation: 2442

your SHL needs to have a result

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

Upvotes: 2

Related Questions