Getting Data types correct

nickobs
2012-01-09
2012-01-13
  • nickobs - 2012-01-09

    In other dialects I have done something like:-

    bool_var := (int_var = 53);

    ie the boolean is set TRUE if the int equals 53 otherwise it is FALSE.
    can I do this here?

     
  • singleton - 2012-01-09

    Yes you can

     
  • nickobs - 2012-01-09

    thanks for the reply. I got my example wrong - what I was actually trying to do was as below.

    bool_var := (int_var AND 8);

     
  • nickobs - 2012-01-09

    thanks for the reply. I got my example wrong - what I was actually trying to do was as below.

    bool_var := (int_var AND 8);

     
  • singleton - 2012-01-09

    nickobs hat geschrieben:

    bool_var := (int_var AND 8);
    

    This will not work. That is not a boolean expression. But the first example should work. Happy CoDeSysing!

     
  • t.lundahl - 2012-01-11

    Hi!

    What I understand is that you can do a bit compare but only with WORD types.

    BOOL := WORD AND 2#10010010

    /T

     
  • shooter - 2012-01-13

    stop when you do an binary AND the result is still a word.
    you must convert it by WORD_TO_BOOL to work correct, and yes the shortcuts will work, but are not easy to read, and are not in IEC

     

Log in to post a comment.