Equal operator does not work in a simple loop? Wtf ?

hwillems
2021-03-13
2021-03-13
  • hwillems - 2021-03-13

    Hi There,

    I have the following code, and i can't wrap my head around how the "equal" operator does literally not work. I tried almost everything and i came to the conclusion that the following line doesn't work:

    rtarrNode[i].Status.oiNodePrio = j

    FOR i := 1 TO maxi DO
        FOR j := 1 TO MAX_PRIO DO
                    tempbool := (rtarrNode[i].Status.oiNodePrio = j);
                    rtarrNode[i].Control.ixStopBlocked := PrioGroupBlocked[j] AND tempbool;
        END_FOR;
    END_FOR;
    

    rtarrNode is reference for IN_OUT but i don't think that is relevant information.
    oiNodePrio is an INT, and j is an INT aswell used in the loop. It should be possible right?
    Already looked to anything else why it gave me a wrong result, it came down to rtarrNode[i].Status.oiNodePrio "equal" to j.

    Does anyone know why this does not work? It's really weird.

    Greetings.

     
  • hwillems - 2021-03-13

    Already solved! I still don't know how and why this is not possible. Codesys has some strange things sometimes....

    Anyway how i solved is way more efficient and neat(Not double loop, and more like "pattern matching" stuff):

    FOR i := 1 TO maxi DO
        rtarrNode[i].Control.ixStopBlocked := PrioGroupBlocked[rtarrNode[i].Status.oiNodePrio];
    END_FOR;
    
     

    Last edit: hwillems 2021-03-13

Log in to post a comment.