title: CoDeSys: BOOL becomes "*** INVALID: 16#02 ***" outside case (link between two vars)
body: <p>When I trace my program (online with breakpoint and singlestep) I see,
  that the VAR SOpen becomes "<strong>* INVALID: 16#02 *</strong>" when the line <code>Step:=Step+1;</code> is reached.</p>
  
  <p>Watching the trace more careful, I saw, that Step changes from 0 to 1, in the first call of "0:". The two VARs are the two initialized and seem to be linked together. The aditional increase sets Step to 2 (in the 1st run!) and SOpen to invalid.</p>
  
  <pre><code>PROGRAM PLC_PRG
  VAR
      SerIO: SERCOMM;
      Step: BYTE := 0;
      Input: ARRAY [0..50] OF DWORD;
      SOpen: BOOL := FALSE;
  END_VAR
  
  IF Eingang1 THEN
      CASE Step OF
      0:
          IF NOT SOpen THEN
              SerIO.FB_ACTION := Open;
              SerIO.RECEIVE_BUFFER:=Input[0];
              SerIO.COMPORT:=1;
              SerIO.EN:=TRUE;
              Ausgang1 := NOT SerIO.ERROR;
              SOpen :=TRUE;
              SerIO.EN:=FALSE;
          END_IF;
      1:
          IF SOpen THEN
              SerIO.FB_ACTION:=Read;
              SerIO.EN:=TRUE;
              Ausgang1 := NOT SerIO.ERROR;
              Ausgang2 := (SerIO.BYTES_DONE&gt;3);
              SerIO.EN:=FALSE;
          END_IF;
      2:
          IF SOpen THEN
              SerIO.FB_ACTION:=Close;
              SerIO.EN:=TRUE;
              Ausgang1 := NOT SerIO.ERROR;
              SOpen :=FALSE;
              SerIO.EN:=FALSE;
          END_IF;
      END_CASE
      Step:=Step+1;
      IF Step&gt;2 THEN Step :=0; END_IF;
  ELSIF SOpen THEN
      SerIO.FB_ACTION:=Close;
      SerIO.EN:=TRUE;
      SerIO.EN:=FALSE;
      SOpen :=FALSE;
      Step:=0;
  END_IF;
  </code></pre>